feat : products , ordering system , discount
add discount page and CRUD , complete products CRUD , improve ordering systemrelease
parent
70e667468d
commit
d442ed17ee
|
@ -14,11 +14,11 @@ public class OrderBagController : ICarterModule
|
||||||
.WithDisplayName("GetUserCurrentOrderBagAsync")
|
.WithDisplayName("GetUserCurrentOrderBagAsync")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
group.MapPost("add/{productId}", AddProductToBagAsync)
|
group.MapPost("add", AddProductToBagAsync)
|
||||||
.WithDisplayName("AddProductToBag")
|
.WithDisplayName("AddProductToBag")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
group.MapPost("remove/{productId}", RemoveFromOrderBagAsync)
|
group.MapDelete("remove", RemoveFromOrderBagAsync)
|
||||||
.WithDisplayName("RemoveFromOrderBag")
|
.WithDisplayName("RemoveFromOrderBag")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ public class OrderBagController : ICarterModule
|
||||||
public async Task<IResult> GetUserCurrentOrderBagAsync(IMediator mediator, CancellationToken cancellationToken)
|
public async Task<IResult> GetUserCurrentOrderBagAsync(IMediator mediator, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(new GetUserOrderBagQuery(), cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(new GetUserOrderBagQuery(), cancellationToken));
|
||||||
|
|
||||||
public async Task<IResult> AddProductToBagAsync( Guid productId, [FromQuery]int count, IMediator mediator, CancellationToken cancellationToken)
|
public async Task<IResult> AddProductToBagAsync([FromBody] List<OrderBagRequestDto> requestDtos, IMediator mediator, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(new AddToOrderBagCommand(productId,count), cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(new AddToOrderBagCommand(requestDtos), cancellationToken));
|
||||||
|
|
||||||
|
|
||||||
public async Task<IResult> RemoveFromOrderBagAsync(Guid productId, [FromQuery] int count, IMediator mediator, CancellationToken cancellationToken)
|
public async Task<IResult> RemoveFromOrderBagAsync([FromBody] List<OrderBagRequestDto> requestDtos, IMediator mediator, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(productId, count), cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(requestDtos), cancellationToken));
|
||||||
|
|
||||||
public async Task<IResult> AddDiscountToOrderBagAsync(Guid orderId, [FromQuery] string discountCode, IMediator mediator, CancellationToken cancellationToken)
|
public async Task<IResult> AddDiscountToOrderBagAsync(Guid orderId, [FromQuery] string discountCode, IMediator mediator, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken));
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class RoleController : ICarterModule
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET:Get All Entity
|
// GET:Get All Entity
|
||||||
public async Task<IResult> GetAllAsync([FromQuery] int page, IUserService userService, CancellationToken cancellationToken)
|
public async Task<IResult> GetAllAsync([FromQuery] int? page, [FromQuery]string? roleName, IUserService userService, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await userService.GetRolesAsync(page, cancellationToken));
|
=> TypedResults.Ok(await userService.GetRolesAsync(page,roleName, cancellationToken));
|
||||||
|
|
||||||
// GET:Get An Entity By Id
|
// GET:Get An Entity By Id
|
||||||
public async Task<IResult> GetAsync(Guid id, IUserService userService, CancellationToken cancellationToken)
|
public async Task<IResult> GetAsync(Guid id, IUserService userService, CancellationToken cancellationToken)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<!--<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>-->
|
||||||
|
|
||||||
<!--<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>10</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="MD.PersianDateTime.Standard" />
|
<Using Include="MD.PersianDateTime.Standard" />
|
||||||
|
|
|
@ -13,6 +13,7 @@ public interface IUserService : IScopedDependency
|
||||||
|
|
||||||
|
|
||||||
Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default);
|
Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default);
|
||||||
|
Task<List<ApplicationRole>> GetRolesAsync(int? page,string? roleName, CancellationToken cancellationToken = default);
|
||||||
Task<RoleActionRequestDto> GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default);
|
Task<RoleActionRequestDto> GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default);
|
||||||
Task<ApplicationRole> CreateRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default);
|
Task<ApplicationRole> CreateRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default);
|
||||||
Task<bool> EditRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default);
|
Task<bool> EditRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default);
|
||||||
|
|
|
@ -20,18 +20,23 @@ public class AddToOrderBagCommandHandler : IRequestHandler<AddToOrderBagCommand,
|
||||||
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
||||||
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
||||||
|
|
||||||
|
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
|
||||||
|
|
||||||
|
foreach (var requestDto in request.RequestDtos)
|
||||||
|
{
|
||||||
|
|
||||||
var product = await _repositoryWrapper.SetRepository<Product>()
|
var product = await _repositoryWrapper.SetRepository<Product>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
|
.FirstOrDefaultAsync(p => p.Id == requestDto.ProductId, cancellationToken);
|
||||||
|
|
||||||
if (product == null)
|
if (product == null)
|
||||||
throw new AppException("Product not found ", ApiResultStatusCode.NotFound);
|
throw new AppException("Product not found ", ApiResultStatusCode.NotFound);
|
||||||
if (!product.IsEnable)
|
if (!product.IsEnable)
|
||||||
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
|
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
|
||||||
|
|
||||||
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
|
|
||||||
|
|
||||||
orderBag.AddToOrderBag(product, request.Count);
|
orderBag.AddToOrderBag(product, requestDto.Count);
|
||||||
|
}
|
||||||
|
|
||||||
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
|
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
|
||||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
|
|
|
@ -19,18 +19,22 @@ public class RemoveFromOrderBagCommandHandler : IRequestHandler<RemoveFromOrderB
|
||||||
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId))
|
||||||
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
throw new AppException("User id wrong", ApiResultStatusCode.BadRequest);
|
||||||
|
|
||||||
|
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
|
||||||
|
|
||||||
|
foreach (var requestDto in request.RequestDtos)
|
||||||
|
{
|
||||||
var product = await _repositoryWrapper.SetRepository<Product>()
|
var product = await _repositoryWrapper.SetRepository<Product>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken);
|
.FirstOrDefaultAsync(p => p.Id == requestDto.ProductId, cancellationToken);
|
||||||
|
|
||||||
if (product == null)
|
if (product == null)
|
||||||
throw new AppException("Product not found ", ApiResultStatusCode.NotFound);
|
throw new AppException("Product not found ", ApiResultStatusCode.NotFound);
|
||||||
if (!product.IsEnable)
|
if (!product.IsEnable)
|
||||||
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
|
throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest);
|
||||||
|
|
||||||
var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken);
|
|
||||||
|
|
||||||
orderBag.RemoveFromOrderBag(product, request.Count);
|
orderBag.RemoveFromOrderBag(product, requestDto.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
|
_repositoryWrapper.SetRepository<Order>().Update(orderBag);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
||||||
namespace NetinaShop.Core.EntityServices;
|
namespace NetinaShop.Core.EntityServices;
|
||||||
|
@ -71,6 +72,16 @@ public class UserService : IUserService
|
||||||
.Skip(page * 15).Take(15)
|
.Skip(page * 15).Take(15)
|
||||||
.Select(ApplicationUserMapper.ProjectToSDto)
|
.Select(ApplicationUserMapper.ProjectToSDto)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
foreach (var user in users)
|
||||||
|
{
|
||||||
|
var roles = await _userManager.GetRolesAsync(user.AdaptToApplicationUser());
|
||||||
|
foreach (var roleName in roles)
|
||||||
|
{
|
||||||
|
var role = await _roleManager.FindByNameAsync(roleName);
|
||||||
|
if (role != null)
|
||||||
|
user.RoleName += role.PersianName + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +269,20 @@ public class UserService : IUserService
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<ApplicationRole>> GetRolesAsync(int? page, string? roleName, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
IQueryable<ApplicationRole> roles;
|
||||||
|
if (roleName!=null)
|
||||||
|
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.PersianName.Trim().ToLower().Contains(roleName));
|
||||||
|
else
|
||||||
|
roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin");
|
||||||
|
if (page != null)
|
||||||
|
roles = roles.Skip(page.Value * 15).Take(15);
|
||||||
|
else
|
||||||
|
roles = roles;
|
||||||
|
return await roles.ToListAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<RoleActionRequestDto> GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default)
|
public async Task<RoleActionRequestDto> GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var role = (await _roleManager.FindByIdAsync(roleId.ToString()));
|
var role = (await _roleManager.FindByIdAsync(roleId.ToString()));
|
||||||
|
@ -324,9 +349,6 @@ public class UserService : IUserService
|
||||||
foreach (var claim in request.Permissions)
|
foreach (var claim in request.Permissions)
|
||||||
await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim));
|
||||||
|
|
||||||
foreach (var claim in roleClaims)
|
|
||||||
await _roleManager.RemoveClaimAsync(applicationRole, claim);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
namespace NetinaShop.Domain.CommandQueries.Commands;
|
using NetinaShop.Domain.Entities.Products;
|
||||||
|
|
||||||
|
namespace NetinaShop.Domain.CommandQueries.Commands;
|
||||||
|
|
||||||
public sealed record CreateOrderCommand(string DiscountCode, List<OrderProductSDto> OrderProducts, OrderDeliverySDto OrderDelivery) : IRequest<OrderSDto>;
|
public sealed record CreateOrderCommand(string DiscountCode, List<OrderProductSDto> OrderProducts, OrderDeliverySDto OrderDelivery) : IRequest<OrderSDto>;
|
||||||
|
|
||||||
public sealed record AddToOrderBagCommand(Guid ProductId, int Count) : IRequest<bool>;
|
public sealed record AddToOrderBagCommand(List<OrderBagRequestDto> RequestDtos) : IRequest<bool>;
|
||||||
public sealed record RemoveFromOrderBagCommand(Guid ProductId, int Count) : IRequest<bool>;
|
public sealed record RemoveFromOrderBagCommand(List<OrderBagRequestDto> RequestDtos) : IRequest<bool>;
|
||||||
|
|
||||||
public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest<bool>;
|
public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest<bool>;
|
||||||
public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest<bool>;
|
public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest<bool>;
|
||||||
|
|
|
@ -10,6 +10,7 @@ string Warranty,
|
||||||
bool BeDisplayed,
|
bool BeDisplayed,
|
||||||
double Cost,
|
double Cost,
|
||||||
double PackingCost,
|
double PackingCost,
|
||||||
|
int Stock,
|
||||||
bool HasExpressDelivery,
|
bool HasExpressDelivery,
|
||||||
int MaxOrderCount,
|
int MaxOrderCount,
|
||||||
bool IsSpecialOffer,
|
bool IsSpecialOffer,
|
||||||
|
@ -30,6 +31,7 @@ public sealed record UpdateProductCommand(
|
||||||
bool BeDisplayed,
|
bool BeDisplayed,
|
||||||
double Cost,
|
double Cost,
|
||||||
double PackingCost,
|
double PackingCost,
|
||||||
|
int Stock,
|
||||||
bool HasExpressDelivery,
|
bool HasExpressDelivery,
|
||||||
int MaxOrderCount,
|
int MaxOrderCount,
|
||||||
bool IsSpecialOffer,
|
bool IsSpecialOffer,
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class ProductLDto : BaseDto<ProductLDto,Product>
|
||||||
public int MaxOrderCount { get; set; }
|
public int MaxOrderCount { get; set; }
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public double PackingCost { get; set; }
|
public double PackingCost { get; set; }
|
||||||
|
public int Stock { get; set; }
|
||||||
public Guid BrandId { get; set; }
|
public Guid BrandId { get; set; }
|
||||||
public string BrandName { get; set; } = string.Empty;
|
public string BrandName { get; set; } = string.Empty;
|
||||||
public Guid CategoryId { get; set; }
|
public Guid CategoryId { get; set; }
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace NetinaShop.Domain.Dtos.RequestDtos;
|
||||||
|
|
||||||
|
public class OrderBagRequestDto
|
||||||
|
{
|
||||||
|
public Guid ProductId { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
|
@ -7,11 +7,27 @@ public partial class Product
|
||||||
double cost,
|
double cost,
|
||||||
double packingCost,
|
double packingCost,
|
||||||
bool hasExpressDelivery,
|
bool hasExpressDelivery,
|
||||||
|
int stock,
|
||||||
int maxOrderCount,
|
int maxOrderCount,
|
||||||
Guid brandId,
|
Guid brandId,
|
||||||
Guid categoryId)
|
Guid categoryId)
|
||||||
{
|
{
|
||||||
return new Product(persianName, englishName, summery, expertCheck, tags, warranty, beDisplayed,cost, packingCost,hasExpressDelivery,maxOrderCount, brandId,categoryId);
|
return new Product(
|
||||||
|
persianName,
|
||||||
|
englishName,
|
||||||
|
summery,
|
||||||
|
expertCheck,
|
||||||
|
tags,
|
||||||
|
warranty,
|
||||||
|
beDisplayed,
|
||||||
|
cost,
|
||||||
|
packingCost,
|
||||||
|
stock,
|
||||||
|
hasExpressDelivery,
|
||||||
|
maxOrderCount,
|
||||||
|
stock > 0,
|
||||||
|
brandId,
|
||||||
|
categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRate(float rate)
|
public void AddRate(float rate)
|
||||||
|
|
|
@ -23,8 +23,10 @@ public partial class Product : ApiEntity
|
||||||
bool beDisplayed,
|
bool beDisplayed,
|
||||||
double cost,
|
double cost,
|
||||||
double packingCost,
|
double packingCost,
|
||||||
|
int stock,
|
||||||
bool hasExpressDelivery,
|
bool hasExpressDelivery,
|
||||||
int maxOrderCount,
|
int maxOrderCount,
|
||||||
|
bool isEnable,
|
||||||
Guid brandId,
|
Guid brandId,
|
||||||
Guid categoryId)
|
Guid categoryId)
|
||||||
{
|
{
|
||||||
|
@ -37,8 +39,10 @@ public partial class Product : ApiEntity
|
||||||
BeDisplayed = beDisplayed;
|
BeDisplayed = beDisplayed;
|
||||||
Cost = cost;
|
Cost = cost;
|
||||||
PackingCost = packingCost;
|
PackingCost = packingCost;
|
||||||
|
Stock = stock;
|
||||||
HasExpressDelivery = hasExpressDelivery;
|
HasExpressDelivery = hasExpressDelivery;
|
||||||
MaxOrderCount = maxOrderCount;
|
MaxOrderCount = maxOrderCount;
|
||||||
|
IsEnable = isEnable;
|
||||||
BrandId = brandId;
|
BrandId = brandId;
|
||||||
CategoryId = categoryId;
|
CategoryId = categoryId;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +56,7 @@ public partial class Product : ApiEntity
|
||||||
public bool IsEnable { get; internal set; }
|
public bool IsEnable { get; internal set; }
|
||||||
public bool BeDisplayed { get; internal set; }
|
public bool BeDisplayed { get; internal set; }
|
||||||
public double PackingCost { get; internal set; }
|
public double PackingCost { get; internal set; }
|
||||||
|
public int Stock { get; internal set; }
|
||||||
public float Rate { get; internal set; }
|
public float Rate { get; internal set; }
|
||||||
public int ReviewCount { get; internal set; }
|
public int ReviewCount { get; internal set; }
|
||||||
public int Viewed { get; internal set; }
|
public int Viewed { get; internal set; }
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
public enum Gender
|
public enum Gender
|
||||||
{
|
{
|
||||||
|
[Display(Name = "مرد")]
|
||||||
Male,
|
Male,
|
||||||
|
[Display(Name = "بانو")]
|
||||||
Female
|
Female
|
||||||
}
|
}
|
|
@ -26,6 +26,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
Cost = p1.Cost,
|
Cost = p1.Cost,
|
||||||
BeDisplayed = p1.BeDisplayed,
|
BeDisplayed = p1.BeDisplayed,
|
||||||
PackingCost = p1.PackingCost,
|
PackingCost = p1.PackingCost,
|
||||||
|
Stock = p1.Stock,
|
||||||
HasExpressDelivery = p1.HasExpressDelivery,
|
HasExpressDelivery = p1.HasExpressDelivery,
|
||||||
MaxOrderCount = p1.MaxOrderCount,
|
MaxOrderCount = p1.MaxOrderCount,
|
||||||
BrandId = p1.BrandId,
|
BrandId = p1.BrandId,
|
||||||
|
@ -54,6 +55,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
result.Cost = p5.Cost;
|
result.Cost = p5.Cost;
|
||||||
result.BeDisplayed = p5.BeDisplayed;
|
result.BeDisplayed = p5.BeDisplayed;
|
||||||
result.PackingCost = p5.PackingCost;
|
result.PackingCost = p5.PackingCost;
|
||||||
|
result.Stock = p5.Stock;
|
||||||
result.HasExpressDelivery = p5.HasExpressDelivery;
|
result.HasExpressDelivery = p5.HasExpressDelivery;
|
||||||
result.MaxOrderCount = p5.MaxOrderCount;
|
result.MaxOrderCount = p5.MaxOrderCount;
|
||||||
result.BrandId = p5.BrandId;
|
result.BrandId = p5.BrandId;
|
||||||
|
@ -77,6 +79,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
Cost = p13.Cost,
|
Cost = p13.Cost,
|
||||||
BeDisplayed = p13.BeDisplayed,
|
BeDisplayed = p13.BeDisplayed,
|
||||||
PackingCost = p13.PackingCost,
|
PackingCost = p13.PackingCost,
|
||||||
|
Stock = p13.Stock,
|
||||||
HasExpressDelivery = p13.HasExpressDelivery,
|
HasExpressDelivery = p13.HasExpressDelivery,
|
||||||
MaxOrderCount = p13.MaxOrderCount,
|
MaxOrderCount = p13.MaxOrderCount,
|
||||||
BrandId = p13.BrandId,
|
BrandId = p13.BrandId,
|
||||||
|
@ -132,6 +135,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MaxOrderCount = p17.MaxOrderCount,
|
MaxOrderCount = p17.MaxOrderCount,
|
||||||
Cost = p17.Cost,
|
Cost = p17.Cost,
|
||||||
PackingCost = p17.PackingCost,
|
PackingCost = p17.PackingCost,
|
||||||
|
Stock = p17.Stock,
|
||||||
BrandId = p17.BrandId,
|
BrandId = p17.BrandId,
|
||||||
BrandName = p17.Brand == null ? null : p17.Brand.Name,
|
BrandName = p17.Brand == null ? null : p17.Brand.Name,
|
||||||
CategoryId = p17.CategoryId,
|
CategoryId = p17.CategoryId,
|
||||||
|
@ -162,6 +166,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
result.MaxOrderCount = p21.MaxOrderCount;
|
result.MaxOrderCount = p21.MaxOrderCount;
|
||||||
result.Cost = p21.Cost;
|
result.Cost = p21.Cost;
|
||||||
result.PackingCost = p21.PackingCost;
|
result.PackingCost = p21.PackingCost;
|
||||||
|
result.Stock = p21.Stock;
|
||||||
result.BrandId = p21.BrandId;
|
result.BrandId = p21.BrandId;
|
||||||
result.BrandName = p21.Brand == null ? null : p21.Brand.Name;
|
result.BrandName = p21.Brand == null ? null : p21.Brand.Name;
|
||||||
result.CategoryId = p21.CategoryId;
|
result.CategoryId = p21.CategoryId;
|
||||||
|
@ -187,6 +192,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MaxOrderCount = p29.MaxOrderCount,
|
MaxOrderCount = p29.MaxOrderCount,
|
||||||
Cost = p29.Cost,
|
Cost = p29.Cost,
|
||||||
PackingCost = p29.PackingCost,
|
PackingCost = p29.PackingCost,
|
||||||
|
Stock = p29.Stock,
|
||||||
BrandId = p29.BrandId,
|
BrandId = p29.BrandId,
|
||||||
BrandName = p29.Brand.Name,
|
BrandName = p29.Brand.Name,
|
||||||
CategoryId = p29.CategoryId,
|
CategoryId = p29.CategoryId,
|
||||||
|
@ -291,41 +297,28 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
public static ProductSDto AdaptToSDto(this Product p40)
|
public static ProductSDto AdaptToSDto(this Product p40)
|
||||||
{
|
{
|
||||||
if (p40 == null)
|
return p40 == null ? null : new ProductSDto()
|
||||||
{
|
{
|
||||||
return null;
|
PersianName = p40.PersianName,
|
||||||
}
|
EnglishName = p40.EnglishName,
|
||||||
ProductSDto result = new ProductSDto();
|
Summery = p40.Summery,
|
||||||
|
ExpertCheck = p40.ExpertCheck,
|
||||||
result.PersianName = p40.PersianName;
|
Tags = p40.Tags,
|
||||||
result.EnglishName = p40.EnglishName;
|
Warranty = p40.Warranty,
|
||||||
result.Summery = p40.Summery;
|
Cost = p40.Cost,
|
||||||
result.ExpertCheck = p40.ExpertCheck;
|
IsEnable = p40.IsEnable,
|
||||||
result.Tags = p40.Tags;
|
BeDisplayed = p40.BeDisplayed,
|
||||||
result.Warranty = p40.Warranty;
|
PackingCost = p40.PackingCost,
|
||||||
result.Cost = p40.Cost;
|
Rate = p40.Rate,
|
||||||
result.IsEnable = p40.IsEnable;
|
ReviewCount = p40.ReviewCount,
|
||||||
result.BeDisplayed = p40.BeDisplayed;
|
Viewed = p40.Viewed,
|
||||||
result.PackingCost = p40.PackingCost;
|
CategoryId = p40.CategoryId,
|
||||||
result.Rate = p40.Rate;
|
BrandId = p40.BrandId,
|
||||||
result.ReviewCount = p40.ReviewCount;
|
BrandName = p40.Brand == null ? null : p40.Brand.Name,
|
||||||
result.Viewed = p40.Viewed;
|
CategoryName = p40.Category == null ? null : p40.Category.Name,
|
||||||
result.CategoryId = p40.CategoryId;
|
Id = p40.Id,
|
||||||
result.BrandId = p40.BrandId;
|
CreatedAt = p40.CreatedAt
|
||||||
result.Id = p40.Id;
|
};
|
||||||
result.CreatedAt = p40.CreatedAt;
|
|
||||||
|
|
||||||
if (!(p40.Brand == null))
|
|
||||||
{
|
|
||||||
result.BrandName = p40.Brand == null ? null : p40.Brand.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(p40.Category == null))
|
|
||||||
{
|
|
||||||
result.CategoryName = p40.Category == null ? null : p40.Category.Name;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static ProductSDto AdaptTo(this Product p41, ProductSDto p42)
|
public static ProductSDto AdaptTo(this Product p41, ProductSDto p42)
|
||||||
{
|
{
|
||||||
|
@ -350,18 +343,10 @@ namespace NetinaShop.Domain.Mappers
|
||||||
result.Viewed = p41.Viewed;
|
result.Viewed = p41.Viewed;
|
||||||
result.CategoryId = p41.CategoryId;
|
result.CategoryId = p41.CategoryId;
|
||||||
result.BrandId = p41.BrandId;
|
result.BrandId = p41.BrandId;
|
||||||
|
result.BrandName = p41.Brand == null ? null : p41.Brand.Name;
|
||||||
|
result.CategoryName = p41.Category == null ? null : p41.Category.Name;
|
||||||
result.Id = p41.Id;
|
result.Id = p41.Id;
|
||||||
result.CreatedAt = p41.CreatedAt;
|
result.CreatedAt = p41.CreatedAt;
|
||||||
|
|
||||||
if (!(p41.Brand == null))
|
|
||||||
{
|
|
||||||
result.BrandName = p41.Brand == null ? null : p41.Brand.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(p41.Category == null))
|
|
||||||
{
|
|
||||||
result.CategoryName = p41.Category == null ? null : p41.Category.Name;
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<!--<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
|
||||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>-->
|
||||||
|
|
||||||
<!--<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>10</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class UpdateDiscountCommandHandler : IRequestHandler<UpdateDiscountComman
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DiscountType.Product:
|
case DiscountType.Product:
|
||||||
var productEnt = await _repositoryWrapper.SetRepository<CategoryDiscount>().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken);
|
var productEnt = await _repositoryWrapper.SetRepository<ProductDiscount>().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken);
|
||||||
if (productEnt == null)
|
if (productEnt == null)
|
||||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,10 @@ public class CreateProductCommandHandler : IRequestHandler<CreateProductCommand,
|
||||||
public async Task<ProductLDto> Handle(CreateProductCommand request, CancellationToken cancellationToken)
|
public async Task<ProductLDto> Handle(CreateProductCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck,
|
var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck,
|
||||||
request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost,request.HasExpressDelivery,request.MaxOrderCount,
|
request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost,
|
||||||
|
request.HasExpressDelivery,
|
||||||
|
request.Stock,
|
||||||
|
request.MaxOrderCount,
|
||||||
request.BrandId,request.CategoryId);
|
request.BrandId,request.CategoryId);
|
||||||
|
|
||||||
foreach (var specification in request.Specifications)
|
foreach (var specification in request.Specifications)
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class UpdateProductCommandHandler : IRequestHandler<UpdateProductCommand,
|
||||||
request.Cost,
|
request.Cost,
|
||||||
request.PackingCost,
|
request.PackingCost,
|
||||||
request.HasExpressDelivery,
|
request.HasExpressDelivery,
|
||||||
|
request.Stock,
|
||||||
request.MaxOrderCount,
|
request.MaxOrderCount,
|
||||||
request.BrandId,
|
request.BrandId,
|
||||||
request.CategoryId);
|
request.CategoryId);
|
||||||
|
|
1608
NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.Designer.cs
generated
100644
1608
NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace NetinaShop.Repository.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class EditProductIsEnable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Stock",
|
||||||
|
schema: "public",
|
||||||
|
table: "Products",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Stock",
|
||||||
|
schema: "public",
|
||||||
|
table: "Products");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -721,6 +721,9 @@ namespace NetinaShop.Repository.Migrations
|
||||||
b.Property<int>("ReviewCount")
|
b.Property<int>("ReviewCount")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Stock")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("Summery")
|
b.Property<string>("Summery")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
|
@ -105,12 +105,12 @@ try
|
||||||
var price = postMetas.FirstOrDefault(pm => pm.post_id == wordPressPostDto.ID && pm.meta_key == "_price");
|
var price = postMetas.FirstOrDefault(pm => pm.post_id == wordPressPostDto.ID && pm.meta_key == "_price");
|
||||||
if (price != null && double.TryParse(price.meta_value, out double dPrice))
|
if (price != null && double.TryParse(price.meta_value, out double dPrice))
|
||||||
product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content,
|
product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content,
|
||||||
wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0,
|
wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0,10,
|
||||||
false,10,false,brandId, categoryId,
|
false,10,false,brandId, categoryId,
|
||||||
new DiscountSDto(),new List<SpecificationSDto>(), new List<StorageFileSDto>());
|
new DiscountSDto(),new List<SpecificationSDto>(), new List<StorageFileSDto>());
|
||||||
else
|
else
|
||||||
product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content,
|
product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content,
|
||||||
wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,false,10,
|
wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,10,false,10,
|
||||||
false,brandId,categoryId,
|
false,brandId,categoryId,
|
||||||
new DiscountSDto(),new List<SpecificationSDto>(), new List<StorageFileSDto>());
|
new DiscountSDto(),new List<SpecificationSDto>(), new List<StorageFileSDto>());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue