Add PartnerDepot support: data table, DI, SignalR endpoints
Introduced PartnerDepotDbTable for managing PartnerDepot entities, registered it in DI, and integrated it into FruitBankDbContext. Updated NameCompatibility and PartnerDbTable for proper mapping and relation loading. Added SignalR controller endpoints for PartnerDepot CRUD and queries.
This commit is contained in:
parent
6b105bb5ed
commit
b782d6a88d
|
|
@ -219,6 +219,50 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
return await ctx.CargoTrucks.GetByIdAsync(cargoTruck.Id, true);
|
return await ctx.CargoTrucks.GetByIdAsync(cargoTruck.Id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetPartnerDepots)]
|
||||||
|
public async Task<List<PartnerDepot>> GetPartnerDepots()
|
||||||
|
{
|
||||||
|
_logger.Detail($"GetPartnerDepots invoked");
|
||||||
|
|
||||||
|
return await ctx.PartnerDepots.GetAll(true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetPartnerDepotById)]
|
||||||
|
public async Task<PartnerDepot> GetPartnerDepotById(int id)
|
||||||
|
{
|
||||||
|
_logger.Detail($"GetPartnerDepotById invoked; id: {id}");
|
||||||
|
return await ctx.PartnerDepots.GetByIdAsync(id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.GetPartnerDepotsByPartnerId)]
|
||||||
|
public async Task<List<PartnerDepot>> GetPartnerDepotsByPartnerId(int partnerId)
|
||||||
|
{
|
||||||
|
_logger.Detail($"GetPartnerDepotsByPartnerId invoked; partnerId: {partnerId}");
|
||||||
|
return await ctx.PartnerDepots.GetByPartnerId(partnerId, true).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.AddPartnerDepot)]
|
||||||
|
public async Task<PartnerDepot> AddPartnerDepot(PartnerDepot partnerDepot)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(partnerDepot);
|
||||||
|
|
||||||
|
_logger.Detail($"AddPartnerDepot invoked; id: {partnerDepot.Id}");
|
||||||
|
|
||||||
|
await ctx.PartnerDepots.InsertAsync(partnerDepot);
|
||||||
|
return await ctx.PartnerDepots.GetByIdAsync(partnerDepot.Id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SignalR(SignalRTags.UpdatePartnerDepot)]
|
||||||
|
public async Task<PartnerDepot> UpdatePartnerDepot(PartnerDepot partnerDepot)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(partnerDepot);
|
||||||
|
|
||||||
|
_logger.Detail($"UpdatePartnerDepot invoked; id: {partnerDepot.Id}");
|
||||||
|
|
||||||
|
await ctx.PartnerDepots.UpdateAsync(partnerDepot);
|
||||||
|
return await ctx.PartnerDepots.GetByIdAsync(partnerDepot.Id, true);
|
||||||
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.GetShippings)]
|
[SignalR(SignalRTags.GetShippings)]
|
||||||
public async Task<List<Shipping>> GetShippings()
|
public async Task<List<Shipping>> GetShippings()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
||||||
public OrderItemDtoDbTable OrderItemDtos { get; set; }
|
public OrderItemDtoDbTable OrderItemDtos { get; set; }
|
||||||
|
|
||||||
public PartnerDbTable Partners { get; set; }
|
public PartnerDbTable Partners { get; set; }
|
||||||
|
public PartnerDepotDbTable PartnerDepots { get; set; }
|
||||||
public CargoPartnerDbTable CargoPartners { get; set; }
|
public CargoPartnerDbTable CargoPartners { get; set; }
|
||||||
public CargoTruckDbTable CargoTrucks{ get; set; }
|
public CargoTruckDbTable CargoTrucks{ get; set; }
|
||||||
|
|
||||||
|
|
@ -81,7 +82,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
||||||
public IRepository<StockQuantityHistoryExt> StockQuantityHistoriesExt { get; set; }
|
public IRepository<StockQuantityHistoryExt> StockQuantityHistoriesExt { get; set; }
|
||||||
|
|
||||||
public FruitBankDbContext(INopDataProvider dataProvider, ILockService lockService, FruitBankAttributeService fruitBankAttributeService, IStoreContext storeContext,
|
public FruitBankDbContext(INopDataProvider dataProvider, ILockService lockService, FruitBankAttributeService fruitBankAttributeService, IStoreContext storeContext,
|
||||||
CargoPartnerDbTable cargoPartnerDbTable, CargoTruckDbTable cargoTruckDbTable, PartnerDbTable partnerDbTable, ShippingDbTable shippingDbTable, ShippingDocumentDbTable shippingDocumentDbTable, ShippingItemDbTable shippingItemDbTable,
|
CargoPartnerDbTable cargoPartnerDbTable, CargoTruckDbTable cargoTruckDbTable, PartnerDbTable partnerDbTable, PartnerDepotDbTable partnerDepotDbTable, ShippingDbTable shippingDbTable, ShippingDocumentDbTable shippingDocumentDbTable, ShippingItemDbTable shippingItemDbTable,
|
||||||
ShippingItemPalletDbTable shippingItemPalletDbTable, FilesDbTable filesDbTable, ShippingDocumentToFilesDbTable shippingDocumentToFilesDbTable,
|
ShippingItemPalletDbTable shippingItemPalletDbTable, FilesDbTable filesDbTable, ShippingDocumentToFilesDbTable shippingDocumentToFilesDbTable,
|
||||||
ProductDtoDbTable productDtoDbTable, OrderDtoDbTable orderDtoDbTable, OrderItemDtoDbTable orderItemDtoDbTable, OrderItemPalletDbTable orderItemPalletDbTable,
|
ProductDtoDbTable productDtoDbTable, OrderDtoDbTable orderDtoDbTable, OrderItemDtoDbTable orderItemDtoDbTable, OrderItemPalletDbTable orderItemPalletDbTable,
|
||||||
StockQuantityHistoryDtoDbTable stockQuantityHistoryDtos, CustomerCreditDbTable customerCreditDbTable,
|
StockQuantityHistoryDtoDbTable stockQuantityHistoryDtos, CustomerCreditDbTable customerCreditDbTable,
|
||||||
|
|
@ -108,6 +109,7 @@ public class FruitBankDbContext : MgDbContextBase,
|
||||||
|
|
||||||
Files = filesDbTable;
|
Files = filesDbTable;
|
||||||
Partners = partnerDbTable;
|
Partners = partnerDbTable;
|
||||||
|
PartnerDepots = partnerDepotDbTable;
|
||||||
CargoPartners = cargoPartnerDbTable;
|
CargoPartners = cargoPartnerDbTable;
|
||||||
CargoTrucks = cargoTruckDbTable;
|
CargoTrucks = cargoTruckDbTable;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,10 @@ public class PartnerDbTable : MgDbTableBase<Partner>
|
||||||
{
|
{
|
||||||
return loadRelations
|
return loadRelations
|
||||||
? GetAll()
|
? GetAll()
|
||||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(s => s.Shipping)
|
.LoadWith(p => p.PartnerDepots)
|
||||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems).ThenLoad(sip => sip.ShippingItemPallets)
|
.LoadWith(p => p.ShippingDocuments).ThenLoad(sd => sd.Shipping)
|
||||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(sdtof => sdtof.ShippingDocumentToFiles).ThenLoad(f => f.ShippingDocumentFile)
|
.LoadWith(p => p.ShippingDocuments).ThenLoad(sd => sd.ShippingItems).ThenLoad(si => si.ShippingItemPallets)
|
||||||
|
.LoadWith(p => p.ShippingDocuments).ThenLoad(sd => sd.ShippingDocumentToFiles).ThenLoad(sdtof => sdtof.ShippingDocumentFile)
|
||||||
: GetAll();
|
: GetAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
using FruitBank.Common.Entities;
|
||||||
|
using LinqToDB;
|
||||||
|
using Mango.Nop.Data.Repositories;
|
||||||
|
using Nop.Core.Caching;
|
||||||
|
using Nop.Core.Configuration;
|
||||||
|
using Nop.Core.Events;
|
||||||
|
using Nop.Data;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
|
public class PartnerDepotDbTable : MgDbTableBase<PartnerDepot>
|
||||||
|
{
|
||||||
|
public PartnerDepotDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
|
||||||
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IOrderedQueryable<PartnerDepot> GetAll() => base.GetAll().OrderBy(p => p.PartnerId);
|
||||||
|
|
||||||
|
public IQueryable<PartnerDepot> GetAll(bool loadRelations)
|
||||||
|
{
|
||||||
|
return loadRelations ? GetAll().LoadWith(sd => sd.Partner) : GetAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<PartnerDepot> GetByIdAsync(int id, bool loadRelations) => GetAll(loadRelations).FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
public IQueryable<PartnerDepot> GetByPartnerId(int partnerId, bool loadRelations) => GetAll(loadRelations).Where(p => p.PartnerId == partnerId);
|
||||||
|
}
|
||||||
|
|
@ -83,6 +83,7 @@ public class PluginNopStartup : INopStartup
|
||||||
services.AddScoped<OrderItemPalletDbTable>();
|
services.AddScoped<OrderItemPalletDbTable>();
|
||||||
|
|
||||||
services.AddScoped<PartnerDbTable>();
|
services.AddScoped<PartnerDbTable>();
|
||||||
|
services.AddScoped<PartnerDepotDbTable>();
|
||||||
services.AddScoped<CargoPartnerDbTable>();
|
services.AddScoped<CargoPartnerDbTable>();
|
||||||
services.AddScoped<CargoTruckDbTable>();
|
services.AddScoped<CargoTruckDbTable>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ public partial class NameCompatibility : INameCompatibility
|
||||||
|
|
||||||
{ typeof(CargoPartner), FruitBankConstClient.CargoPartnerDbTableName},
|
{ typeof(CargoPartner), FruitBankConstClient.CargoPartnerDbTableName},
|
||||||
{ typeof(CargoTruck), FruitBankConstClient.CargoTruckDbTableName},
|
{ typeof(CargoTruck), FruitBankConstClient.CargoTruckDbTableName},
|
||||||
|
|
||||||
|
{ typeof(PartnerDepot), FruitBankConstClient.PartnerDepotDbTableName},
|
||||||
|
{ typeof(EkaerHistory), FruitBankConstClient.EkaerHistoryDbTableName},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue