fix(CateforyDiscount) , fix(ProductReviewCountInDTos) , VER 1.5.17.23
parent
c3abc322d4
commit
a1f2e92863
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"PostgresServer": "Host=185.220.227.246;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi",
|
"PostgresServer": "Host=185.220.227.39;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi",
|
||||||
"Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB",
|
"Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB",
|
||||||
"MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB"
|
"MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB"
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,6 +36,10 @@ public class BlogController : ICarterModule
|
||||||
.WithDisplayName("Update Blog")
|
.WithDisplayName("Update Blog")
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
|
group.MapGet("{blogId}/comment", GetBlogCommentsAsync)
|
||||||
|
.WithDisplayName("Get Blog Comments")
|
||||||
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
group.MapDelete("{id}", Delete)
|
group.MapDelete("{id}", Delete)
|
||||||
.RequireAuthorization(builder =>
|
.RequireAuthorization(builder =>
|
||||||
builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()
|
builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()
|
||||||
|
@ -49,6 +53,10 @@ public class BlogController : ICarterModule
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<IResult> GetBlogCommentsAsync([FromQuery] int page, [FromQuery] int count, [FromRoute] Guid blogId, IMediator mediator, CancellationToken cancellationToken)
|
||||||
|
=> TypedResults.Ok(await mediator.Send(new GetCommentsQuery(page, count, null, blogId), cancellationToken));
|
||||||
|
|
||||||
private async Task<IResult> GetBlogNewLinkAsync([FromQuery]string slug,IRepositoryWrapper repositoryWrapper,IOptionsSnapshot<SiteSettings> snapshot,CancellationToken cancellationToken)
|
private async Task<IResult> GetBlogNewLinkAsync([FromQuery]string slug,IRepositoryWrapper repositoryWrapper,IOptionsSnapshot<SiteSettings> snapshot,CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var htmlSlug = HttpUtility.UrlEncode(slug);
|
var htmlSlug = HttpUtility.UrlEncode(slug);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<AssemblyVersion>1.5.14.20</AssemblyVersion>
|
<AssemblyVersion>1.5.17.23</AssemblyVersion>
|
||||||
<FileVersion>1.5.14.20</FileVersion>
|
<FileVersion>1.5.17.23</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
|
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
|
||||||
<PackageReference Include="Ben.BlockingDetector" Version="0.0.4" />
|
<PackageReference Include="Ben.BlockingDetector" Version="0.0.4" />
|
||||||
<PackageReference Include="Carter" Version="8.2.1" />
|
<PackageReference Include="Carter" Version="8.1.0" />
|
||||||
<PackageReference Include="FluentValidation" Version="11.10.0" />
|
<PackageReference Include="FluentValidation" Version="11.10.0" />
|
||||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
|
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
|
||||||
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.1.0" />
|
<PackageReference Include="MediatR.Extensions.Autofac.DependencyInjection" Version="12.1.0" />
|
||||||
|
|
|
@ -72,7 +72,7 @@ public static class ServiceExtensions
|
||||||
serviceCollection.AddDbContextFactory<ApplicationContext>(options =>
|
serviceCollection.AddDbContextFactory<ApplicationContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||||
options.UseNpgsql(Configuration.GetConnectionString("Postgres"), b => b.MigrationsAssembly("Netina.Repository"))
|
options.UseNpgsql(Configuration.GetConnectionString("PostgresServer"), b => b.MigrationsAssembly("Netina.Repository"))
|
||||||
.UseProjectAssembly(typeof(ApplicationUser).Assembly);
|
.UseProjectAssembly(typeof(ApplicationUser).Assembly);
|
||||||
|
|
||||||
//options.EnableServiceProviderCaching(true);
|
//options.EnableServiceProviderCaching(true);
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace Netina.Common.Extensions
|
||||||
|
|
||||||
return outPut;
|
return outPut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToPriceWhitPriceType(this long price, string priceType)
|
public static string ToPriceWhitPriceType(this long price, string priceType)
|
||||||
{
|
{
|
||||||
return price.ToString("N0") + " " + priceType;
|
return price.ToString("N0") + " " + priceType;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Netina.Core.EntityServices.DiscountHandlers;
|
using Netina.Domain.Entities.ProductCategories;
|
||||||
|
|
||||||
|
namespace Netina.Core.EntityServices.DiscountHandlers;
|
||||||
|
|
||||||
public class CalculateOrderDiscountCommandHandler(
|
public class CalculateOrderDiscountCommandHandler(
|
||||||
IRepositoryWrapper repositoryWrapper,
|
IRepositoryWrapper repositoryWrapper,
|
||||||
|
@ -51,8 +53,12 @@ public class CalculateOrderDiscountCommandHandler(
|
||||||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||||
if ( categoryDiscount!=null && !categoryDiscount.IsExpired())
|
if ( categoryDiscount!=null && !categoryDiscount.IsExpired())
|
||||||
{
|
{
|
||||||
totalPrice = request.Order.OrderProducts.Where(op => op.ProductCategoryId == categoryDiscount.CategoryId).Sum(op => op.ProductCost);
|
var subCats = await repositoryWrapper.SetRepository<ProductCategory>().TableNoTracking
|
||||||
|
.Where(c => c.ParentId == categoryDiscount.CategoryId)
|
||||||
|
.Select(c => c.Id)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
|
subCats.Add(categoryDiscount.CategoryId);
|
||||||
|
totalPrice = request.Order.OrderProducts.Where(op => subCats.Contains(op.ProductCategoryId)).Sum(op => op.ProductCost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (discount.Type == DiscountType.Product)
|
else if (discount.Type == DiscountType.Product)
|
||||||
|
|
|
@ -68,6 +68,12 @@ public class CalculateProductDiscountCommandHandler(IRepositoryWrapper repositor
|
||||||
request.DiscountPercent = request.Cost == 0 ? 0 : 100 - 100 * request.CostWithDiscount / request.Cost;
|
request.DiscountPercent = request.Cost == 0 ? 0 : 100 - 100 * request.CostWithDiscount / request.Cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.DiscountPercent == 0)
|
||||||
|
{
|
||||||
|
request.CostWithDiscount = 0;
|
||||||
|
request.HasDiscount = false;
|
||||||
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,17 @@ public class CalculateOrderCommandHandler(IRepositoryWrapper repositoryWrapper,
|
||||||
var deliveryPrice = order.OrderDelivery?.DeliveryCost ?? 0;
|
var deliveryPrice = order.OrderDelivery?.DeliveryCost ?? 0;
|
||||||
double productDiscountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
double productDiscountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
||||||
double discountCodePrice = 0;
|
double discountCodePrice = 0;
|
||||||
if (!order.DiscountCode.IsNullOrEmpty())
|
|
||||||
discountCodePrice += await mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),cancellationToken);
|
try
|
||||||
|
{
|
||||||
|
if (!order.DiscountCode.IsNullOrEmpty())
|
||||||
|
discountCodePrice += await mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),
|
||||||
|
cancellationToken);
|
||||||
|
}
|
||||||
|
catch (Exception )
|
||||||
|
{
|
||||||
|
order.RemoveDiscount();
|
||||||
|
}
|
||||||
|
|
||||||
var taxesPrice = (((totalProductPrice - (discountCodePrice + productDiscountPrice)) + totalPackingPrice + servicePrice) / 100) * taxesFee;
|
var taxesPrice = (((totalProductPrice - (discountCodePrice + productDiscountPrice)) + totalPackingPrice + servicePrice) / 100) * taxesFee;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ public class BlogLDto : BaseDto<BlogLDto , Blog>
|
||||||
public string Summery { get; set; } = string.Empty;
|
public string Summery { get; set; } = string.Empty;
|
||||||
public string MainImage { get; set; } = string.Empty;
|
public string MainImage { get; set; } = string.Empty;
|
||||||
public bool IsSuggested { get; set; }
|
public bool IsSuggested { get; set; }
|
||||||
|
public float Rate { get; set; }
|
||||||
|
public int CommentCount { get; set; }
|
||||||
public Guid CategoryId { get; set; }
|
public Guid CategoryId { get; set; }
|
||||||
public string CategoryName { get; set; } = string.Empty;
|
public string CategoryName { get; set; } = string.Empty;
|
||||||
public Guid AuthorId { get; set; }
|
public Guid AuthorId { get; set; }
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class ProductLDto : BaseDto<ProductLDto,Product>
|
||||||
public double PackingCost { get; set; }
|
public double PackingCost { get; set; }
|
||||||
public int MaxOrderCount { get; set; }
|
public int MaxOrderCount { get; set; }
|
||||||
public int Stock { get; set; }
|
public int Stock { get; set; }
|
||||||
|
public float Rate { get; set; }
|
||||||
|
public int CommentCount { 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; }
|
||||||
|
|
|
@ -8,6 +8,8 @@ public class BlogSDto : BaseDto<BlogSDto , Blog>
|
||||||
public int ReadingTime { get; set; }
|
public int ReadingTime { get; set; }
|
||||||
public string Summery { get; set; } = string.Empty;
|
public string Summery { get; set; } = string.Empty;
|
||||||
public bool IsSuggested { get; set; }
|
public bool IsSuggested { get; set; }
|
||||||
|
public float Rate { get; set; }
|
||||||
|
public int CommentCount { get; set; }
|
||||||
public Guid CategoryId { get; set; }
|
public Guid CategoryId { get; set; }
|
||||||
public string CategoryName { get; set; } = string.Empty;
|
public string CategoryName { get; set; } = string.Empty;
|
||||||
public string MainImage { get; set; } = string.Empty;
|
public string MainImage { get; set; } = string.Empty;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class ProductSDto : BaseDto<ProductSDto, Product>
|
||||||
public bool BeDisplayed { get; set; }
|
public bool BeDisplayed { get; set; }
|
||||||
public double PackingCost { get; set; }
|
public double PackingCost { get; set; }
|
||||||
public float Rate { get; set; }
|
public float Rate { get; set; }
|
||||||
public int ReviewCount { get; set; }
|
public int CommentCount { get; set; }
|
||||||
public int Viewed { get; set; }
|
public int Viewed { get; set; }
|
||||||
public string MainImage { get; set; } = string.Empty;
|
public string MainImage { get; set; } = string.Empty;
|
||||||
public Guid CategoryId { get; set; }
|
public Guid CategoryId { get; set; }
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace Netina.Domain.Mappers
|
||||||
BeDisplayed = p1.BeDisplayed,
|
BeDisplayed = p1.BeDisplayed,
|
||||||
PackingCost = p1.PackingCost,
|
PackingCost = p1.PackingCost,
|
||||||
Stock = p1.Stock,
|
Stock = p1.Stock,
|
||||||
|
Rate = p1.Rate,
|
||||||
HasExpressDelivery = p1.HasExpressDelivery,
|
HasExpressDelivery = p1.HasExpressDelivery,
|
||||||
MaxOrderCount = p1.MaxOrderCount,
|
MaxOrderCount = p1.MaxOrderCount,
|
||||||
BrandId = p1.BrandId,
|
BrandId = p1.BrandId,
|
||||||
|
@ -67,6 +68,7 @@ namespace Netina.Domain.Mappers
|
||||||
result.BeDisplayed = p4.BeDisplayed;
|
result.BeDisplayed = p4.BeDisplayed;
|
||||||
result.PackingCost = p4.PackingCost;
|
result.PackingCost = p4.PackingCost;
|
||||||
result.Stock = p4.Stock;
|
result.Stock = p4.Stock;
|
||||||
|
result.Rate = p4.Rate;
|
||||||
result.HasExpressDelivery = p4.HasExpressDelivery;
|
result.HasExpressDelivery = p4.HasExpressDelivery;
|
||||||
result.MaxOrderCount = p4.MaxOrderCount;
|
result.MaxOrderCount = p4.MaxOrderCount;
|
||||||
result.BrandId = p4.BrandId;
|
result.BrandId = p4.BrandId;
|
||||||
|
@ -95,6 +97,7 @@ namespace Netina.Domain.Mappers
|
||||||
BeDisplayed = p16.BeDisplayed,
|
BeDisplayed = p16.BeDisplayed,
|
||||||
PackingCost = p16.PackingCost,
|
PackingCost = p16.PackingCost,
|
||||||
Stock = p16.Stock,
|
Stock = p16.Stock,
|
||||||
|
Rate = p16.Rate,
|
||||||
HasExpressDelivery = p16.HasExpressDelivery,
|
HasExpressDelivery = p16.HasExpressDelivery,
|
||||||
MaxOrderCount = p16.MaxOrderCount,
|
MaxOrderCount = p16.MaxOrderCount,
|
||||||
BrandId = p16.BrandId,
|
BrandId = p16.BrandId,
|
||||||
|
@ -149,6 +152,8 @@ namespace Netina.Domain.Mappers
|
||||||
PackingCost = p19.PackingCost,
|
PackingCost = p19.PackingCost,
|
||||||
MaxOrderCount = p19.MaxOrderCount,
|
MaxOrderCount = p19.MaxOrderCount,
|
||||||
Stock = p19.Stock,
|
Stock = p19.Stock,
|
||||||
|
Rate = (float)(p19.Rate == 0f ? 4.5d : (double)p19.Rate),
|
||||||
|
CommentCount = p19.ReviewCount,
|
||||||
BrandId = p19.BrandId,
|
BrandId = p19.BrandId,
|
||||||
BrandName = p19.Brand == null ? null : p19.Brand.PersianName,
|
BrandName = p19.Brand == null ? null : p19.Brand.PersianName,
|
||||||
CategoryId = p19.CategoryId,
|
CategoryId = p19.CategoryId,
|
||||||
|
@ -182,6 +187,8 @@ namespace Netina.Domain.Mappers
|
||||||
result.PackingCost = p22.PackingCost;
|
result.PackingCost = p22.PackingCost;
|
||||||
result.MaxOrderCount = p22.MaxOrderCount;
|
result.MaxOrderCount = p22.MaxOrderCount;
|
||||||
result.Stock = p22.Stock;
|
result.Stock = p22.Stock;
|
||||||
|
result.Rate = (float)(p22.Rate == 0f ? 4.5d : (double)p22.Rate);
|
||||||
|
result.CommentCount = p22.ReviewCount;
|
||||||
result.BrandId = p22.BrandId;
|
result.BrandId = p22.BrandId;
|
||||||
result.BrandName = p22.Brand == null ? null : p22.Brand.PersianName;
|
result.BrandName = p22.Brand == null ? null : p22.Brand.PersianName;
|
||||||
result.CategoryId = p22.CategoryId;
|
result.CategoryId = p22.CategoryId;
|
||||||
|
@ -210,6 +217,8 @@ namespace Netina.Domain.Mappers
|
||||||
PackingCost = p28.PackingCost,
|
PackingCost = p28.PackingCost,
|
||||||
MaxOrderCount = p28.MaxOrderCount,
|
MaxOrderCount = p28.MaxOrderCount,
|
||||||
Stock = p28.Stock,
|
Stock = p28.Stock,
|
||||||
|
Rate = (float)(p28.Rate == 0f ? 4.5d : (double)p28.Rate),
|
||||||
|
CommentCount = p28.ReviewCount,
|
||||||
BrandId = p28.BrandId,
|
BrandId = p28.BrandId,
|
||||||
BrandName = p28.Brand == null ? null : p28.Brand.PersianName,
|
BrandName = p28.Brand == null ? null : p28.Brand.PersianName,
|
||||||
CategoryId = p28.CategoryId,
|
CategoryId = p28.CategoryId,
|
||||||
|
@ -257,7 +266,6 @@ namespace Netina.Domain.Mappers
|
||||||
PackingCost = p31.PackingCost,
|
PackingCost = p31.PackingCost,
|
||||||
Stock = p31.Stock,
|
Stock = p31.Stock,
|
||||||
Rate = p31.Rate,
|
Rate = p31.Rate,
|
||||||
ReviewCount = p31.ReviewCount,
|
|
||||||
Viewed = p31.Viewed,
|
Viewed = p31.Viewed,
|
||||||
MaxOrderCount = p31.MaxOrderCount,
|
MaxOrderCount = p31.MaxOrderCount,
|
||||||
BrandId = p31.BrandId,
|
BrandId = p31.BrandId,
|
||||||
|
@ -296,7 +304,6 @@ namespace Netina.Domain.Mappers
|
||||||
result.PackingCost = p32.PackingCost;
|
result.PackingCost = p32.PackingCost;
|
||||||
result.Stock = p32.Stock;
|
result.Stock = p32.Stock;
|
||||||
result.Rate = p32.Rate;
|
result.Rate = p32.Rate;
|
||||||
result.ReviewCount = p32.ReviewCount;
|
|
||||||
result.Viewed = p32.Viewed;
|
result.Viewed = p32.Viewed;
|
||||||
result.MaxOrderCount = p32.MaxOrderCount;
|
result.MaxOrderCount = p32.MaxOrderCount;
|
||||||
result.BrandId = p32.BrandId;
|
result.BrandId = p32.BrandId;
|
||||||
|
@ -328,8 +335,8 @@ namespace Netina.Domain.Mappers
|
||||||
MaxOrderCount = p40.MaxOrderCount,
|
MaxOrderCount = p40.MaxOrderCount,
|
||||||
BeDisplayed = p40.BeDisplayed,
|
BeDisplayed = p40.BeDisplayed,
|
||||||
PackingCost = p40.PackingCost,
|
PackingCost = p40.PackingCost,
|
||||||
Rate = p40.Rate,
|
Rate = (float)(p40.Rate == 0f ? 4.5d : (double)p40.Rate),
|
||||||
ReviewCount = p40.ReviewCount,
|
CommentCount = p40.ReviewCount,
|
||||||
Viewed = p40.Viewed,
|
Viewed = p40.Viewed,
|
||||||
MainImage = p40.Files.FirstOrDefault<ProductStorageFile>(funcMain15) != null ? p40.Files.FirstOrDefault<ProductStorageFile>(funcMain16).FileLocation : (p40.Files.Count > 0 ? p40.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
MainImage = p40.Files.FirstOrDefault<ProductStorageFile>(funcMain15) != null ? p40.Files.FirstOrDefault<ProductStorageFile>(funcMain16).FileLocation : (p40.Files.Count > 0 ? p40.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
||||||
CategoryId = p40.CategoryId,
|
CategoryId = p40.CategoryId,
|
||||||
|
@ -364,8 +371,8 @@ namespace Netina.Domain.Mappers
|
||||||
result.MaxOrderCount = p41.MaxOrderCount;
|
result.MaxOrderCount = p41.MaxOrderCount;
|
||||||
result.BeDisplayed = p41.BeDisplayed;
|
result.BeDisplayed = p41.BeDisplayed;
|
||||||
result.PackingCost = p41.PackingCost;
|
result.PackingCost = p41.PackingCost;
|
||||||
result.Rate = p41.Rate;
|
result.Rate = (float)(p41.Rate == 0f ? 4.5d : (double)p41.Rate);
|
||||||
result.ReviewCount = p41.ReviewCount;
|
result.CommentCount = p41.ReviewCount;
|
||||||
result.Viewed = p41.Viewed;
|
result.Viewed = p41.Viewed;
|
||||||
result.MainImage = p41.Files.FirstOrDefault<ProductStorageFile>(funcMain15) != null ? p41.Files.FirstOrDefault<ProductStorageFile>(funcMain16).FileLocation : (p41.Files.Count > 0 ? p41.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty);
|
result.MainImage = p41.Files.FirstOrDefault<ProductStorageFile>(funcMain15) != null ? p41.Files.FirstOrDefault<ProductStorageFile>(funcMain16).FileLocation : (p41.Files.Count > 0 ? p41.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty);
|
||||||
result.CategoryId = p41.CategoryId;
|
result.CategoryId = p41.CategoryId;
|
||||||
|
@ -395,8 +402,8 @@ namespace Netina.Domain.Mappers
|
||||||
MaxOrderCount = p43.MaxOrderCount,
|
MaxOrderCount = p43.MaxOrderCount,
|
||||||
BeDisplayed = p43.BeDisplayed,
|
BeDisplayed = p43.BeDisplayed,
|
||||||
PackingCost = p43.PackingCost,
|
PackingCost = p43.PackingCost,
|
||||||
Rate = p43.Rate,
|
Rate = (float)(p43.Rate == 0f ? 4.5d : (double)p43.Rate),
|
||||||
ReviewCount = p43.ReviewCount,
|
CommentCount = p43.ReviewCount,
|
||||||
Viewed = p43.Viewed,
|
Viewed = p43.Viewed,
|
||||||
MainImage = p43.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary) != null ? p43.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary).FileLocation : (p43.Files.Count > 0 ? p43.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
MainImage = p43.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary) != null ? p43.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary).FileLocation : (p43.Files.Count > 0 ? p43.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
||||||
CategoryId = p43.CategoryId,
|
CategoryId = p43.CategoryId,
|
||||||
|
|
|
@ -63,6 +63,8 @@ public class MapsterRegister : IRegister
|
||||||
.Map("MainImage", o => o.Files.FirstOrDefault(f => f.IsPrimary) != null ? o.Files.FirstOrDefault(f => f.IsPrimary).FileLocation : o.Files.Count > 0 ? o.Files.FirstOrDefault().FileLocation : string.Empty)
|
.Map("MainImage", o => o.Files.FirstOrDefault(f => f.IsPrimary) != null ? o.Files.FirstOrDefault(f => f.IsPrimary).FileLocation : o.Files.Count > 0 ? o.Files.FirstOrDefault().FileLocation : string.Empty)
|
||||||
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
|
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
|
||||||
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
||||||
|
.Map(d=>d.Rate , o=>o.Rate == 0 ? 4.5 : o.Rate)
|
||||||
|
.Map(d => d.CommentCount, o => o.ReviewCount)
|
||||||
.IgnoreNullValues(false)
|
.IgnoreNullValues(false)
|
||||||
.TwoWays();
|
.TwoWays();
|
||||||
|
|
||||||
|
@ -79,6 +81,8 @@ public class MapsterRegister : IRegister
|
||||||
.Map(o => o.AuthorFullName, d => d.Author != null ? d.Author.FirstName + " " + d.Author.LastName : string.Empty)
|
.Map(o => o.AuthorFullName, d => d.Author != null ? d.Author.FirstName + " " + d.Author.LastName : string.Empty)
|
||||||
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
|
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
|
||||||
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
||||||
|
.Map(d => d.Rate, o => o.Rate == 0 ? 4.5 : o.Rate)
|
||||||
|
.Map(d => d.CommentCount, o => o.ReviewCount)
|
||||||
.IgnoreNullValues(false)
|
.IgnoreNullValues(false)
|
||||||
.TwoWays();
|
.TwoWays();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Netina.Repository.Handlers.Discounts;
|
using BaseApiException = Netina.Common.Models.Exception.BaseApiException;
|
||||||
|
|
||||||
|
namespace Netina.Repository.Handlers.Discounts;
|
||||||
|
|
||||||
public class CreateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
|
public class CreateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||||
: IRequestHandler<CreateDiscountCommand, DiscountLDto>
|
: IRequestHandler<CreateDiscountCommand, DiscountLDto>
|
||||||
|
@ -15,35 +17,42 @@ public class CreateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||||
if (foundDiscount != null)
|
if (foundDiscount != null)
|
||||||
throw new BaseApiException(ApiResultStatusCode.BadRequest, "کد تخفیف مورد نظر تکراری می باشد");
|
throw new BaseApiException(ApiResultStatusCode.BadRequest, "کد تخفیف مورد نظر تکراری می باشد");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request is { AmountType: DiscountAmountType.Percent, DiscountPercent: 0 })
|
||||||
|
throw new BaseApiException(ApiResultStatusCode.BadRequest, "در تخفیف درصدی ، درصد تخفیف نمی تواند صفر باشد");
|
||||||
|
|
||||||
|
if (request is { AmountType: DiscountAmountType.Amount, DiscountAmount: 0 })
|
||||||
|
throw new BaseApiException(ApiResultStatusCode.BadRequest, "در تخفیف مبلغی ، مبلغ تخفیف نمی تواند صفر باشد");
|
||||||
|
|
||||||
switch (request.Type)
|
switch (request.Type)
|
||||||
{
|
{
|
||||||
case DiscountType.All:
|
case DiscountType.All:
|
||||||
var ent = Discount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount,
|
var ent = Discount.Create(request.Code, request.Description, request.DiscountPercent, request.DiscountAmount,
|
||||||
request.HasCode, request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate,
|
request.HasCode, request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate,
|
||||||
request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling,
|
request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling,
|
||||||
request.IsInfinity, request.UseCount, request.IsForInvitation,request.IsForFirstPurchase,request.IsSpecialOffer);
|
request.IsInfinity, request.UseCount, request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer);
|
||||||
repositoryWrapper.SetRepository<Discount>().Add(ent);
|
repositoryWrapper.SetRepository<Discount>().Add(ent);
|
||||||
break;
|
break;
|
||||||
case DiscountType.Category:
|
case DiscountType.Category:
|
||||||
var catDis = CategoryDiscount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
var catDis = CategoryDiscount.Create(request.Code, request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||||
request.AmountType, request.Type, request.Count,request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
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.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||||
request.IsForInvitation,request.IsForFirstPurchase,request.IsSpecialOffer, request.CategoryId);
|
request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.CategoryId);
|
||||||
repositoryWrapper.SetRepository<CategoryDiscount>().Add(catDis);
|
repositoryWrapper.SetRepository<CategoryDiscount>().Add(catDis);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DiscountType.Product:
|
case DiscountType.Product:
|
||||||
var productDis = ProductDiscount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
var productDis = ProductDiscount.Create(request.Code, request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
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.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||||
request.IsForInvitation,request.IsForFirstPurchase, request.IsSpecialOffer,request.ProductId);
|
request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer, request.ProductId);
|
||||||
repositoryWrapper.SetRepository<ProductDiscount>().Add(productDis);
|
repositoryWrapper.SetRepository<ProductDiscount>().Add(productDis);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var def = Discount.Create(request.Code,request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
var def = Discount.Create(request.Code, request.Description, request.DiscountPercent, request.DiscountAmount, request.HasCode,
|
||||||
request.AmountType, request.Type, request.Count, request.IsImmortal, request.StartDate, request.ExpireDate, request.PriceFloor,
|
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.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount,
|
||||||
request.IsForInvitation, request.IsForFirstPurchase,request.IsSpecialOffer);
|
request.IsForInvitation, request.IsForFirstPurchase, request.IsSpecialOffer);
|
||||||
repositoryWrapper.SetRepository<Discount>().Add(def);
|
repositoryWrapper.SetRepository<Discount>().Add(def);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue