diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomProductController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomProductController.cs index b98e41f..787844d 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomProductController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/CustomProductController.cs @@ -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.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; diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerController.cs index 4b15dc7..acd05af 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerController.cs @@ -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 { diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerScriptsApiController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerScriptsApiController.cs index bf40f0f..c2e18ed 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerScriptsApiController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FileManagerScriptsApiController.cs @@ -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 { diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FruitBankPluginAdminController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FruitBankPluginAdminController.cs index 8853f57..991b046 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FruitBankPluginAdminController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/FruitBankPluginAdminController.cs @@ -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 diff --git a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/ManagementPageController.cs b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/ManagementPageController.cs index 2376ed1..e8f6759 100644 --- a/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/ManagementPageController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Areas/Admin/Controllers/ManagementPageController.cs @@ -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; diff --git a/Nop.Plugin.Misc.AIPlugin/Controllers/FruitBankDataController.cs b/Nop.Plugin.Misc.AIPlugin/Controllers/FruitBankDataController.cs index 4a32beb..d7f16e7 100644 --- a/Nop.Plugin.Misc.AIPlugin/Controllers/FruitBankDataController.cs +++ b/Nop.Plugin.Misc.AIPlugin/Controllers/FruitBankDataController.cs @@ -38,7 +38,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers [SignalR(SignalRTags.GetMeasuringModels)] - public async Task> GetMeasuringModels() + public Task> GetMeasuringModels() { throw new NotImplementedException("GetMeasuringModels"); } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FilesDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FilesDbTable.cs index 3e15761..c840cf7 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FilesDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FilesDbTable.cs @@ -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(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) +public class FilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) { } \ No newline at end of file diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FruitBankDbContext.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FruitBankDbContext.cs index eb58570..5c6c0ab 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FruitBankDbContext.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/FruitBankDbContext.cs @@ -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 customerRepository, IRepository customerCustomerRoleMappingRepository, IRepository customerRoleRepository, - IEnumerable logWriters) : base(dataProvider, lockService, logWriters) + IEnumerable logWriters) : base(dataProvider, lockService, new Logger(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; } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/MeasuringItemPalletBaseDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/MeasuringItemPalletBaseDbTable.cs index 0b78fc1..e62a6af 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/MeasuringItemPalletBaseDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/MeasuringItemPalletBaseDbTable.cs @@ -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(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings, ILogger logger) : MgDbTableBase(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) where TEntity +public class MeasuringItemPalletBaseDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) where TEntity : MgEntityBase, IMeasuringItemPalletBase { protected override void OnUpdate(TEntity entity) diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs index 359a5c4..e930071 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderDtoDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemDtoDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemDtoDbTable.cs index d3f8aca..47aafd2 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemDtoDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemDtoDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemPalletDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemPalletDbTable.cs index 7fe9b37..783c415 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemPalletDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/OrderItemPalletDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/PartnerDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/PartnerDbTable.cs index bede242..b2823c9 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/PartnerDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/PartnerDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ProductDtoDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ProductDtoDbTable.cs index a48afe3..c38b1f8 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ProductDtoDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ProductDtoDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDbTable.cs index f25eb69..6335057 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentDbTable.cs index 0db565c..1cee391 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentToFilesDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentToFilesDbTable.cs index bd6e71c..c6a2b98 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentToFilesDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingDocumentToFilesDbTable.cs @@ -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(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings, logger) +public class ShippingDocumentToFilesDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : MgDbTableBase(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) { } \ No newline at end of file diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemDbTable.cs index 93943d5..4ed6ab0 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemPalletDbTable.cs b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemPalletDbTable.cs index 3499db4..00f668a 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemPalletDbTable.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/DataLayer/ShippingItemPalletDbTable.cs @@ -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 { - 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) { } diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs b/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs index 72f714f..3f323f8 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs @@ -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(nameof(IMeasurable.IsMeasurable)); - - if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value) + try { - await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(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(nameof(IMeasurable.IsMeasurable)); + + if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value) + { + await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value); + isMeasurableChanged = true; + } + + //NetWeight + var netWeight = double.Round(CommonHelper.To(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1); + var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull(nameof(IMeasuringNetWeight.NetWeight)); + + if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight) + await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight); + + //Tára + var tare = double.Round(CommonHelper.To(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.Id, nameof(ITare.Tare), tare); + + //IncomingQuantity + var incomingQuantity = CommonHelper.To(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.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity); + } + catch (Exception ex) + { + Logger.Error($"FruitBankEventConsumer->SaveProductCustomAttributesAsync; {ex.Message}", ex); } - - //NetWeight - var netWeight = double.Round(CommonHelper.To(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1); - var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull(nameof(IMeasuringNetWeight.NetWeight)); - - if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight) - await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight); - - //Tára - var tare = double.Round(CommonHelper.To(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.Id, nameof(ITare.Tare), tare); - - //IncomingQuantity - var incomingQuantity = CommonHelper.To(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.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity); return (isMeasurableChanged, isMeasurable); } public async Task HandleEventAsync(EntityInsertedEvent eventMessage) { - Logger.Info($"HandleEventAsync EntityInsertedEvent; id: {eventMessage.Entity.Id}"); + return; + Logger.Info($"HandleEventAsync EntityInsertedEvent; id: {eventMessage.Entity.Id}"); await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity); } public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { - Logger.Info($"HandleEventAsync EntityUpdatedEvent; id: {eventMessage.Entity.Id}"); + return; + Logger.Info($"HandleEventAsync EntityUpdatedEvent; id: {eventMessage.Entity.Id}"); await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity); } diff --git a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs index 3082552..46ac4ec 100644 --- a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs @@ -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 /// Configuration of the application public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { + services.AddScoped(); + + services.AddTransient(); + services.AddScoped(); + + services.AddSingleton(); + //services.AddSingleton(); + services.Configure(options => { options.ViewLocationExpanders.Add(new ViewLocationExpander()); }); - //register services and interfaces - services.AddSingleton(); - - services.AddScoped(); - //services.AddScoped(); - services.AddScoped(); - //services.AddSingleton(); - services.AddScoped(); services.AddScoped(); @@ -124,7 +124,7 @@ public class PluginNopStartup : INopStartup { app.UseEndpoints(endpoints => { - endpoints.MapHub(loggrHubEndPoint); + endpoints.MapHub(loggrHubEndPoint); }); }); } diff --git a/Nop.Plugin.Misc.AIPlugin/Nop.Plugin.Misc.FruitBankPlugin.csproj b/Nop.Plugin.Misc.AIPlugin/Nop.Plugin.Misc.FruitBankPlugin.csproj index 0283609..026afda 100644 --- a/Nop.Plugin.Misc.AIPlugin/Nop.Plugin.Misc.FruitBankPlugin.csproj +++ b/Nop.Plugin.Misc.AIPlugin/Nop.Plugin.Misc.FruitBankPlugin.csproj @@ -26,7 +26,7 @@ - + diff --git a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs index 55d55ec..7f12a25 100644 --- a/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs +++ b/Nop.Plugin.Misc.AIPlugin/Services/CustomPriceCalculationService.cs @@ -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 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 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()); - } - + { + return (0m, 0m, 0m, []); + } } return await base.GetFinalPriceAsync(product, customer, store, overriddenProductPrice, additionalCharge, includeDiscounts, quantity, rentalStartDate, rentalEndDate); } - - } diff --git a/Nop.Plugin.Misc.AIPlugin/Services/EventConsumer.cs b/Nop.Plugin.Misc.AIPlugin/Services/EventConsumer.cs index 67d5201..df37c03 100644 --- a/Nop.Plugin.Misc.AIPlugin/Services/EventConsumer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Services/EventConsumer.cs @@ -37,7 +37,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Services IGenericAttributeService genericAttributeService, IProductService productService, ISpecificationAttributeService specificationAttributeService, - IOrderService orderService, + IOrderService orderService, IProductAttributeService productAttributeService, IPluginManager 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(form[nameof(IMeasurable.IsMeasurable)].ToString()); - + await _fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(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.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 - { - 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"), + } } - } }); } diff --git a/Nop.Plugin.Misc.AIPlugin/Services/LoggerSignalRHub.cs b/Nop.Plugin.Misc.AIPlugin/Services/LoggerSignalRHub.cs deleted file mode 100644 index 18ad102..0000000 --- a/Nop.Plugin.Misc.AIPlugin/Services/LoggerSignalRHub.cs +++ /dev/null @@ -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(logger) -{ } \ No newline at end of file diff --git a/Nop.Plugin.Misc.AIPlugin/Services/LoggerToLoggerApiController2.cs b/Nop.Plugin.Misc.AIPlugin/Services/LoggerToLoggerApiController2.cs deleted file mode 100644 index e088b1d..0000000 --- a/Nop.Plugin.Misc.AIPlugin/Services/LoggerToLoggerApiController2.cs +++ /dev/null @@ -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(logWriters); \ No newline at end of file