Add brand-specific discount feature

-  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
master
Amir Hossein Khademi 2025-04-14 18:02:07 +03:30
parent 13751e452a
commit 48d3386233
6 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -13,9 +13,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
</ItemGroup>
</ItemGroup>-->
<!--<PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
@ -26,7 +26,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
</ItemGroup>-->
</ItemGroup>
<ItemGroup>
<Using Include="MD.PersianDateTime.Standard" />

View File

@ -47,7 +47,8 @@ public sealed record UpdateDiscountCommand(
bool IsSpecialOffer,
bool IsForFirstPurchase,
Guid ProductId,
Guid CategoryId) : IRequest<bool>;
Guid CategoryId,
Guid BrandId) : IRequest<bool>;
public sealed record DeleteDiscountCommand(Guid Id) : IRequest<bool>;

View File

@ -23,6 +23,8 @@ public class DiscountLDto : BaseDto<DiscountLDto,Discount>
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; }

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@ -16,9 +16,9 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.8" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>
</ItemGroup>-->
<!--<PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>-->
</ItemGroup>
<ItemGroup>

View File

@ -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;

View File

@ -5,7 +5,7 @@ public class UpdateSubProductCommandHandler(IRepositoryWrapper repositoryWrapper
{
public async Task<Guid> Handle(UpdateSubProductCommand request, CancellationToken cancellationToken)
{
if (currentUserService.UserId == null)
throw new BaseApiException(ApiResultStatusCode.UnAuthorized, "User id is wrong");