Compare commits

...

5 Commits

Author SHA1 Message Date
Loretta ca1f59a5e1 product event fixex; etc... 2025-10-11 17:51:30 +02:00
Loretta c9fa03a69c fix 2025-10-11 12:53:54 +02:00
Loretta 08b5d2984a improvements, etc 2025-10-11 12:52:55 +02:00
Loretta da241818d7 fix 2025-10-11 07:12:22 +02:00
Loretta 35378d9b0d CustomOrders in progress.... 2025-10-11 07:11:00 +02:00
10 changed files with 195 additions and 168 deletions

View File

@ -1,29 +1,65 @@
using Microsoft.AspNetCore.Mvc;
using Nop.Services.Orders;
using Nop.Web.Areas.Admin.Controllers;
using Nop.Web.Framework.Mvc.Filters;
using Nop.Web.Framework;
using Nop.Web.Areas.Admin.Models.Orders;
using Nop.Services.Security;
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.Web.Areas.Admin.Factories;
using Nop.Plugin.Misc.FruitBankPlugin.Models;
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;
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
public class CustomOrderController : BaseAdminController, ICustomOrderSignalREndpointServer
{
private readonly IOrderService _orderService;
private readonly IOrderModelFactory _orderModelFactory;
private readonly CustomOrderModelFactory _orderModelFactory;
private readonly ICustomOrderSignalREndpointServer _customOrderSignalREndpoint;
private readonly IPermissionService _permissionService;
// ... other dependencies
public CustomOrderController(IOrderService orderService, IOrderModelFactory orderModelFactory, IPermissionService permissionService)
public CustomOrderController(IOrderService orderService, IOrderModelFactory orderModelFactory, ICustomOrderSignalREndpointServer customOrderSignalREndpoint, IPermissionService permissionService)
{
_orderService = orderService;
_orderModelFactory = orderModelFactory;
_orderModelFactory = orderModelFactory as CustomOrderModelFactory;
_customOrderSignalREndpoint = customOrderSignalREndpoint;
_permissionService = permissionService;
// ... initialize other deps
}
@ -44,20 +80,39 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
[HttpPost]
[CheckPermission(StandardPermission.Orders.ORDERS_VIEW)]
public virtual async Task<IActionResult> OrderList(OrderSearchModel searchModel)
public async Task<IActionResult> OrderList(OrderSearchModel searchModel)
{
//prepare model
var model = await _orderModelFactory.PrepareOrderListModelAsync(searchModel);
var orderListModel = await GetOrderModelsByFilter(searchModel);
var valami = Json(orderListModel);
Console.WriteLine(valami);
return valami;
}
Console.WriteLine($"Total: {model.RecordsTotal}, Data Count: {model.Data.Count()}");
foreach (var item in model.Data.Take(3))
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($"Order: {item.Id}, {item.CustomOrderNumber}");
}
var valami = Json(model);
Console.WriteLine(valami);
return valami;
return orderListModel;
}
[SignalR(SignalRTags.GetPendingOrderModels)]
public async Task<OrderListModelExtended> GetPendingOrderModels()
{
var orderSearchModel = new OrderSearchModel
{
OrderStatusIds = new List<int> { 1 }
};
return await GetOrderModelsByFilter(orderSearchModel);
}
public virtual IActionResult Test()

View File

@ -5,6 +5,7 @@ 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;
@ -14,60 +15,34 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
[ViewComponent(Name = "ProductAttributes")]
public class ProductAttributesViewComponent : NopViewComponent
{
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 FruitBankAttributeService _fruitBankAttributeService;
private readonly IWorkContext _workContext;
private readonly IStoreContext _storeContext;
public ProductAttributesViewComponent(
IGenericAttributeService genericAttributeService,
IWorkContext workContext,
IStoreContext storeContext)
public ProductAttributesViewComponent(FruitBankAttributeService fruitBankAttributeService, 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 (additionalData is not ProductModel product)
return Content("");
var model = new ProductAttributesModel
if (model.ProductId > 0)
{
ProductId = product.Id
};
//get store scope
var storeScope = await _storeContext.GetCurrentStoreAsync();
if (product.Id > 0)
var measuringAttributeValues = await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync<Product>(model.ProductId);
if (measuringAttributeValues != null)
{
// Load existing values
var dbProduct = new Core.Domain.Catalog.Product { Id = product.Id };
model.IsMeasurable = measuringAttributeValues.IsMeasurable;
model.NetWeight = measuringAttributeValues.NetWeight;
}
//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);
model.Tare = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Product, double>(model.ProductId, nameof(ITare.Tare));
model.IncomingQuantity = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Product, int>(model.ProductId, "IncomingQuantity");
}
return View("~/Plugins/Misc.FruitBankPlugin/Views/ProductAttributes.cshtml", model);

View File

@ -7,6 +7,7 @@ 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;

View File

@ -19,8 +19,8 @@ using System.Globalization;
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers;
public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, FruitBankDbContext ctx, FruitBankAttributeService fruitBankAttributeService, IStoreContext storeContext, IEnumerable<IAcLogWriterBase> logWriters, IGenericAttributeService genericAttributeService) :
MgEventConsumer(httpContextAccessor, logWriters),
public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBankDbContext ctx, FruitBankAttributeService fruitBankAttributeService, IEnumerable<IAcLogWriterBase> logWriters) :
MgEventConsumer(httpContextAcc, logWriters),
IConsumer<EntityDeletedEvent<Shipping>>,
IConsumer<EntityInsertedEvent<ShippingItem>>,
IConsumer<EntityUpdatedEvent<ShippingItem>>,
@ -36,7 +36,7 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, Fr
{
var product = eventMessage.Entity;
await SaveCustomAttributesAsync(eventMessage.Entity);
await SaveProductCustomAttributesAsync(eventMessage.Entity);
var isMeasurableProduct = await fruitBankAttributeService.IsMeasurableEntityAsync<Product>(product.Id);
@ -51,61 +51,42 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, Fr
await base.HandleEventAsync(eventMessage);
}
public async Task HandleEventAsync(EntityInsertedEvent<Product> eventMessage)
public override async Task HandleEventAsync(EntityInsertedEvent<Product> eventMessage)
{
await SaveCustomAttributesAsync(eventMessage.Entity);
await SaveProductCustomAttributesAsync(eventMessage.Entity);
await base.HandleEventAsync(eventMessage);
}
private async Task SaveCustomAttributesAsync(Product product)
private async Task SaveProductCustomAttributesAsync(Product product)
{
if (product == null)
return;
if (product == null) return;
var form = httpContextAccessor.HttpContext?.Request?.Form;
if (form == null || !form.Any())
return;
var form = HttpContextAccessor.HttpContext?.Request?.Form;
if (form == null || form.Count == 0) return;
var store = await storeContext.GetCurrentStoreAsync();
if (form.ContainsKey(nameof(IMeasurable.IsMeasurable)) && form.ContainsKey(nameof(IMeasuringNetWeight.NetWeight)))
{
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());
// Save IsMeasurable
if (form.ContainsKey(nameof(IMeasuringAttributeValues.IsMeasurable)))
{
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);
}
// 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);
}
await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, netWeight, 0, isMeasurable, false);
}
if (form.ContainsKey(nameof(ITare.Tare)))
{
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);
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);
}
}

View File

@ -1,12 +1,16 @@
using Microsoft.AspNetCore.Mvc.Infrastructure;
using AyCode.Core.Extensions;
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.Core;
using Nop.Plugin.Misc.FruitBankPlugin.Helpers;
using Nop.Plugin.Misc.FruitBankPlugin.Models;
using Nop.Plugin.Misc.FruitBankPlugin.Services;
using Nop.Services.Affiliates;
using Nop.Services.Catalog;
@ -28,10 +32,7 @@ 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
{
@ -166,32 +167,31 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Factories
}
public override async Task<OrderListModel> PrepareOrderListModelAsync(OrderSearchModel searchModel)
{
// get the default model first
var baseModel = await base.PrepareOrderListModelAsync(searchModel);
=>await base.PrepareOrderListModelAsync(searchModel);
var extendedRows = new List<OrderModelExtended>();
foreach (var order in baseModel.Data)
public async Task<OrderListModelExtended> PrepareOrderListModelExtendedAsync(OrderSearchModel searchModel)
{
var extendedOrder = new OrderModelExtended();
CopyModelHelper.CopyPublicProperties(order, extendedOrder);
extendedOrder.IsMeasurable = await ShouldMarkAsNeedsMeasurementAsync(order);
Console.WriteLine(extendedOrder.Id);
extendedRows.Add(extendedOrder);
var orderListModel = await PrepareOrderListModelAsync(searchModel);
var orderListModelExtended = new OrderListModelExtended();
var extendedRows = new List<OrderModelExtended>(orderListModel.RecordsFiltered);
//TODO: Megnézni miért száll el az IEnumerable!!! - J.
//PropertyHelper.CopyPublicProperties(orderListModel, orderListModelExtended);
foreach (var orderModel in orderListModel.Data)
{
var orderModelExtended = new OrderModelExtended();
PropertyHelper.CopyPublicProperties(orderModel, orderModelExtended);
orderModelExtended.IsMeasurable = await ShouldMarkAsNeedsMeasurementAsync(orderModel);
Console.WriteLine(orderModelExtended.Id);
extendedRows.Add(orderModelExtended);
}
//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;
orderListModelExtended.Data = extendedRows; // Different cast approach
return orderListModelExtended;
}
// example async custom logic

View File

@ -1,28 +0,0 @@
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));
}
}
}
}

View File

@ -27,7 +27,9 @@ 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 FruitBankDataController = Nop.Plugin.Misc.FruitBankPlugin.Controllers.FruitBankDataController;
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;
@ -66,6 +68,7 @@ public class PluginNopStartup : INopStartup
services.AddScoped<FruitBankDbContext>();
services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
services.AddScoped<ICustomOrderSignalREndpointServer, CustomOrderSignalREndpoint>();
//services.AddScoped<CustomModelFactory, ICustomerModelFactory>();
services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
@ -73,9 +76,11 @@ public class PluginNopStartup : INopStartup
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>();

View File

@ -0,0 +1,8 @@
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; }
}

View File

@ -1,8 +1,9 @@
using Nop.Web.Areas.Admin.Models.Orders;
using Nop.Web.Framework.Models;
namespace Nop.Plugin.Misc.FruitBankPlugin.Models
{
public partial record OrderListModelExtended : OrderListModel
public partial record OrderListModelExtended : BasePagedListModel<OrderModelExtended>, IOrderListModelExtended<OrderModelExtended>
{
public bool? NeedsMeasurement { get; set; }
}

View File

@ -19,6 +19,15 @@ 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))
@ -121,6 +130,20 @@ 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
@ -135,6 +158,9 @@ 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);
@ -147,6 +173,9 @@ 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);