improvements, refactroing, etc...
This commit is contained in:
parent
d245c50890
commit
268ec3f7f4
|
|
@ -1,5 +1,7 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using AyCode.Services.SignalRs;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Loggers;
|
||||
using FruitBank.Common.Models;
|
||||
|
|
@ -14,13 +16,68 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
||||
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringModel)]
|
||||
public async Task<MeasuringModel> GetMeasuringModel()
|
||||
[SignalR(SignalRTags.GetMeasuringModels)]
|
||||
public async Task<List<MeasuringModel>> GetMeasuringModels()
|
||||
{
|
||||
_logger.Detail($"GetMeasuringModel invoked");
|
||||
throw new NotImplementedException("GetMeasuringModels");
|
||||
}
|
||||
|
||||
var partner = await ctx.Partners.Table.FirstOrDefaultAsync();
|
||||
return new MeasuringModel($"GetMeasuringModel invoked [{DateTime.Now}] [{partner?.Name}]");
|
||||
[SignalR(SignalRTags.GetMeasuringModelByShippingId)]
|
||||
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||
{
|
||||
throw new NotImplementedException("GetMeasuringModelByShippingId");
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPartners)]
|
||||
public async Task<List<Partner>> GetPartners()
|
||||
{
|
||||
_logger.Detail($"GetPartners invoked");
|
||||
|
||||
return await ctx.Partners.Table.ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPartnerById)]
|
||||
public async Task<Partner> GetPartnerById(int id)
|
||||
{
|
||||
_logger.Detail($"GetPartnerById invoked; id: {id}");
|
||||
|
||||
return await ctx.Partners.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippings)]
|
||||
public async Task<List<Shipping>> GetShippings()
|
||||
{
|
||||
_logger.Detail($"GetShippings invoked");
|
||||
|
||||
return await ctx.Shippings.Table.ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingById)]
|
||||
public async Task<Shipping> GetShippingById(int id)
|
||||
{
|
||||
_logger.Detail($"GetShippingById invoked; id: {id}");
|
||||
|
||||
return await ctx.Shippings.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
public async Task<List<ShippingItem>> GetShippingItem()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<ShippingItem> GetShippingItemById(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<List<ShippingDocument>> GetShippingDocuments()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<ShippingDocument> GetShippingDocumentById(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,22 +7,24 @@ using Nop.Services.Logging;
|
|||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||
public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>, IShippingDbSet<ShippingDbTable>
|
||||
{
|
||||
private readonly IProductService _productService;
|
||||
private readonly IStaticCacheManager _staticCacheManager;
|
||||
|
||||
public PartnerDbTable Partners { get; set; }
|
||||
public ShippingDbTable Shippings { get; set; }
|
||||
//public EntityRepository<Auction> Auctions2 { get; set; }
|
||||
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
||||
|
||||
|
||||
public FruitBankDbContext(INopDataProvider dataProvider, PartnerDbTable partnerDbTable, IProductService productService, IStaticCacheManager staticCacheManager, ILogger logger) : base(dataProvider, logger)
|
||||
public FruitBankDbContext(INopDataProvider dataProvider, PartnerDbTable partnerDbTable, ShippingDbTable shippingDbTable, IProductService productService, IStaticCacheManager staticCacheManager, ILogger logger) : base(dataProvider, logger)
|
||||
{
|
||||
_productService = productService;
|
||||
_staticCacheManager = staticCacheManager;
|
||||
|
||||
Partners = partnerDbTable;
|
||||
Shippings = shippingDbTable;
|
||||
|
||||
//Auctions.Table
|
||||
//var auctions = DataProvider.GetTable<Auction>().Where(x => x.Closed);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using Mango.Nop.Core.Interfaces;
|
||||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Interfaces;
|
||||
using Nop.Data;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||
|
||||
public interface IShippingDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<Shipping>
|
||||
{
|
||||
public TDbTable Shippings { get; set; }
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
using Mango.Nop.Core.Repositories;
|
||||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Data;
|
||||
using Nop.Services.Logging;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
public class ShippingDbTable : MgDbTableBase<Shipping>
|
||||
{
|
||||
public ShippingDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
|
||||
[Table(Name = "fbPartner")]
|
||||
public class Partner : MgEntityBase, IPartner
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string State { get; set; }
|
||||
public string County { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Street { get; set; }
|
||||
|
||||
[SkipValuesOnUpdate]
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
|
||||
[Table(Name = "fbShipping")]
|
||||
public class Shipping : MgEntityBase, IShipping
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PartnerId { get; set; }
|
||||
public DateTime ShippingDate { get; set; }
|
||||
public string LicencePlate { get; set; }
|
||||
|
||||
[SkipValuesOnUpdate]
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
|
||||
[Table(Name = "fbShippingDocument")]
|
||||
public class ShippingDocument : MgEntityBase, ISippingDocument
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PartnerId { get; set; }
|
||||
public int ShippingId { get; set; }
|
||||
public int ShippingItemId { get; set; }
|
||||
public DateTime ShippingDate { get; set; }
|
||||
public string Country { get; set; }
|
||||
|
||||
[SkipValuesOnUpdate]
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB.Mapping;
|
||||
using Mango.Nop.Core.Entities;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
|
||||
[Table(Name = "fbShippingItem")]
|
||||
public class ShippingItem : MgEntityBase, IShippingItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ShippingDocumentId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public double NetWeight { get; set; }
|
||||
public double GrossWeight { get; set; }
|
||||
public double MeasuredNetWeight { get; set; }
|
||||
public double MeasuredGrossWeight { get; set; }
|
||||
|
||||
[SkipValuesOnUpdate]
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ public class PluginNopStartup : INopStartup
|
|||
//services.AddSingleton<SessionService>();
|
||||
|
||||
services.AddScoped<PartnerDbTable>();
|
||||
services.AddScoped<ShippingDbTable>();
|
||||
|
||||
services.AddScoped<FruitBankDbContext>();
|
||||
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Nop.Data.Mapping;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.Entities;
|
||||
using FruitBank.Common;
|
||||
using FruitBank.Common.Entities;
|
||||
using Nop.Data.Mapping;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Mapping;
|
||||
|
||||
|
|
@ -10,10 +11,10 @@ public partial class NameCompatibility : INameCompatibility
|
|||
/// </summary>
|
||||
public Dictionary<Type, string> TableNames => new Dictionary<Type, string>
|
||||
{
|
||||
{ typeof(Partner), "fbPartner" },
|
||||
{ typeof(Shipping), "fbShipping" },
|
||||
{ typeof(ShippingItem), "fbShippingItem" },
|
||||
{ typeof(ShippingDocument), "fbShippingDocument" },
|
||||
{ typeof(Partner), FruitBankConstClient.PartnerDbTableName },
|
||||
{ typeof(Shipping), FruitBankConstClient.ShippingDbTableName },
|
||||
{ typeof(ShippingItem), FruitBankConstClient.ShippingItemDbTableName},
|
||||
{ typeof(ShippingDocument), FruitBankConstClient.ShippingDocumentDbTableName },
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
<Folder Include="Areas\Admin\Extensions\" />
|
||||
<Folder Include="Areas\Admin\Factories\" />
|
||||
<Folder Include="Areas\Admin\Validators\" />
|
||||
<Folder Include="Domains\Entities\" />
|
||||
<Folder Include="Extensions\" />
|
||||
<Folder Include="Factories\" />
|
||||
<Folder Include="Models\" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue