refactoring, cleanup v1.1...
This commit is contained in:
parent
3719994ec4
commit
c63516e774
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue