improvement, fixes, etc...
This commit is contained in:
parent
568deb0131
commit
efe66eaa88
|
|
@ -6,6 +6,7 @@ using FruitBank.Common.Loggers;
|
|||
using FruitBank.Common.Models;
|
||||
using FruitBank.Common.Server;
|
||||
using FruitBank.Common.SignalRs;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
using Mango.Nop.Core.Models;
|
||||
using Nop.Core;
|
||||
|
|
@ -40,7 +41,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
[SignalR(SignalRTags.GetMeasuringModelByShippingId)]
|
||||
public async Task<MeasuringModel> GetMeasuringModelByShippingId(int shippingId)
|
||||
{
|
||||
return await ctx.GetMeasuringModelByShippingId(shippingId).FirstOrDefaultAsync();
|
||||
return await ctx.GetMeasuringModelByShippingId(shippingId).FirstOrDefaultAsync(c => true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPartners)]
|
||||
|
|
@ -79,7 +80,16 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
{
|
||||
_logger.Detail($"GetShippings invoked");
|
||||
|
||||
return await ctx.Shippings.GetAll().ToListAsync();
|
||||
return await ctx.Shippings.GetAll(false).ToListAsync();
|
||||
//return await ctx.Shippings.Table.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetNotMeasuredShippings)]
|
||||
public async Task<List<Shipping>> GetNotMeasuredShippings()
|
||||
{
|
||||
_logger.Detail($"GetNotMeasuredShippings invoked");
|
||||
|
||||
return await ctx.Shippings.GetNotMeasured(true).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingById)]
|
||||
|
|
@ -87,7 +97,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
{
|
||||
_logger.Detail($"GetShippingById invoked; id: {id}");
|
||||
|
||||
return await ctx.Shippings.GetByIdAsync(id);
|
||||
return await ctx.Shippings.GetByIdAsync(id, true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShipping)]
|
||||
public async Task<Shipping> UpdateShipping(Shipping shipping)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shipping);
|
||||
|
||||
_logger.Detail($"UpdateShipping invoked; id: {shipping.Id}");
|
||||
|
||||
await ctx.Shippings.UpdateAsync(shipping);
|
||||
return shipping;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingItems)]
|
||||
|
|
@ -106,6 +127,17 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
return await ctx.ShippingItems.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingItem)]
|
||||
public async Task<ShippingItem> UpdateShippingItem(ShippingItem shippingItem)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shippingItem);
|
||||
|
||||
_logger.Detail($"UpdateShippingItem invoked; id: {shippingItem.Id}");
|
||||
|
||||
await ctx.ShippingItems.UpdateAsync(shippingItem);
|
||||
return shippingItem;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetShippingDocuments)]
|
||||
public async Task<List<ShippingDocument>> GetShippingDocuments()
|
||||
{
|
||||
|
|
@ -122,6 +154,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
return await ctx.ShippingDocuments.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.UpdateShippingDocument)]
|
||||
public async Task<ShippingDocument> UpdateShippingDocument(ShippingDocument shippingDocument)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shippingDocument);
|
||||
|
||||
_logger.Detail($"UpdateShippingDocument invoked; id: {shippingDocument.Id}");
|
||||
|
||||
await ctx.ShippingDocuments.UpdateAsync(shippingDocument);
|
||||
return shippingDocument;
|
||||
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringUsers)]
|
||||
public async Task<List<CustomerDto>> GetMeasuringUsers()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using DocumentFormat.OpenXml.Drawing;
|
||||
using FruitBank.Common.Models;
|
||||
using LinqToDB;
|
||||
using FruitBank.Common.Models;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Customers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Entities;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Repositories;
|
||||
using Nop.Core.Caching;
|
||||
using Nop.Core.Configuration;
|
||||
|
|
@ -14,4 +15,23 @@ public class ShippingDbTable : MgDbTableBase<Shipping>
|
|||
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IOrderedQueryable<Shipping> GetAll()
|
||||
=> base.GetAll().OrderBy(s => s.ShippingDate);
|
||||
|
||||
public IQueryable<Shipping> GetAll(bool loadRelations)
|
||||
{
|
||||
return loadRelations
|
||||
? GetAll()
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(si => si.ShippingItems)
|
||||
.LoadWith(sd => sd.ShippingDocuments).ThenLoad(p => p.Partner)
|
||||
: GetAll();
|
||||
}
|
||||
|
||||
public IQueryable<Shipping> GetNotMeasured(bool loadRelations)
|
||||
=> GetAll(loadRelations).Where(s => !s.IsAllMeasured);
|
||||
|
||||
|
||||
public Task<Shipping> GetByIdAsync(int id, bool loadRelations)
|
||||
=> GetAll(loadRelations).FirstOrDefaultAsync(s => s.Id == id);
|
||||
}
|
||||
Loading…
Reference in New Issue