This commit is contained in:
Adam 2025-10-23 10:26:20 +02:00
commit 236e2c6a03
26 changed files with 140 additions and 153 deletions

View File

@ -29,6 +29,7 @@ using Nop.Services.Orders;
using Nop.Services.Security;
using Nop.Services.Seo;
using Nop.Services.Shipping;
using Nop.Web.Areas.Admin.Controllers;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Areas.Admin.Infrastructure.Mapper.Extensions;
using Nop.Web.Areas.Admin.Models.Catalog;
@ -39,7 +40,7 @@ using Nop.Web.Framework.Mvc.ModelBinding;
using Nop.Web.Framework.Validators;
using System.Text;
namespace Nop.Web.Areas.Admin.Controllers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
public partial class CustomProductController : BaseAdminController
{
@ -2734,7 +2735,7 @@ public partial class CustomProductController : BaseAdminController
//fill entity from model
var tierPrice = model.ToEntity<TierPrice>();
tierPrice.ProductId = product.Id;
tierPrice.CustomerRoleId = model.CustomerRoleId > 0 ? model.CustomerRoleId : (int?)null;
tierPrice.CustomerRoleId = model.CustomerRoleId > 0 ? model.CustomerRoleId : null;
await _productService.InsertTierPriceAsync(tierPrice);
@ -2795,7 +2796,7 @@ public partial class CustomProductController : BaseAdminController
{
//fill entity from model
tierPrice = model.ToEntity(tierPrice);
tierPrice.CustomerRoleId = model.CustomerRoleId > 0 ? model.CustomerRoleId : (int?)null;
tierPrice.CustomerRoleId = model.CustomerRoleId > 0 ? model.CustomerRoleId : null;
await _productService.UpdateTierPriceAsync(tierPrice);
ViewBag.RefreshPage = true;

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
namespace DevExtreme.NETCore.Demos.Controllers
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
{
public class FileManagerController : Controller
{

View File

@ -1,10 +1,8 @@
using DevExtreme.AspNet.Mvc.FileManagement;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
using System.Collections.Generic;
namespace DevExtreme.NETCore.Demos.Controllers
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
{
public class FileManagerScriptsApiController : Controller
{

View File

@ -1,12 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models;
using Nop.Plugin.Misc.FruitBankPlugin;
using Nop.Services.Configuration;
using Nop.Web.Framework.Controllers;
using Nop.Services.Messages;
using System.Threading.Tasks;
namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
{
[Area("Admin")]
public class FruitBankPluginAdminController : BasePluginController

View File

@ -5,8 +5,6 @@ using FruitBank.Common.Entities;
using Mango.Nop.Core.Loggers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Azure;
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models;
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.FruitBankPlugin.Services;

View File

@ -38,7 +38,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
[SignalR(SignalRTags.GetMeasuringModels)]
public async Task<List<MeasuringModel>> GetMeasuringModels()
public Task<List<MeasuringModel>> GetMeasuringModels()
{
throw new NotImplementedException("GetMeasuringModels");
}

View File

@ -1,14 +1,14 @@
using FruitBank.Common.Entities;
using Mango.Nop.Core.Loggers;
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 FilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : MgDbTableBase<Files>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public class FilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase<Files>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -16,7 +16,9 @@ using Nop.Plugin.Misc.FruitBankPlugin.Services;
using Nop.Services.Catalog;
using FruitBank.Common.Dtos;
using Mango.Nop.Core.Extensions;
using Mango.Nop.Core.Loggers;
using Nop.Core.Domain.Orders;
using WebMarkupMin.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
@ -67,7 +69,7 @@ public class FruitBankDbContext : MgDbContextBase,
IRepository<Customer> customerRepository,
IRepository<CustomerCustomerRoleMapping> customerCustomerRoleMappingRepository,
IRepository<CustomerRole> customerRoleRepository,
IEnumerable<IAcLogWriterBase> logWriters) : base(dataProvider, lockService, logWriters)
IEnumerable<IAcLogWriterBase> logWriters) : base(dataProvider, lockService, new Logger<FruitBankDbContext>(logWriters.ToArray()))
{
_storeContext = storeContext;
_productService = productService;
@ -177,6 +179,9 @@ public class FruitBankDbContext : MgDbContextBase,
{
try
{
//Logger.Warning($"UpdateShippingItemAsync");
//throw new Exception($"Teszt");
ProductDto? productDto = null;
var productIsMeasurable = false;
@ -313,6 +318,10 @@ public class FruitBankDbContext : MgDbContextBase,
if (!await SetupShippingItemPalletMeauringValues(shippingItemPallet)) return null;
await ShippingItemPallets.InsertAsync(shippingItemPallet);
var shippingItem = await ShippingItems.GetByIdAsync(shippingItemPallet.ShippingItemId, false);
await UpdateShippingItemAsync(shippingItem);
return shippingItemPallet;
}
@ -324,6 +333,10 @@ public class FruitBankDbContext : MgDbContextBase,
if (!await SetupShippingItemPalletMeauringValues(shippingItemPallet)) return null;
await ShippingItemPallets.UpdateAsync(shippingItemPallet);
var shippingItem = await ShippingItems.GetByIdAsync(shippingItemPallet.ShippingItemId, false);
await UpdateShippingItemAsync(shippingItem);
return shippingItemPallet;
}

View File

@ -5,11 +5,11 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class MeasuringItemPalletBaseDbTable<TEntity>(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : MgDbTableBase<TEntity>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) where TEntity
public class MeasuringItemPalletBaseDbTable<TEntity>(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase<TEntity>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) where TEntity
: MgEntityBase, IMeasuringItemPalletBase
{
protected override void OnUpdate(TEntity entity)

View File

@ -7,14 +7,14 @@ using Nop.Core.Configuration;
using Nop.Core.Domain.Orders;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class OrderDtoDbTable : MgDtoDbTableBase<OrderDto, Order>
{
public OrderDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public OrderDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -6,14 +6,14 @@ using Nop.Core.Configuration;
using Nop.Core.Domain.Orders;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class OrderItemDtoDbTable : MgDtoDbTableBase<OrderItemDto, OrderItem>
{
public OrderItemDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public OrderItemDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -4,14 +4,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class OrderItemPalletDbTable : MeasuringItemPalletBaseDbTable<OrderItemPallet>
{
public OrderItemPalletDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public OrderItemPalletDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -5,14 +5,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class PartnerDbTable : MgDbTableBase<Partner>
{
public PartnerDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public PartnerDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -6,14 +6,14 @@ using Nop.Core.Configuration;
using Nop.Core.Domain.Catalog;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class ProductDtoDbTable : MgDtoDbTableBase<ProductDto, Product>
{
public ProductDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public ProductDtoDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -5,14 +5,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
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)
public ShippingDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -5,14 +5,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class ShippingDocumentDbTable : MgDbTableBase<ShippingDocument>
{
public ShippingDocumentDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public ShippingDocumentDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -1,5 +1,5 @@
using FruitBank.Common.Entities;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
using Mango.Nop.Core.Repositories;
using Nop.Core.Caching;
using Nop.Core.Configuration;
@ -8,7 +8,7 @@ using Nop.Data;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class ShippingDocumentToFilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : MgDbTableBase<ShippingDocumentToFiles>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public class ShippingDocumentToFilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase<ShippingDocumentToFiles>(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -6,14 +6,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
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)
public ShippingItemDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -5,14 +5,14 @@ using Nop.Core.Caching;
using Nop.Core.Configuration;
using Nop.Core.Events;
using Nop.Data;
using Nop.Services.Logging;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
public class ShippingItemPalletDbTable : MeasuringItemPalletBaseDbTable<ShippingItemPallet>
{
public ShippingItemPalletDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger)
public ShippingItemPalletDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings)
: base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{
}

View File

@ -1,24 +1,14 @@
using System.Diagnostics.CodeAnalysis;
using AyCode.Core.Loggers;
using AyCode.Interfaces.Entities;
using FruitBank.Common.Dtos;
using AyCode.Core.Loggers;
using FruitBank.Common.Entities;
using FruitBank.Common.Interfaces;
using FruitBank.Common.Loggers;
using FruitBank.Common.Server;
using Humanizer;
using Mango.Nop.Core.Loggers;
using Mango.Nop.Services;
using Microsoft.AspNetCore.Http;
using Nop.Core;
using Nop.Core.Domain.Catalog;
using Nop.Core.Events;
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.FruitBankPlugin.Services;
using Nop.Services.Common;
using Nop.Services.Events;
using System.Globalization;
using Mango.Nop.Core.Extensions;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers;
@ -87,53 +77,62 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa
bool? isMeasurable = null;
var isMeasurableChanged = false;
var productDto = product.Id > 0 ? await ctx.ProductDtos.GetByIdAsync(product.Id, false) : null;
//IsMeasurable
isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
var productDtoIsMeasurable = productDto?.GenericAttributes.GetValueOrNull<bool>(nameof(IMeasurable.IsMeasurable));
if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value)
try
{
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, bool>(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value);
isMeasurableChanged = true;
var productDto = product.Id > 0 ? await ctx.ProductDtos.GetByIdAsync(product.Id, false) : null;
//IsMeasurable
isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
var productDtoIsMeasurable = productDto?.GenericAttributes.GetValueOrNull<bool>(nameof(IMeasurable.IsMeasurable));
if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value)
{
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, bool>(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value);
isMeasurableChanged = true;
}
//NetWeight
var netWeight = double.Round(CommonHelper.To<double>(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1);
var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull<double>(nameof(IMeasuringNetWeight.NetWeight));
if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight);
//Tára
var tare = double.Round(CommonHelper.To<double>(form[nameof(ITare.Tare)].ToString()), 1);
if (tare < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (tare < 0); productId: {product.Id}; tare: {tare}");
if (productDto == null || productDto.Tare != tare)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(ITare.Tare), tare);
//IncomingQuantity
var incomingQuantity = CommonHelper.To<int>(form[nameof(IIncomingQuantity.IncomingQuantity)].ToString());
if (incomingQuantity < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (incomingQuantity < 0); productId: {product.Id}; incomingQuantity: {incomingQuantity}");
if (productDto == null || productDto.IncomingQuantity != incomingQuantity)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(product.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity);
}
catch (Exception ex)
{
Logger.Error($"FruitBankEventConsumer->SaveProductCustomAttributesAsync; {ex.Message}", ex);
}
//NetWeight
var netWeight = double.Round(CommonHelper.To<double>(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1);
var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull<double>(nameof(IMeasuringNetWeight.NetWeight));
if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight);
//Tára
var tare = double.Round(CommonHelper.To<double>(form[nameof(ITare.Tare)].ToString()), 1);
if (tare < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (tare < 0); productId: {product.Id}; tare: {tare}");
if (productDto == null || productDto.Tare != tare)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(ITare.Tare), tare);
//IncomingQuantity
var incomingQuantity = CommonHelper.To<int>(form[nameof(IIncomingQuantity.IncomingQuantity)].ToString());
if (incomingQuantity < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (incomingQuantity < 0); productId: {product.Id}; incomingQuantity: {incomingQuantity}");
if (productDto == null || productDto.IncomingQuantity != incomingQuantity)
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(product.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity);
return (isMeasurableChanged, isMeasurable);
}
public async Task HandleEventAsync(EntityInsertedEvent<ShippingItemPallet> eventMessage)
{
Logger.Info($"HandleEventAsync EntityInsertedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
return;
Logger.Info($"HandleEventAsync EntityInsertedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity);
}
public async Task HandleEventAsync(EntityUpdatedEvent<ShippingItemPallet> eventMessage)
{
Logger.Info($"HandleEventAsync EntityUpdatedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
return;
Logger.Info($"HandleEventAsync EntityUpdatedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity);
}

View File

@ -2,13 +2,13 @@
using AyCode.Core.Loggers;
using DevExpress.AspNetCore;
using FruitBank.Common;
using FruitBank.Common.Interfaces;
using FruitBank.Common.Server.Interfaces;
using FruitBank.Common.Server.Services.Loggers;
using FruitBank.Common.Server.Services.SignalRs;
using Mango.Nop.Core.Loggers;
using Mango.Nop.Services;
using Mango.Nop.Services.Loggers;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.SignalR;
@ -16,6 +16,9 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Nop.Core.Domain.Orders;
using Nop.Core.Infrastructure;
using Nop.Data;
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
using Nop.Plugin.Misc.FruitBankPlugin.Filters;
@ -27,9 +30,6 @@ using Nop.Services.Events;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Areas.Admin.Models.Catalog;
using Nop.Web.Areas.Admin.Models.Orders;
using FruitBank.Common.Server.Interfaces;
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
@ -42,20 +42,20 @@ public class PluginNopStartup : INopStartup
/// <param name="configuration">Configuration of the application</param>
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
services.AddTransient<INopLoggerMsSqlNopDataProvider, NopLoggerMsSqlNopDataProvider>();
services.AddScoped<IAcLogWriterBase, NopLogWriter>();
services.AddSingleton<LoggerToLoggerApiController>();
//services.AddSingleton<SessionService>();
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
//register services and interfaces
services.AddSingleton<ILockService, LockService>();
services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
//services.AddScoped<IAcLogWriterBase, NopLogWriter>();
services.AddScoped<LoggerToLoggerApiController2>();
//services.AddSingleton<SessionService>();
services.AddScoped<FruitBankAttributeService>();
services.AddScoped<ProductDtoDbTable>();
@ -124,7 +124,7 @@ public class PluginNopStartup : INopStartup
{
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<LoggerSignalRHub2>(loggrHubEndPoint);
endpoints.MapHub<LoggerSignalRHub>(loggrHubEndPoint);
});
});
}

View File

@ -26,7 +26,7 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
<!--<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />-->
<PackageReference Include="PdfPig" Version="0.1.11" />
<PackageReference Include="PdfPig.Rendering.Skia" Version="0.1.11.5" />
<PackageReference Include="SendGrid" Version="9.29.3" />

View File

@ -21,7 +21,6 @@ public class CustomPriceCalculationService : PriceCalculationService
private readonly IProductAttributeService _productAttributeService;
private readonly ISpecificationAttributeService _specificationAttributeService;
private readonly ILocalizationService _localizationService;
private readonly IProductService _productService;
public CustomPriceCalculationService(
IRepository<Product> productRepository,
@ -34,7 +33,7 @@ public class CustomPriceCalculationService : PriceCalculationService
IProductAttributeParser productAttributeParser,
IProductAttributeService productAttributeService,
ISpecificationAttributeService specificationAttributeService,
IProductService productService,
IProductService productService,
ICustomerService customerService,
IDiscountService discountService,
IDiscountPluginManager discountPluginManager,
@ -43,45 +42,41 @@ public class CustomPriceCalculationService : PriceCalculationService
IWorkContext workContext,
ILogger logger)
: base(catalogSettings, currencySettings, categoryService, currencyService, customerService, discountService, manufacturerService,
productAttributeParser, productService,
cacheManager)
productAttributeParser, productService,
cacheManager)
{
_productRepository = productRepository;
// assign all base deps to local private vars if needed
_productAttributeService = productAttributeService;
_specificationAttributeService = specificationAttributeService;
_localizationService = localizationService;
_productService = productService;
}
//decimal? overriddenProductPrice = null
public override async Task<(decimal priceWithoutDiscounts, decimal finalPrice, decimal appliedDiscountAmount, List<Discount> appliedDiscounts)> GetFinalPriceAsync(
Product product, Customer customer, Store store, decimal? overriddenProductPrice, decimal additionalCharge = 0, bool includeDiscounts = true,
int quantity = 1, DateTime? rentalStartDate = null, DateTime? rentalEndDate = null)
Product product, Customer customer, Store store, decimal? overriddenProductPrice, decimal additionalCharge = 0, bool includeDiscounts = true,
int quantity = 1, DateTime? rentalStartDate = null, DateTime? rentalEndDate = null)
{
var productAttributeMappings = await _specificationAttributeService.GetProductSpecificationAttributesAsync(product.Id);
var productAttributeMappings = await _specificationAttributeService.GetProductSpecificationAttributesAsync(product.Id);
//Product Attributes
foreach (var pam in productAttributeMappings)
{
//get option
var attributeOtion = await _specificationAttributeService.GetSpecificationAttributeOptionByIdAsync(pam.SpecificationAttributeOptionId);
//get attribute
var attribute = await _specificationAttributeService.GetSpecificationAttributeByIdAsync(attributeOtion.SpecificationAttributeId);
// you can check for specific attribute by its name or id
if (attribute.Name == "Needs to be measured for price")
{
return (0m, 0m, 0m, new List<Discount>());
}
{
return (0m, 0m, 0m, []);
}
}
return await base.GetFinalPriceAsync(product, customer, store, overriddenProductPrice, additionalCharge, includeDiscounts, quantity, rentalStartDate, rentalEndDate);
}
}

View File

@ -37,7 +37,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
IGenericAttributeService genericAttributeService,
IProductService productService,
ISpecificationAttributeService specificationAttributeService,
IOrderService orderService,
IOrderService orderService,
IProductAttributeService productAttributeService,
IPluginManager<IPlugin> pluginManager,
IWorkContext workContext,
@ -146,7 +146,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
{
var isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
//var isMeasurable = CommonHelper.To<bool>(form[nameof(IMeasurable.IsMeasurable)].ToString());
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Order, bool>(order.Id, nameof(IMeasurable.IsMeasurable), isMeasurable);
}
@ -154,7 +154,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
if (form.ContainsKey(nameof(IOrderDto.DateOfReceipt)))
{
var dateOfReceipt = form[nameof(IOrderDto.DateOfReceipt)];
await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Order, DateTime>(order.Id, nameof(IOrderDto.DateOfReceipt), DateTime.Parse(dateOfReceipt));
}
@ -162,12 +162,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
public async Task HandleEventAsync(AdminMenuCreatedEvent eventMessage)
public override async Task HandleEventAsync(AdminMenuCreatedEvent eventMessage)
{
var rootNode = eventMessage.RootMenuItem;
var ShippingsListMenuItem = new AdminMenuItem
var shippingsListMenuItem = new AdminMenuItem
{
Visible = true,
SystemName = "FruitBank",
@ -196,18 +196,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
};
// Create a new top-level menu item
var ShippingsMenuItem = new AdminMenuItem
var shippingsMenuItem = new AdminMenuItem
{
Visible = true,
SystemName = "FruitBank",
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.Shippings"), // You can localize this with await _localizationService.GetResourceAsync("...")
IconClass = "fas fa-shipping-fast",
//Url = _adminMenu.GetMenuItemUrl("Shipping", "List")
ChildNodes = new[] { ShippingsListMenuItem, createShippingMenuItem, editShippingMenuItem }
ChildNodes = [shippingsListMenuItem, createShippingMenuItem, editShippingMenuItem]
};
var ShippingConfigurationItem = rootNode;
ShippingConfigurationItem.ChildNodes.Insert(2, ShippingsMenuItem);
var shippingConfigurationItem = rootNode;
shippingConfigurationItem.ChildNodes.Insert(2, shippingsMenuItem);
var invoiceListMenuItem = new AdminMenuItem
@ -227,7 +227,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.Invoices"), // You can localize this with await _localizationService.GetResourceAsync("...")
IconClass = "fas fa-file-invoice",
//Url = _adminMenu.GetMenuItemUrl("Shipping", "List")
ChildNodes = new[] { invoiceListMenuItem }
ChildNodes = [invoiceListMenuItem]
};
var invoiceConfigurationItem = rootNode;
@ -257,18 +257,18 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.AI"),
IconClass = "far fa-dot-circle",
ChildNodes = new List<AdminMenuItem>
{
new()
{
new()
{
Visible = true,
SystemName = "FruitBank",
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.Configure"),
IconClass = "far fa-circle",
Url = _adminMenu.GetMenuItemUrl("FruitBankPlugin", "Configure"),
Visible = true,
SystemName = "FruitBank",
Title = await _localizationService.GetResourceAsync("Plugins.Misc.FruitBankPlugin.Menu.Configure"),
IconClass = "far fa-circle",
Url = _adminMenu.GetMenuItemUrl("FruitBankPlugin", "Configure"),
}
}
}
});
}

View File

@ -1,8 +0,0 @@
using AyCode.Services.Server.SignalRs;
using FruitBank.Common.Server.Services.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
public class LoggerSignalRHub2(LoggerToLoggerApiController2 logger) : AcLoggerSignalRHub<LoggerToLoggerApiController2>(logger)
{ }

View File

@ -1,8 +0,0 @@
using AyCode.Core.Enums;
using AyCode.Core.Loggers;
using FruitBank.Common.Loggers;
using Mango.Nop.Core.Loggers;
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
public class LoggerToLoggerApiController2(IAcLogWriterBase[] logWriters) : Logger<LoggerToLoggerApiController2>(logWriters);