Compare commits
No commits in common. "ca1f59a5e142fede2afa6031f0bcdaf3a4819895" and "76f0994d9fcb698632083bc63c1f97a0344fce54" have entirely different histories.
ca1f59a5e1
...
76f0994d9f
|
|
@ -1,65 +1,29 @@
|
|||
using AyCode.Services.SignalRs;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Server.Interfaces;
|
||||
using FruitBank.Common.SignalRs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nop.Services.Orders;
|
||||
using Nop.Services.Security;
|
||||
using Nop.Web.Areas.Admin.Controllers;
|
||||
using Nop.Web.Areas.Admin.Factories;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
using Nop.Web.Framework;
|
||||
using Nop.Web.Framework.Mvc.Filters;
|
||||
using Nop.Web.Framework;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
using Nop.Services.Security;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
||||
using Nop.Web.Areas.Admin.Factories;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||
{
|
||||
public class CustomOrderSignalREndpoint(IOrderService orderService, IOrderModelFactory orderModelFactory) : ICustomOrderSignalREndpointServer
|
||||
{
|
||||
private readonly IOrderService _orderService = orderService;
|
||||
private readonly CustomOrderModelFactory _orderModelFactory = orderModelFactory as CustomOrderModelFactory;
|
||||
|
||||
public async Task<OrderListModelExtended> GetOrderModelsByFilter(OrderSearchModel searchModel)
|
||||
{
|
||||
var orderListModel = await _orderModelFactory.PrepareOrderListModelExtendedAsync(searchModel);
|
||||
|
||||
Console.WriteLine($"Total: {orderListModel.RecordsTotal}, Data Count: {orderListModel.Data.Count()}");
|
||||
foreach (var item in orderListModel.Data.Take(3))
|
||||
{
|
||||
Console.WriteLine($"Order: {item.Id}, {item.CustomOrderNumber}");
|
||||
}
|
||||
|
||||
return orderListModel;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPendingOrderModels)]
|
||||
public async Task<OrderListModelExtended> GetPendingOrderModels()
|
||||
{
|
||||
var orderSearchModel = new OrderSearchModel
|
||||
{
|
||||
OrderStatusIds = new List<int> { 1 }
|
||||
};
|
||||
|
||||
return await GetOrderModelsByFilter(orderSearchModel);
|
||||
}
|
||||
}
|
||||
|
||||
[Area(AreaNames.ADMIN)]
|
||||
[AuthorizeAdmin]
|
||||
public class CustomOrderController : BaseAdminController, ICustomOrderSignalREndpointServer
|
||||
public class CustomOrderController : BaseAdminController
|
||||
{
|
||||
private readonly IOrderService _orderService;
|
||||
private readonly CustomOrderModelFactory _orderModelFactory;
|
||||
private readonly ICustomOrderSignalREndpointServer _customOrderSignalREndpoint;
|
||||
private readonly IOrderModelFactory _orderModelFactory;
|
||||
private readonly IPermissionService _permissionService;
|
||||
// ... other dependencies
|
||||
|
||||
public CustomOrderController(IOrderService orderService, IOrderModelFactory orderModelFactory, ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IPermissionService permissionService)
|
||||
public CustomOrderController(IOrderService orderService, IOrderModelFactory orderModelFactory, IPermissionService permissionService)
|
||||
{
|
||||
_orderService = orderService;
|
||||
_orderModelFactory = orderModelFactory as CustomOrderModelFactory;
|
||||
_customOrderSignalREndpoint = customOrderSignalREndpoint;
|
||||
_orderModelFactory = orderModelFactory;
|
||||
_permissionService = permissionService;
|
||||
// ... initialize other deps
|
||||
}
|
||||
|
|
@ -80,40 +44,21 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
|
||||
[HttpPost]
|
||||
[CheckPermission(StandardPermission.Orders.ORDERS_VIEW)]
|
||||
public async Task<IActionResult> OrderList(OrderSearchModel searchModel)
|
||||
public virtual async Task<IActionResult> OrderList(OrderSearchModel searchModel)
|
||||
{
|
||||
//prepare model
|
||||
var orderListModel = await GetOrderModelsByFilter(searchModel);
|
||||
|
||||
var valami = Json(orderListModel);
|
||||
Console.WriteLine(valami);
|
||||
return valami;
|
||||
}
|
||||
var model = await _orderModelFactory.PrepareOrderListModelAsync(searchModel);
|
||||
|
||||
public async Task<OrderListModelExtended> GetOrderModelsByFilter(OrderSearchModel searchModel)
|
||||
{
|
||||
//return _customOrderService.
|
||||
var orderListModel = await _orderModelFactory.PrepareOrderListModelExtendedAsync(searchModel);
|
||||
|
||||
Console.WriteLine($"Total: {orderListModel.RecordsTotal}, Data Count: {orderListModel.Data.Count()}");
|
||||
foreach (var item in orderListModel.Data.Take(3))
|
||||
|
||||
Console.WriteLine($"Total: {model.RecordsTotal}, Data Count: {model.Data.Count()}");
|
||||
foreach (var item in model.Data.Take(3))
|
||||
{
|
||||
Console.WriteLine($"Order: {item.Id}, {item.CustomOrderNumber}");
|
||||
}
|
||||
|
||||
return orderListModel;
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetPendingOrderModels)]
|
||||
public async Task<OrderListModelExtended> GetPendingOrderModels()
|
||||
{
|
||||
var orderSearchModel = new OrderSearchModel
|
||||
{
|
||||
OrderStatusIds = new List<int> { 1 }
|
||||
};
|
||||
|
||||
return await GetOrderModelsByFilter(orderSearchModel);
|
||||
}
|
||||
var valami = Json(model);
|
||||
Console.WriteLine(valami);
|
||||
return valami;
|
||||
}
|
||||
|
||||
public virtual IActionResult Test()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Common;
|
||||
using Nop.Web.Areas.Admin.Models.Catalog;
|
||||
using Nop.Web.Framework.Components;
|
||||
|
|
@ -15,34 +14,60 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
|
|||
[ViewComponent(Name = "ProductAttributes")]
|
||||
public class ProductAttributesViewComponent : NopViewComponent
|
||||
{
|
||||
private readonly FruitBankAttributeService _fruitBankAttributeService;
|
||||
private const string NET_WEIGHT_KEY = nameof(IMeasuringAttributeValues.NetWeight);
|
||||
private const string TARE_KEY = nameof(ITare.Tare);
|
||||
private const string IS_MEASURABLE_KEY = nameof(IMeasuringAttributeValues.IsMeasurable);
|
||||
|
||||
private readonly IGenericAttributeService _genericAttributeService;
|
||||
private readonly IWorkContext _workContext;
|
||||
private readonly IStoreContext _storeContext;
|
||||
|
||||
public ProductAttributesViewComponent(FruitBankAttributeService fruitBankAttributeService, IWorkContext workContext, IStoreContext storeContext)
|
||||
public ProductAttributesViewComponent(
|
||||
IGenericAttributeService genericAttributeService,
|
||||
IWorkContext workContext,
|
||||
IStoreContext storeContext)
|
||||
{
|
||||
_genericAttributeService = genericAttributeService;
|
||||
_workContext = workContext;
|
||||
_storeContext = storeContext;
|
||||
_fruitBankAttributeService = fruitBankAttributeService;
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||
{
|
||||
if (additionalData is not ProductModel productModel) return Content("");
|
||||
|
||||
var model = new ProductAttributesModel { ProductId = productModel.Id };
|
||||
|
||||
if (model.ProductId > 0)
|
||||
if (additionalData is not ProductModel product)
|
||||
return Content("");
|
||||
|
||||
var model = new ProductAttributesModel
|
||||
{
|
||||
var measuringAttributeValues = await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync<Product>(model.ProductId);
|
||||
if (measuringAttributeValues != null)
|
||||
{
|
||||
model.IsMeasurable = measuringAttributeValues.IsMeasurable;
|
||||
model.NetWeight = measuringAttributeValues.NetWeight;
|
||||
}
|
||||
ProductId = product.Id
|
||||
};
|
||||
|
||||
model.Tare = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Product, double>(model.ProductId, nameof(ITare.Tare));
|
||||
model.IncomingQuantity = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Product, int>(model.ProductId, "IncomingQuantity");
|
||||
//get store scope
|
||||
var storeScope = await _storeContext.GetCurrentStoreAsync();
|
||||
|
||||
|
||||
if (product.Id > 0)
|
||||
{
|
||||
// Load existing values
|
||||
var dbProduct = new Core.Domain.Catalog.Product { Id = product.Id };
|
||||
|
||||
//var dbMesaurable = await _genericAttributeService.GetAttributeAsync<bool>(dbProduct, IS_MEASURABLE_KEY, storeScope.Id);
|
||||
//var dbNetWeight = await _genericAttributeService.GetAttributeAsync<decimal?>(dbProduct, NET_WEIGHT_KEY, storeScope.Id);
|
||||
//var dbIncomingQuantity = await _genericAttributeService.GetAttributeAsync<decimal?>(dbProduct, "IncomingQuantity", storeScope.Id);
|
||||
|
||||
model.IsMeasurable = await _genericAttributeService
|
||||
.GetAttributeAsync<bool>(dbProduct, IS_MEASURABLE_KEY, storeScope.Id);
|
||||
|
||||
model.NetWeight = await _genericAttributeService
|
||||
.GetAttributeAsync<double>(dbProduct, NET_WEIGHT_KEY, storeScope.Id);
|
||||
|
||||
model.IncomingQuantity = await _genericAttributeService
|
||||
.GetAttributeAsync<int?>(dbProduct, "IncomingQuantity", storeScope.Id);
|
||||
|
||||
model.Tare = await _genericAttributeService
|
||||
.GetAttributeAsync<double>(dbProduct, TARE_KEY, storeScope.Id);
|
||||
}
|
||||
|
||||
return View("~/Plugins/Misc.FruitBankPlugin/Views/ProductAttributes.cshtml", model);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ using FruitBank.Common.Interfaces;
|
|||
using FruitBank.Common.Loggers;
|
||||
using FruitBank.Common.Models;
|
||||
using FruitBank.Common.Server;
|
||||
using FruitBank.Common.Server.Interfaces;
|
||||
using FruitBank.Common.SignalRs;
|
||||
using LinqToDB;
|
||||
using Mango.Nop.Core.Dtos;
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ using System.Globalization;
|
|||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers;
|
||||
|
||||
public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBankDbContext ctx, FruitBankAttributeService fruitBankAttributeService, IEnumerable<IAcLogWriterBase> logWriters) :
|
||||
MgEventConsumer(httpContextAcc, logWriters),
|
||||
public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, FruitBankDbContext ctx, FruitBankAttributeService fruitBankAttributeService, IStoreContext storeContext, IEnumerable<IAcLogWriterBase> logWriters, IGenericAttributeService genericAttributeService) :
|
||||
MgEventConsumer(httpContextAccessor, logWriters),
|
||||
IConsumer<EntityDeletedEvent<Shipping>>,
|
||||
IConsumer<EntityInsertedEvent<ShippingItem>>,
|
||||
IConsumer<EntityUpdatedEvent<ShippingItem>>,
|
||||
|
|
@ -36,7 +36,7 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa
|
|||
{
|
||||
var product = eventMessage.Entity;
|
||||
|
||||
await SaveProductCustomAttributesAsync(eventMessage.Entity);
|
||||
await SaveCustomAttributesAsync(eventMessage.Entity);
|
||||
|
||||
var isMeasurableProduct = await fruitBankAttributeService.IsMeasurableEntityAsync<Product>(product.Id);
|
||||
|
||||
|
|
@ -51,42 +51,61 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa
|
|||
await base.HandleEventAsync(eventMessage);
|
||||
}
|
||||
|
||||
public override async Task HandleEventAsync(EntityInsertedEvent<Product> eventMessage)
|
||||
public async Task HandleEventAsync(EntityInsertedEvent<Product> eventMessage)
|
||||
{
|
||||
await SaveProductCustomAttributesAsync(eventMessage.Entity);
|
||||
await base.HandleEventAsync(eventMessage);
|
||||
await SaveCustomAttributesAsync(eventMessage.Entity);
|
||||
}
|
||||
|
||||
private async Task SaveProductCustomAttributesAsync(Product product)
|
||||
private async Task SaveCustomAttributesAsync(Product product)
|
||||
{
|
||||
if (product == null) return;
|
||||
if (product == null)
|
||||
return;
|
||||
|
||||
var form = HttpContextAccessor.HttpContext?.Request?.Form;
|
||||
if (form == null || form.Count == 0) return;
|
||||
var form = httpContextAccessor.HttpContext?.Request?.Form;
|
||||
if (form == null || !form.Any())
|
||||
return;
|
||||
|
||||
if (form.ContainsKey(nameof(IMeasurable.IsMeasurable)) && form.ContainsKey(nameof(IMeasuringNetWeight.NetWeight)))
|
||||
var store = await storeContext.GetCurrentStoreAsync();
|
||||
|
||||
// Save IsMeasurable
|
||||
if (form.ContainsKey(nameof(IMeasuringAttributeValues.IsMeasurable)))
|
||||
{
|
||||
var isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
|
||||
//var isMeasurable = CommonHelper.To<bool>(form[nameof(IMeasurable.IsMeasurable)].ToString());
|
||||
var netWeight = CommonHelper.To<double>(form[nameof(IMeasuringNetWeight.NetWeight)].ToString());
|
||||
var isMeasurable = form[nameof(IMeasuringAttributeValues.IsMeasurable)].ToString().Contains("true");
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(IMeasuringAttributeValues.IsMeasurable), isMeasurable, store.Id);
|
||||
//Akkor ez kell? - Á.
|
||||
//await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, 0, 0, isMeasurable, false);
|
||||
}
|
||||
|
||||
await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, netWeight, 0, isMeasurable, false);
|
||||
// Save NetWeight
|
||||
if (form.ContainsKey(nameof(IMeasuringAttributeValues.NetWeight)))
|
||||
{
|
||||
var netWeightStr = form[nameof(IMeasuringAttributeValues.NetWeight)].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(netWeightStr) && double.TryParse(netWeightStr, NumberStyles.Float, CultureInfo.InvariantCulture, out var netWeight))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(IMeasuringAttributeValues.NetWeight), netWeight, store.Id);
|
||||
//Akkor ez kell? - Á.
|
||||
//await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, 0, 0, , false);
|
||||
}
|
||||
}
|
||||
|
||||
// Save IncomingQuantity
|
||||
if (form.ContainsKey("IncomingQuantity"))
|
||||
{
|
||||
var incomingQtyStr = form["IncomingQuantity"].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(incomingQtyStr) && int.TryParse(incomingQtyStr, out var incomingQuantity))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, "IncomingQuantity", incomingQuantity, store.Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (form.ContainsKey(nameof(ITare.Tare)))
|
||||
{
|
||||
var tare = CommonHelper.To<double>(form[nameof(ITare.Tare)].ToString());
|
||||
if (tare < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (tare < 0); productId: {product.Id}; tare: {tare}");
|
||||
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(ITare.Tare), tare);
|
||||
}
|
||||
|
||||
if (form.ContainsKey("IncomingQuantity"))
|
||||
{
|
||||
var incomingQuantity = CommonHelper.To<int>(form["IncomingQuantity"].ToString());
|
||||
if (incomingQuantity < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (incomingQuantity < 0); productId: {product.Id}; incomingQuantity: {incomingQuantity}");
|
||||
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(product.Id, "IncomingQuantity", incomingQuantity);
|
||||
var tareStr = form[nameof(ITare.Tare)].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(tareStr) &&
|
||||
double.TryParse(tareStr, NumberStyles.Float, CultureInfo.InvariantCulture, out var tare))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(ITare.Tare), tare, store.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
using AyCode.Core.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Domain.Common;
|
||||
using Nop.Core.Domain.Directory;
|
||||
using Nop.Core.Domain.Orders;
|
||||
using Nop.Core.Domain.Shipping;
|
||||
using Nop.Core.Domain.Tax;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Helpers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
using Nop.Core;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Affiliates;
|
||||
using Nop.Services.Catalog;
|
||||
|
|
@ -32,7 +28,10 @@ using Nop.Services.Tax;
|
|||
using Nop.Services.Vendors;
|
||||
using Nop.Web.Areas.Admin.Factories;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
using System.Reflection;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc.TagHelpers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
|
||||
{
|
||||
|
|
@ -167,31 +166,32 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
|
|||
}
|
||||
|
||||
public override async Task<OrderListModel> PrepareOrderListModelAsync(OrderSearchModel searchModel)
|
||||
=>await base.PrepareOrderListModelAsync(searchModel);
|
||||
|
||||
public async Task<OrderListModelExtended> PrepareOrderListModelExtendedAsync(OrderSearchModel searchModel)
|
||||
{
|
||||
var orderListModel = await PrepareOrderListModelAsync(searchModel);
|
||||
|
||||
var orderListModelExtended = new OrderListModelExtended();
|
||||
var extendedRows = new List<OrderModelExtended>(orderListModel.RecordsFiltered);
|
||||
// get the default model first
|
||||
var baseModel = await base.PrepareOrderListModelAsync(searchModel);
|
||||
|
||||
//TODO: Megnézni miért száll el az IEnumerable!!! - J.
|
||||
//PropertyHelper.CopyPublicProperties(orderListModel, orderListModelExtended);
|
||||
var extendedRows = new List<OrderModelExtended>();
|
||||
|
||||
foreach (var orderModel in orderListModel.Data)
|
||||
foreach (var order in baseModel.Data)
|
||||
{
|
||||
var orderModelExtended = new OrderModelExtended();
|
||||
PropertyHelper.CopyPublicProperties(orderModel, orderModelExtended);
|
||||
|
||||
orderModelExtended.IsMeasurable = await ShouldMarkAsNeedsMeasurementAsync(orderModel);
|
||||
|
||||
Console.WriteLine(orderModelExtended.Id);
|
||||
extendedRows.Add(orderModelExtended);
|
||||
var extendedOrder = new OrderModelExtended();
|
||||
CopyModelHelper.CopyPublicProperties(order, extendedOrder);
|
||||
extendedOrder.IsMeasurable = await ShouldMarkAsNeedsMeasurementAsync(order);
|
||||
Console.WriteLine(extendedOrder.Id);
|
||||
extendedRows.Add(extendedOrder);
|
||||
}
|
||||
|
||||
orderListModelExtended.Data = extendedRows; // Different cast approach
|
||||
return orderListModelExtended;
|
||||
|
||||
//var model = new OrderListModel
|
||||
//{
|
||||
// Data = extendedRows.Cast<OrderModel>().ToList(),
|
||||
// RecordsTotal = baseModel.RecordsTotal
|
||||
//};
|
||||
|
||||
var model = new OrderListModel();
|
||||
CopyModelHelper.CopyPublicProperties(baseModel, model);
|
||||
model.Data = extendedRows.ToList<OrderModel>(); // Different cast approach
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
// example async custom logic
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Helpers
|
||||
{
|
||||
public static class CopyModelHelper
|
||||
{
|
||||
public static void CopyPublicProperties<TSource, TDestination>(TSource src, TDestination dest)
|
||||
{
|
||||
if (src == null || dest == null) return;
|
||||
|
||||
var srcProps = typeof(TSource)
|
||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.Where(p => p.CanRead);
|
||||
|
||||
foreach (var sp in srcProps)
|
||||
{
|
||||
var dp = typeof(TDestination).GetProperty(sp.Name, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (dp == null || !dp.CanWrite) continue;
|
||||
dp.SetValue(dest, sp.GetValue(src));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,9 +27,7 @@ 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;
|
||||
using FruitBankDataController = Nop.Plugin.Misc.FruitBankPlugin.Controllers.FruitBankDataController;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
|
||||
|
||||
|
|
@ -68,19 +66,16 @@ public class PluginNopStartup : INopStartup
|
|||
|
||||
services.AddScoped<FruitBankDbContext>();
|
||||
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
|
||||
services.AddScoped<ICustomOrderSignalREndpointServer, CustomOrderSignalREndpoint>();
|
||||
|
||||
|
||||
//services.AddScoped<CustomModelFactory, ICustomerModelFactory>();
|
||||
services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
|
||||
services.AddScoped<PriceCalculationService, CustomPriceCalculationService>();
|
||||
services.AddScoped<IConsumer<OrderPlacedEvent>, EventConsumer>();
|
||||
services.AddScoped<IOrderMeasurementService, OrderMeasurementService>();
|
||||
services.AddScoped<PendingMeasurementCheckoutFilter>();
|
||||
|
||||
//services.AddScoped<OrderListModel, OrderListModelExtended>();
|
||||
//services.AddScoped<OrderModel, OrderModelExtended>();
|
||||
//services.AddScoped<OrderSearchModel, OrderSearchModelExtended>();
|
||||
|
||||
services.AddScoped<OrderListModel, OrderListModelExtended>();
|
||||
services.AddScoped<OrderModel, OrderModelExtended>();
|
||||
services.AddScoped<OrderSearchModel, OrderSearchModelExtended>();
|
||||
services.AddScoped<IOrderModelFactory, CustomOrderModelFactory>();
|
||||
services.AddScoped<IGenericAttributeService, GenericAttributeService>();
|
||||
services.AddScoped<CerebrasAPIService>();
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using Nop.Web.Framework.Models;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models;
|
||||
|
||||
public interface IOrderListModelExtended<T>: IPagedModel<T> where T : BaseNopModel
|
||||
{
|
||||
public bool? NeedsMeasurement { get; set; }
|
||||
}
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
using Nop.Web.Framework.Models;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models
|
||||
{
|
||||
public partial record OrderListModelExtended : BasePagedListModel<OrderModelExtended>, IOrderListModelExtended<OrderModelExtended>
|
||||
public partial record OrderListModelExtended : OrderListModel
|
||||
{
|
||||
public bool? NeedsMeasurement { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,6 @@ public class FruitBankAttributeService(IGenericAttributeService genericAttribute
|
|||
return (await genericAttributeService.GetAttributesForEntityAsync(entityId, typeof(TEntity).Name)).SingleOrDefault(ga => ga.StoreId == storeId && ga.Key == key);
|
||||
}
|
||||
|
||||
public Task<TPropType?> GetGenericAttributeValueAsync<TEntity, TPropType>(int entityId, string key)
|
||||
=> GetGenericAttributeValueAsync<TEntity, TPropType>(entityId, key, storeContext.GetCurrentStore().Id);
|
||||
|
||||
public async Task<TPropType?> GetGenericAttributeValueAsync<TEntity, TPropType>(int entityId, string key, int storeId)
|
||||
{
|
||||
var ga = await GetGenericAttributeAsync<TEntity>(entityId, key, storeId);
|
||||
return ga == null ? default : CommonHelper.To<TPropType>(ga.Value);
|
||||
}
|
||||
|
||||
public async Task<List<GenericAttribute>?> GetMeasuringAttributesAsync<TEntity>(int entityId, int storeId)
|
||||
{
|
||||
var measuringAttributes = (await genericAttributeService.GetAttributesForEntityAsync(entityId, typeof(TEntity).Name))
|
||||
|
|
@ -130,20 +121,6 @@ public class FruitBankAttributeService(IGenericAttributeService genericAttribute
|
|||
}
|
||||
}
|
||||
|
||||
public Task InsertOrUpdateGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType value)
|
||||
=> InsertOrUpdateGenericAttributeAsync<TEntity, TPropType>(entityId, key, value, storeContext.GetCurrentStore().Id);
|
||||
|
||||
public async Task InsertOrUpdateGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType value, int storeId)
|
||||
{
|
||||
var ga = await GetGenericAttributeAsync<TEntity>(entityId, key, storeId);
|
||||
|
||||
if (ga == null) await InsertGenericAttributeAsync<TEntity, TPropType>(entityId, key, value, storeId);
|
||||
else await UpdateGenericAttributeAsync(ga, value);
|
||||
}
|
||||
|
||||
public Task InsertGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType value)
|
||||
=> InsertGenericAttributeAsync<TEntity, TPropType>(entityId, key, value, storeContext.GetCurrentStore().Id);
|
||||
|
||||
public async Task InsertGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType value, int storeId)
|
||||
{
|
||||
var genericAttribute = new GenericAttribute
|
||||
|
|
@ -158,9 +135,6 @@ public class FruitBankAttributeService(IGenericAttributeService genericAttribute
|
|||
await genericAttributeService.InsertAttributeAsync(genericAttribute);
|
||||
}
|
||||
|
||||
public Task UpdateGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType value)
|
||||
=> UpdateGenericAttributeAsync<TEntity, TPropType>(entityId, key, value, storeContext.GetCurrentStore().Id);
|
||||
|
||||
public async Task UpdateGenericAttributeAsync<TEntity, TPropType>(int entityId, string key, TPropType newValue, int storeId)
|
||||
{
|
||||
var ga = await GetGenericAttributeAsync<TEntity>(entityId, key, storeId);
|
||||
|
|
@ -173,9 +147,6 @@ public class FruitBankAttributeService(IGenericAttributeService genericAttribute
|
|||
await genericAttributeService.UpdateAttributeAsync(genericAttribute);
|
||||
}
|
||||
|
||||
public Task DeleteGenericAttributeAsync<TEntity>(int entityId, string key)
|
||||
=> DeleteGenericAttributeAsync<TEntity>(entityId, key, storeContext.GetCurrentStore().Id);
|
||||
|
||||
public async Task DeleteGenericAttributeAsync<TEntity>(int entityId, string key, int storeId)
|
||||
{
|
||||
var ga = await GetGenericAttributeAsync<TEntity>(entityId, key, storeId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue