From 48d3386233f27d1960a468b3e447f678c3708888 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Mon, 14 Apr 2025 18:02:07 +0330 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20brand-specific=20discount=20f?= =?UTF-8?q?eature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ➕ Add `MudAutocomplete` for brand selection in UI Introduced a new component in `DiscountActionDialogBox.razor`. - 🆕 Introduce `IsBrandEnable` property in ViewModel Added to manage the state of brand-specific discounts. - 🔄 Update ViewModel logic for `IsBrandEnable` Ensured mutual exclusivity with other discount types. - 🛠️ Handle brand selection in `SubmitEditAsync` Added logic for brand selection and validation. - 🔍 Modify `SearchBrand` method in ViewModel Fetch and return brand data for selection. - 📦 Change target framework to `net5.0` Updated `Netina.Common.csproj` and `Netina.Domain.csproj`. - 🆙 Update `UpdateDiscountCommand` and `DiscountLDto` Included `BrandId` and `BrandName` properties. - 🛠️ Modify `UpdateDiscountCommandHandler` Handle brand-specific discount updates. - 🆕 Add `SubmitEditAsync` method in ViewModel For handling discount edits. Changes made by Amir.H Khademi --- Netina.Common/Netina.Common.csproj | 8 ++++---- Netina.Domain/CommandQueries/Commands/DiscountCommands.cs | 3 ++- Netina.Domain/Dtos/LargDtos/DiscountLDto.cs | 2 ++ Netina.Domain/Netina.Domain.csproj | 8 ++++---- .../Handlers/Discounts/UpdateDiscountCommandHandler.cs | 2 +- .../SubProducts/UpdateSubProductCommandHandler.cs | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Netina.Common/Netina.Common.csproj b/Netina.Common/Netina.Common.csproj index e13fd24..35a3466 100644 --- a/Netina.Common/Netina.Common.csproj +++ b/Netina.Common/Netina.Common.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/Netina.Domain/CommandQueries/Commands/DiscountCommands.cs b/Netina.Domain/CommandQueries/Commands/DiscountCommands.cs index da9f253..091df1b 100644 --- a/Netina.Domain/CommandQueries/Commands/DiscountCommands.cs +++ b/Netina.Domain/CommandQueries/Commands/DiscountCommands.cs @@ -47,7 +47,8 @@ public sealed record UpdateDiscountCommand( bool IsSpecialOffer, bool IsForFirstPurchase, Guid ProductId, - Guid CategoryId) : IRequest; + Guid CategoryId, + Guid BrandId) : IRequest; public sealed record DeleteDiscountCommand(Guid Id) : IRequest; diff --git a/Netina.Domain/Dtos/LargDtos/DiscountLDto.cs b/Netina.Domain/Dtos/LargDtos/DiscountLDto.cs index bc6896c..dceeaac 100644 --- a/Netina.Domain/Dtos/LargDtos/DiscountLDto.cs +++ b/Netina.Domain/Dtos/LargDtos/DiscountLDto.cs @@ -23,6 +23,8 @@ public class DiscountLDto : BaseDto public bool IsForInvitation { get; set; } public Guid ProductId { get; set; } public string ProductName { get; set; } = string.Empty; + public Guid BrandId { get; set; } + public string BrandName { get; set; } = string.Empty; public Guid CategoryId { get; set; } public string CategoryName { get; set; } = string.Empty; public bool IsForFirstPurchase { get; set; } diff --git a/Netina.Domain/Netina.Domain.csproj b/Netina.Domain/Netina.Domain.csproj index 7206c71..71801de 100644 --- a/Netina.Domain/Netina.Domain.csproj +++ b/Netina.Domain/Netina.Domain.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/Netina.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs b/Netina.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs index 0741e89..9b85add 100644 --- a/Netina.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs +++ b/Netina.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs @@ -66,7 +66,7 @@ public class UpdateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper) request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, - request.UseCount, request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.ProductId); + request.UseCount, request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.BrandId); brandDis.Id = brandEnt.Id; brandDis.CreatedAt = brandEnt.CreatedAt; brandDis.CreatedBy = brandEnt.CreatedBy; diff --git a/Netina.Repository/Handlers/SubProducts/UpdateSubProductCommandHandler.cs b/Netina.Repository/Handlers/SubProducts/UpdateSubProductCommandHandler.cs index b9608ad..aa1c38c 100644 --- a/Netina.Repository/Handlers/SubProducts/UpdateSubProductCommandHandler.cs +++ b/Netina.Repository/Handlers/SubProducts/UpdateSubProductCommandHandler.cs @@ -5,7 +5,7 @@ public class UpdateSubProductCommandHandler(IRepositoryWrapper repositoryWrapper { public async Task Handle(UpdateSubProductCommand request, CancellationToken cancellationToken) { - + if (currentUserService.UserId == null) throw new BaseApiException(ApiResultStatusCode.UnAuthorized, "User id is wrong");