improvements, fixes, etc....
This commit is contained in:
parent
268ec3f7f4
commit
fbad15e02f
|
|
@ -11,6 +11,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
{
|
{
|
||||||
|
//https://linq2db.github.io/articles/sql/Join-Operators.html
|
||||||
public class FruitBankDataController(FruitBankDbContext ctx, IEnumerable<IAcLogWriterBase> logWriters): Controller, IFruitBankDataControllerServer
|
public class FruitBankDataController(FruitBankDbContext ctx, IEnumerable<IAcLogWriterBase> logWriters): Controller, IFruitBankDataControllerServer
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
private readonly ILogger _logger = new Logger<FruitBankDataController>(logWriters.ToArray());
|
||||||
|
|
@ -25,7 +26,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
[SignalR(SignalRTags.GetMeasuringModelByShippingId)]
|
[SignalR(SignalRTags.GetMeasuringModelByShippingId)]
|
||||||
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("GetMeasuringModelByShippingId");
|
return await ctx.GetMeasuringModelByShippingId(shippingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.GetPartners)]
|
[SignalR(SignalRTags.GetPartners)]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Mango.Nop.Core.Repositories;
|
using FruitBank.Common.Models;
|
||||||
|
using Mango.Nop.Core.Repositories;
|
||||||
using Nop.Core.Caching;
|
using Nop.Core.Caching;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||||
|
|
@ -7,29 +8,42 @@ using Nop.Services.Logging;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>, IShippingDbSet<ShippingDbTable>
|
public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>, IShippingDbSet<ShippingDbTable>, IShippingItemDbSet<ShippingItemDbTable>
|
||||||
{
|
{
|
||||||
private readonly IProductService _productService;
|
private readonly IProductService _productService;
|
||||||
private readonly IStaticCacheManager _staticCacheManager;
|
private readonly IStaticCacheManager _staticCacheManager;
|
||||||
|
|
||||||
public PartnerDbTable Partners { get; set; }
|
public PartnerDbTable Partners { get; set; }
|
||||||
public ShippingDbTable Shippings { get; set; }
|
public ShippingDbTable Shippings { get; set; }
|
||||||
|
public ShippingItemDbTable ShippingItems { get; set; }
|
||||||
//public EntityRepository<Auction> Auctions2 { get; set; }
|
//public EntityRepository<Auction> Auctions2 { get; set; }
|
||||||
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
//public IRepository<AuctionBid> AuctionBids2 { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public FruitBankDbContext(INopDataProvider dataProvider, PartnerDbTable partnerDbTable, ShippingDbTable shippingDbTable, IProductService productService, IStaticCacheManager staticCacheManager, ILogger logger) : base(dataProvider, logger)
|
public FruitBankDbContext(INopDataProvider dataProvider, PartnerDbTable partnerDbTable, ShippingDbTable shippingDbTable, ShippingItemDbTable shippingItemDbTable, IProductService productService, IStaticCacheManager staticCacheManager, ILogger logger) : base(dataProvider, logger)
|
||||||
{
|
{
|
||||||
_productService = productService;
|
_productService = productService;
|
||||||
_staticCacheManager = staticCacheManager;
|
_staticCacheManager = staticCacheManager;
|
||||||
|
|
||||||
Partners = partnerDbTable;
|
Partners = partnerDbTable;
|
||||||
Shippings = shippingDbTable;
|
Shippings = shippingDbTable;
|
||||||
|
ShippingItems = shippingItemDbTable;
|
||||||
|
|
||||||
//Auctions.Table
|
//Auctions.Table
|
||||||
//var auctions = DataProvider.GetTable<Auction>().Where(x => x.Closed);
|
//var auctions = DataProvider.GetTable<Auction>().Where(x => x.Closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||||
|
{
|
||||||
|
var query =
|
||||||
|
from p in Partners.Table
|
||||||
|
join s in Shippings.Table on p.Id equals s.PartnerId
|
||||||
|
where s.Id == shippingId
|
||||||
|
select new MeasuringModel(p.Name);
|
||||||
|
|
||||||
|
return await query.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
////public AuctionDbContext(IRepository<Auction> _auctionRepository, IRepository<AuctionBid> _auctionBidRepository)
|
////public AuctionDbContext(IRepository<Auction> _auctionRepository, IRepository<AuctionBid> _auctionBidRepository)
|
||||||
////{
|
////{
|
||||||
//// Auctions2 = _auctionRepository as EntityRepository<Auction>;
|
//// Auctions2 = _auctionRepository as EntityRepository<Auction>;
|
||||||
|
|
|
||||||
|
|
@ -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 IShippingItemDbSet<TDbTable> : IMgDbTableBase where TDbTable : IRepository<ShippingItem>
|
||||||
|
{
|
||||||
|
public TDbTable ShippingItems { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -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 ShippingItemDbTable : MgDbTableBase<ShippingItem>
|
||||||
|
{
|
||||||
|
public ShippingItemDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
|
||||||
|
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -44,6 +44,7 @@ public class PluginNopStartup : INopStartup
|
||||||
|
|
||||||
services.AddScoped<PartnerDbTable>();
|
services.AddScoped<PartnerDbTable>();
|
||||||
services.AddScoped<ShippingDbTable>();
|
services.AddScoped<ShippingDbTable>();
|
||||||
|
services.AddScoped<ShippingItemDbTable>();
|
||||||
|
|
||||||
services.AddScoped<FruitBankDbContext>();
|
services.AddScoped<FruitBankDbContext>();
|
||||||
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue