feat : add english name for brands , add displayed change for products
parent
118888eb68
commit
ccce08d389
|
@ -26,6 +26,10 @@ public class ProductController : ICarterModule
|
||||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
|
group.MapPut("{productId}", ChangeDisplayedAsync)
|
||||||
|
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||||
|
.HasApiVersion(1.0);
|
||||||
|
|
||||||
group.MapDelete("{id}", Delete)
|
group.MapDelete("{id}", Delete)
|
||||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||||
.HasApiVersion(1.0);
|
.HasApiVersion(1.0);
|
||||||
|
@ -49,6 +53,9 @@ public class ProductController : ICarterModule
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(request, cancellationToken));
|
||||||
|
|
||||||
|
public async Task<IResult> ChangeDisplayedAsync(Guid productId, [FromQuery]bool beDisplayed, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||||
|
=> TypedResults.Ok(await mediator.Send(new ChangeProductDisplayedCommand(productId, beDisplayed), cancellationToken));
|
||||||
|
|
||||||
// DELETE:Delete Entity
|
// DELETE:Delete Entity
|
||||||
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
|
public async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken)
|
||||||
=> TypedResults.Ok(await mediator.Send(new DeleteProductCommand(id), cancellationToken));
|
=> TypedResults.Ok(await mediator.Send(new DeleteProductCommand(id), cancellationToken));
|
||||||
|
|
|
@ -65,13 +65,13 @@ public class SeedController : ICarterModule
|
||||||
if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==")
|
if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==")
|
||||||
throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized);
|
throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized);
|
||||||
Dictionary<int, Guid> brands = new Dictionary<int, Guid>();
|
Dictionary<int, Guid> brands = new Dictionary<int, Guid>();
|
||||||
var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند", "محصولات بدون برند", false,string.Empty,
|
var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند","NoBrand", "محصولات بدون برند", false,string.Empty,
|
||||||
new List<StorageFileSDto>()));
|
new List<StorageFileSDto>()), cancellationToken);
|
||||||
brands.Add(0, baseBrand.Id);
|
brands.Add(0, baseBrand.Id);
|
||||||
foreach (var requestDto in request)
|
foreach (var requestDto in request)
|
||||||
{
|
{
|
||||||
var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name, requestDto.Description, false,
|
var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name,string.Empty, requestDto.Description, false,
|
||||||
string.Empty, new List<StorageFileSDto>()));
|
string.Empty, new List<StorageFileSDto>()), cancellationToken);
|
||||||
brands.Add(requestDto.BaseBrandId,sDto.Id);
|
brands.Add(requestDto.BaseBrandId,sDto.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
namespace NetinaShop.Domain.CommandQueries.Commands;
|
namespace NetinaShop.Domain.CommandQueries.Commands;
|
||||||
|
|
||||||
public sealed record CreateBrandCommand(string Name,string Description , bool HasSpecialPage , string PageUrl, List<StorageFileSDto> Files) : IRequest<BrandSDto>;
|
public sealed record CreateBrandCommand(string PersianName,string EnglishName, string Description , bool HasSpecialPage , string PageUrl, List<StorageFileSDto> Files) : IRequest<BrandSDto>;
|
||||||
|
|
||||||
public sealed record UpdateBrandCommand(Guid Id, string Name, string Description, bool HasSpecialPage, string PageUrl, List<StorageFileSDto> Files) : IRequest<bool>;
|
public sealed record UpdateBrandCommand(Guid Id,string PersianName, string EnglishName, string Description, bool HasSpecialPage, string PageUrl, List<StorageFileSDto> Files) : IRequest<bool>;
|
||||||
|
|
||||||
public sealed record DeleteBrandCommand(Guid Id) : IRequest<bool>;
|
public sealed record DeleteBrandCommand(Guid Id) : IRequest<bool>;
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ public sealed record UpdateProductCommand(
|
||||||
List<SpecificationSDto> Specifications,
|
List<SpecificationSDto> Specifications,
|
||||||
List<StorageFileSDto> Files) : IRequest<bool>;
|
List<StorageFileSDto> Files) : IRequest<bool>;
|
||||||
|
|
||||||
|
public sealed record ChangeProductDisplayedCommand(Guid Id,bool BeDisplayed) : IRequest<bool>;
|
||||||
|
|
||||||
public sealed record DeleteProductCommand(Guid Id) : IRequest<bool>;
|
public sealed record DeleteProductCommand(Guid Id) : IRequest<bool>;
|
||||||
|
|
||||||
public sealed record CalculateProductDiscountCommand(object Product) : IRequest<bool>;
|
public sealed record CalculateProductDiscountCommand(object Product) : IRequest<bool>;
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
public class BrandLDto : BaseDto<BrandLDto,Brand>
|
public class BrandLDto : BaseDto<BrandLDto,Brand>
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string PersianName { get; set; } = string.Empty;
|
||||||
|
public string EnglishName { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public bool HasSpecialPage { get; set; }
|
public bool HasSpecialPage { get; set; }
|
||||||
public string PageUrl { get; set; } = string.Empty;
|
public string PageUrl { get; set; } = string.Empty;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
public class BrandSDto : BaseDto<BrandSDto , Brand>
|
public class BrandSDto : BaseDto<BrandSDto , Brand>
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string PersianName { get; set; } = string.Empty;
|
||||||
|
public string EnglishName { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public bool HasSpecialPage { get; set; }
|
public bool HasSpecialPage { get; set; }
|
||||||
public string PageUrl { get; set; } = string.Empty;
|
public string PageUrl { get; set; } = string.Empty;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
public partial class Brand
|
public partial class Brand
|
||||||
{
|
{
|
||||||
public static Brand Create(string name, string description, bool hasSpecialPage, string pageUrl)
|
public static Brand Create(string persianName, string englishName, string description, bool hasSpecialPage, string pageUrl)
|
||||||
{
|
{
|
||||||
return new Brand( name, description, hasSpecialPage, pageUrl);
|
return new Brand(persianName,englishName, description, hasSpecialPage, pageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrandStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
public BrandStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
|
||||||
|
|
|
@ -12,14 +12,16 @@ public partial class Brand : ApiEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Brand(string name, string description, bool hasSpecialPage, string pageUrl)
|
public Brand(string persianName,string englishName, string description, bool hasSpecialPage, string pageUrl)
|
||||||
{
|
{
|
||||||
Name = name;
|
PersianName = persianName;
|
||||||
|
EnglishName = englishName;
|
||||||
Description = description;
|
Description = description;
|
||||||
HasSpecialPage = hasSpecialPage;
|
HasSpecialPage = hasSpecialPage;
|
||||||
PageUrl = pageUrl;
|
PageUrl = pageUrl;
|
||||||
}
|
}
|
||||||
public string Name { get; internal set; } = string.Empty;
|
public string PersianName { get; internal set; } = string.Empty;
|
||||||
|
public string EnglishName { get; internal set; } = string.Empty;
|
||||||
public string Description { get; internal set; } = string.Empty;
|
public string Description { get; internal set; } = string.Empty;
|
||||||
public bool HasSpecialPage { get; internal set; }
|
public bool HasSpecialPage { get; internal set; }
|
||||||
public string PageUrl { get; internal set; } = string.Empty;
|
public string PageUrl { get; internal set; } = string.Empty;
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
return p1 == null ? null : new Brand()
|
return p1 == null ? null : new Brand()
|
||||||
{
|
{
|
||||||
Name = p1.Name,
|
PersianName = p1.PersianName,
|
||||||
|
EnglishName = p1.EnglishName,
|
||||||
Description = p1.Description,
|
Description = p1.Description,
|
||||||
HasSpecialPage = p1.HasSpecialPage,
|
HasSpecialPage = p1.HasSpecialPage,
|
||||||
PageUrl = p1.PageUrl,
|
PageUrl = p1.PageUrl,
|
||||||
|
@ -31,7 +32,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
Brand result = p4 ?? new Brand();
|
Brand result = p4 ?? new Brand();
|
||||||
|
|
||||||
result.Name = p3.Name;
|
result.PersianName = p3.PersianName;
|
||||||
|
result.EnglishName = p3.EnglishName;
|
||||||
result.Description = p3.Description;
|
result.Description = p3.Description;
|
||||||
result.HasSpecialPage = p3.HasSpecialPage;
|
result.HasSpecialPage = p3.HasSpecialPage;
|
||||||
result.PageUrl = p3.PageUrl;
|
result.PageUrl = p3.PageUrl;
|
||||||
|
@ -43,7 +45,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
public static Expression<Func<BrandLDto, Brand>> ProjectToBrand => p7 => new Brand()
|
public static Expression<Func<BrandLDto, Brand>> ProjectToBrand => p7 => new Brand()
|
||||||
{
|
{
|
||||||
Name = p7.Name,
|
PersianName = p7.PersianName,
|
||||||
|
EnglishName = p7.EnglishName,
|
||||||
Description = p7.Description,
|
Description = p7.Description,
|
||||||
HasSpecialPage = p7.HasSpecialPage,
|
HasSpecialPage = p7.HasSpecialPage,
|
||||||
PageUrl = p7.PageUrl,
|
PageUrl = p7.PageUrl,
|
||||||
|
@ -65,7 +68,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
return p9 == null ? null : new BrandLDto()
|
return p9 == null ? null : new BrandLDto()
|
||||||
{
|
{
|
||||||
Name = p9.Name,
|
PersianName = p9.PersianName,
|
||||||
|
EnglishName = p9.EnglishName,
|
||||||
Description = p9.Description,
|
Description = p9.Description,
|
||||||
HasSpecialPage = p9.HasSpecialPage,
|
HasSpecialPage = p9.HasSpecialPage,
|
||||||
PageUrl = p9.PageUrl,
|
PageUrl = p9.PageUrl,
|
||||||
|
@ -82,7 +86,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
BrandLDto result = p12 ?? new BrandLDto();
|
BrandLDto result = p12 ?? new BrandLDto();
|
||||||
|
|
||||||
result.Name = p11.Name;
|
result.PersianName = p11.PersianName;
|
||||||
|
result.EnglishName = p11.EnglishName;
|
||||||
result.Description = p11.Description;
|
result.Description = p11.Description;
|
||||||
result.HasSpecialPage = p11.HasSpecialPage;
|
result.HasSpecialPage = p11.HasSpecialPage;
|
||||||
result.PageUrl = p11.PageUrl;
|
result.PageUrl = p11.PageUrl;
|
||||||
|
@ -94,7 +99,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
public static Expression<Func<Brand, BrandLDto>> ProjectToLDto => p15 => new BrandLDto()
|
public static Expression<Func<Brand, BrandLDto>> ProjectToLDto => p15 => new BrandLDto()
|
||||||
{
|
{
|
||||||
Name = p15.Name,
|
PersianName = p15.PersianName,
|
||||||
|
EnglishName = p15.EnglishName,
|
||||||
Description = p15.Description,
|
Description = p15.Description,
|
||||||
HasSpecialPage = p15.HasSpecialPage,
|
HasSpecialPage = p15.HasSpecialPage,
|
||||||
PageUrl = p15.PageUrl,
|
PageUrl = p15.PageUrl,
|
||||||
|
@ -115,7 +121,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
return p17 == null ? null : new Brand()
|
return p17 == null ? null : new Brand()
|
||||||
{
|
{
|
||||||
Name = p17.Name,
|
PersianName = p17.PersianName,
|
||||||
|
EnglishName = p17.EnglishName,
|
||||||
Description = p17.Description,
|
Description = p17.Description,
|
||||||
HasSpecialPage = p17.HasSpecialPage,
|
HasSpecialPage = p17.HasSpecialPage,
|
||||||
PageUrl = p17.PageUrl,
|
PageUrl = p17.PageUrl,
|
||||||
|
@ -131,7 +138,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
Brand result = p19 ?? new Brand();
|
Brand result = p19 ?? new Brand();
|
||||||
|
|
||||||
result.Name = p18.Name;
|
result.PersianName = p18.PersianName;
|
||||||
|
result.EnglishName = p18.EnglishName;
|
||||||
result.Description = p18.Description;
|
result.Description = p18.Description;
|
||||||
result.HasSpecialPage = p18.HasSpecialPage;
|
result.HasSpecialPage = p18.HasSpecialPage;
|
||||||
result.PageUrl = p18.PageUrl;
|
result.PageUrl = p18.PageUrl;
|
||||||
|
@ -144,7 +152,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
return p20 == null ? null : new BrandSDto()
|
return p20 == null ? null : new BrandSDto()
|
||||||
{
|
{
|
||||||
Name = p20.Name,
|
PersianName = p20.PersianName,
|
||||||
|
EnglishName = p20.EnglishName,
|
||||||
Description = p20.Description,
|
Description = p20.Description,
|
||||||
HasSpecialPage = p20.HasSpecialPage,
|
HasSpecialPage = p20.HasSpecialPage,
|
||||||
PageUrl = p20.PageUrl,
|
PageUrl = p20.PageUrl,
|
||||||
|
@ -161,7 +170,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
BrandSDto result = p22 ?? new BrandSDto();
|
BrandSDto result = p22 ?? new BrandSDto();
|
||||||
|
|
||||||
result.Name = p21.Name;
|
result.PersianName = p21.PersianName;
|
||||||
|
result.EnglishName = p21.EnglishName;
|
||||||
result.Description = p21.Description;
|
result.Description = p21.Description;
|
||||||
result.HasSpecialPage = p21.HasSpecialPage;
|
result.HasSpecialPage = p21.HasSpecialPage;
|
||||||
result.PageUrl = p21.PageUrl;
|
result.PageUrl = p21.PageUrl;
|
||||||
|
@ -173,7 +183,8 @@ namespace NetinaShop.Domain.Mappers
|
||||||
}
|
}
|
||||||
public static Expression<Func<Brand, BrandSDto>> ProjectToSDto => p23 => new BrandSDto()
|
public static Expression<Func<Brand, BrandSDto>> ProjectToSDto => p23 => new BrandSDto()
|
||||||
{
|
{
|
||||||
Name = p23.Name,
|
PersianName = p23.PersianName,
|
||||||
|
EnglishName = p23.EnglishName,
|
||||||
Description = p23.Description,
|
Description = p23.Description,
|
||||||
HasSpecialPage = p23.HasSpecialPage,
|
HasSpecialPage = p23.HasSpecialPage,
|
||||||
PageUrl = p23.PageUrl,
|
PageUrl = p23.PageUrl,
|
||||||
|
|
|
@ -30,11 +30,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
HasExpressDelivery = p1.HasExpressDelivery,
|
HasExpressDelivery = p1.HasExpressDelivery,
|
||||||
MaxOrderCount = p1.MaxOrderCount,
|
MaxOrderCount = p1.MaxOrderCount,
|
||||||
BrandId = p1.BrandId,
|
BrandId = p1.BrandId,
|
||||||
Brand = new Brand()
|
Brand = new Brand() {Id = p1.BrandId},
|
||||||
{
|
|
||||||
Name = p1.BrandName,
|
|
||||||
Id = p1.BrandId
|
|
||||||
},
|
|
||||||
CategoryId = p1.CategoryId,
|
CategoryId = p1.CategoryId,
|
||||||
Category = new ProductCategory()
|
Category = new ProductCategory()
|
||||||
{
|
{
|
||||||
|
@ -95,11 +91,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
HasExpressDelivery = p17.HasExpressDelivery,
|
HasExpressDelivery = p17.HasExpressDelivery,
|
||||||
MaxOrderCount = p17.MaxOrderCount,
|
MaxOrderCount = p17.MaxOrderCount,
|
||||||
BrandId = p17.BrandId,
|
BrandId = p17.BrandId,
|
||||||
Brand = new Brand()
|
Brand = new Brand() {Id = p17.BrandId},
|
||||||
{
|
|
||||||
Name = p17.BrandName,
|
|
||||||
Id = p17.BrandId
|
|
||||||
},
|
|
||||||
CategoryId = p17.CategoryId,
|
CategoryId = p17.CategoryId,
|
||||||
Category = new ProductCategory()
|
Category = new ProductCategory()
|
||||||
{
|
{
|
||||||
|
@ -159,7 +151,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MaxOrderCount = p21.MaxOrderCount,
|
MaxOrderCount = p21.MaxOrderCount,
|
||||||
Stock = p21.Stock,
|
Stock = p21.Stock,
|
||||||
BrandId = p21.BrandId,
|
BrandId = p21.BrandId,
|
||||||
BrandName = p21.Brand == null ? null : p21.Brand.Name,
|
BrandName = p21.Brand == null ? null : p21.Brand.PersianName,
|
||||||
CategoryId = p21.CategoryId,
|
CategoryId = p21.CategoryId,
|
||||||
CategoryName = p21.Category == null ? null : p21.Category.Name,
|
CategoryName = p21.Category == null ? null : p21.Category.Name,
|
||||||
Specifications = funcMain9(p21.Specifications),
|
Specifications = funcMain9(p21.Specifications),
|
||||||
|
@ -190,7 +182,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
result.MaxOrderCount = p25.MaxOrderCount;
|
result.MaxOrderCount = p25.MaxOrderCount;
|
||||||
result.Stock = p25.Stock;
|
result.Stock = p25.Stock;
|
||||||
result.BrandId = p25.BrandId;
|
result.BrandId = p25.BrandId;
|
||||||
result.BrandName = p25.Brand == null ? null : p25.Brand.Name;
|
result.BrandName = p25.Brand == null ? null : p25.Brand.PersianName;
|
||||||
result.CategoryId = p25.CategoryId;
|
result.CategoryId = p25.CategoryId;
|
||||||
result.CategoryName = p25.Category == null ? null : p25.Category.Name;
|
result.CategoryName = p25.Category == null ? null : p25.Category.Name;
|
||||||
result.Specifications = funcMain12(p25.Specifications, result.Specifications);
|
result.Specifications = funcMain12(p25.Specifications, result.Specifications);
|
||||||
|
@ -216,7 +208,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MaxOrderCount = p33.MaxOrderCount,
|
MaxOrderCount = p33.MaxOrderCount,
|
||||||
Stock = p33.Stock,
|
Stock = p33.Stock,
|
||||||
BrandId = p33.BrandId,
|
BrandId = p33.BrandId,
|
||||||
BrandName = p33.Brand == null ? null : p33.Brand.Name,
|
BrandName = p33.Brand == null ? null : p33.Brand.PersianName,
|
||||||
CategoryId = p33.CategoryId,
|
CategoryId = p33.CategoryId,
|
||||||
CategoryName = p33.Category == null ? null : p33.Category.Name,
|
CategoryName = p33.Category == null ? null : p33.Category.Name,
|
||||||
Specifications = p33.Specifications.Select<Specification, SpecificationSDto>(p34 => new SpecificationSDto()
|
Specifications = p33.Specifications.Select<Specification, SpecificationSDto>(p34 => new SpecificationSDto()
|
||||||
|
@ -274,11 +266,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
Viewed = p37.Viewed,
|
Viewed = p37.Viewed,
|
||||||
MaxOrderCount = p37.MaxOrderCount,
|
MaxOrderCount = p37.MaxOrderCount,
|
||||||
BrandId = p37.BrandId,
|
BrandId = p37.BrandId,
|
||||||
Brand = new Brand()
|
Brand = new Brand() {Id = p37.BrandId},
|
||||||
{
|
|
||||||
Name = p37.BrandName,
|
|
||||||
Id = p37.BrandId
|
|
||||||
},
|
|
||||||
CategoryId = p37.CategoryId,
|
CategoryId = p37.CategoryId,
|
||||||
Category = new ProductCategory()
|
Category = new ProductCategory()
|
||||||
{
|
{
|
||||||
|
@ -343,7 +331,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MainImage = p44.Files.FirstOrDefault<ProductStorageFile>(funcMain17) != null ? p44.Files.FirstOrDefault<ProductStorageFile>(funcMain18).FileLocation : (p44.Files.Count > 0 ? p44.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
MainImage = p44.Files.FirstOrDefault<ProductStorageFile>(funcMain17) != null ? p44.Files.FirstOrDefault<ProductStorageFile>(funcMain18).FileLocation : (p44.Files.Count > 0 ? p44.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
||||||
CategoryId = p44.CategoryId,
|
CategoryId = p44.CategoryId,
|
||||||
BrandId = p44.BrandId,
|
BrandId = p44.BrandId,
|
||||||
BrandName = p44.Brand == null ? null : p44.Brand.Name,
|
BrandName = p44.Brand == null ? null : p44.Brand.PersianName,
|
||||||
CategoryName = p44.Category == null ? null : p44.Category.Name,
|
CategoryName = p44.Category == null ? null : p44.Category.Name,
|
||||||
Id = p44.Id,
|
Id = p44.Id,
|
||||||
CreatedAt = p44.CreatedAt
|
CreatedAt = p44.CreatedAt
|
||||||
|
@ -375,7 +363,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
result.MainImage = p45.Files.FirstOrDefault<ProductStorageFile>(funcMain17) != null ? p45.Files.FirstOrDefault<ProductStorageFile>(funcMain18).FileLocation : (p45.Files.Count > 0 ? p45.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty);
|
result.MainImage = p45.Files.FirstOrDefault<ProductStorageFile>(funcMain17) != null ? p45.Files.FirstOrDefault<ProductStorageFile>(funcMain18).FileLocation : (p45.Files.Count > 0 ? p45.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty);
|
||||||
result.CategoryId = p45.CategoryId;
|
result.CategoryId = p45.CategoryId;
|
||||||
result.BrandId = p45.BrandId;
|
result.BrandId = p45.BrandId;
|
||||||
result.BrandName = p45.Brand == null ? null : p45.Brand.Name;
|
result.BrandName = p45.Brand == null ? null : p45.Brand.PersianName;
|
||||||
result.CategoryName = p45.Category == null ? null : p45.Category.Name;
|
result.CategoryName = p45.Category == null ? null : p45.Category.Name;
|
||||||
result.Id = p45.Id;
|
result.Id = p45.Id;
|
||||||
result.CreatedAt = p45.CreatedAt;
|
result.CreatedAt = p45.CreatedAt;
|
||||||
|
@ -402,7 +390,7 @@ namespace NetinaShop.Domain.Mappers
|
||||||
MainImage = p47.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary) != null ? p47.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary).FileLocation : (p47.Files.Count > 0 ? p47.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
MainImage = p47.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary) != null ? p47.Files.FirstOrDefault<ProductStorageFile>(f => f.IsPrimary).FileLocation : (p47.Files.Count > 0 ? p47.Files.FirstOrDefault<ProductStorageFile>().FileLocation : string.Empty),
|
||||||
CategoryId = p47.CategoryId,
|
CategoryId = p47.CategoryId,
|
||||||
BrandId = p47.BrandId,
|
BrandId = p47.BrandId,
|
||||||
BrandName = p47.Brand == null ? null : p47.Brand.Name,
|
BrandName = p47.Brand == null ? null : p47.Brand.PersianName,
|
||||||
CategoryName = p47.Category == null ? null : p47.Category.Name,
|
CategoryName = p47.Category == null ? null : p47.Category.Name,
|
||||||
Id = p47.Id,
|
Id = p47.Id,
|
||||||
CreatedAt = p47.CreatedAt
|
CreatedAt = p47.CreatedAt
|
||||||
|
@ -505,7 +493,6 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
Brand result = p8 ?? new Brand();
|
Brand result = p8 ?? new Brand();
|
||||||
|
|
||||||
result.Name = p5.BrandName;
|
|
||||||
result.Id = p5.BrandId;
|
result.Id = p5.BrandId;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -802,7 +789,6 @@ namespace NetinaShop.Domain.Mappers
|
||||||
{
|
{
|
||||||
Brand result = p41 ?? new Brand();
|
Brand result = p41 ?? new Brand();
|
||||||
|
|
||||||
result.Name = p38.BrandName;
|
|
||||||
result.Id = p38.BrandId;
|
result.Id = p38.BrandId;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class MapsterRegister : IRegister
|
||||||
config.NewConfig<Product, ProductSDto>()
|
config.NewConfig<Product, ProductSDto>()
|
||||||
.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.Name)
|
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
||||||
.IgnoreNullValues(false)
|
.IgnoreNullValues(false)
|
||||||
.TwoWays();
|
.TwoWays();
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class MapsterRegister : IRegister
|
||||||
|
|
||||||
config.NewConfig<Product, ProductLDto>()
|
config.NewConfig<Product, ProductLDto>()
|
||||||
.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.Name)
|
.Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName)
|
||||||
.IgnoreNullValues(false)
|
.IgnoreNullValues(false)
|
||||||
.TwoWays();
|
.TwoWays();
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class DigikalaScraper : IDigikalaScraper
|
||||||
{
|
{
|
||||||
var nonBrand = await _repositoryWrapper.SetRepository<Brand>()
|
var nonBrand = await _repositoryWrapper.SetRepository<Brand>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(b => b.Name == "بدون برند", cancellationToken);
|
.FirstOrDefaultAsync(b => b.PersianName == "بدون برند", cancellationToken);
|
||||||
if (nonBrand == null)
|
if (nonBrand == null)
|
||||||
throw new AppException("NoneBrand is not exist");
|
throw new AppException("NoneBrand is not exist");
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace NetinaShop.Repository.Handlers.Brands;
|
||||||
|
|
||||||
public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , BrandSDto>
|
public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , BrandSDto>
|
||||||
{
|
{
|
||||||
private IRepositoryWrapper _repositoryWrapper;
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||||
|
|
||||||
public CreateBrandCommandHandler(IRepositoryWrapper repositoryWrapper)
|
public CreateBrandCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , Br
|
||||||
}
|
}
|
||||||
public async Task<BrandSDto> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
|
public async Task<BrandSDto> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var ent = Brand.Create(request.Name, request.Description, request.HasSpecialPage, request.PageUrl);
|
var ent = Brand.Create(request.PersianName,request.EnglishName, request.Description, request.HasSpecialPage, request.PageUrl);
|
||||||
foreach (var file in request.Files)
|
foreach (var file in request.Files)
|
||||||
{
|
{
|
||||||
ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType);
|
ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class GetBrandsQueryHandler : IRequestHandler<GetBrandsQuery, List<BrandS
|
||||||
{
|
{
|
||||||
baseBrands = _repositoryWrapper.SetRepository<Brand>()
|
baseBrands = _repositoryWrapper.SetRepository<Brand>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.Where(b => b.Name.Trim().Contains(request.BrandName.Trim()))
|
.Where(b => b.PersianName.Trim().Contains(request.BrandName.Trim()))
|
||||||
.OrderByDescending(b => b.CreatedAt);
|
.OrderByDescending(b => b.CreatedAt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class UpdateBrandCommandHandler : IRequestHandler<UpdateBrandCommand,bool
|
||||||
.FirstOrDefaultAsync(b => b.Id == request.Id, cancellationToken);
|
.FirstOrDefaultAsync(b => b.Id == request.Id, cancellationToken);
|
||||||
if (ent == null)
|
if (ent == null)
|
||||||
throw new AppException("Brand not found");
|
throw new AppException("Brand not found");
|
||||||
var newEnt = Brand.Create(request.Name, request.Description, request.HasSpecialPage, request.PageUrl);
|
var newEnt = Brand.Create(request.PersianName,request.EnglishName, request.Description, request.HasSpecialPage, request.PageUrl);
|
||||||
newEnt.Id = ent.Id;
|
newEnt.Id = ent.Id;
|
||||||
newEnt.CreatedAt = ent.CreatedAt;
|
newEnt.CreatedAt = ent.CreatedAt;
|
||||||
newEnt.CreatedBy = ent.CreatedBy;
|
newEnt.CreatedBy = ent.CreatedBy;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace NetinaShop.Repository.Handlers.Products;
|
||||||
|
|
||||||
|
public class ChangeProductDisplayedCommandHandler : IRequestHandler<ChangeProductDisplayedCommand,bool>
|
||||||
|
{
|
||||||
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||||
|
|
||||||
|
public ChangeProductDisplayedCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||||
|
{
|
||||||
|
_repositoryWrapper = repositoryWrapper;
|
||||||
|
}
|
||||||
|
public async Task<bool> Handle(ChangeProductDisplayedCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var ent = await _repositoryWrapper.SetRepository<Product>()
|
||||||
|
.TableNoTracking
|
||||||
|
.FirstOrDefaultAsync(p => p.Id == request.Id, cancellationToken);
|
||||||
|
if (ent == null)
|
||||||
|
throw new AppException("Product not found");
|
||||||
|
var newEnt = Product.Create(ent.PersianName, ent.EnglishName, ent.Summery, ent.ExpertCheck, ent.Tags,
|
||||||
|
ent.Warranty,
|
||||||
|
request.BeDisplayed, ent.Cost, ent.PackingCost, ent.HasExpressDelivery, ent.Stock, ent.MaxOrderCount,
|
||||||
|
ent.BrandId,
|
||||||
|
ent.CategoryId);
|
||||||
|
newEnt.CreatedAt = ent.CreatedAt;
|
||||||
|
newEnt.CreatedBy = ent.CreatedBy;
|
||||||
|
newEnt.Id = ent.Id;
|
||||||
|
|
||||||
|
_repositoryWrapper.SetRepository<Product>()
|
||||||
|
.Update(newEnt);
|
||||||
|
|
||||||
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
1689
NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs
generated
100644
1689
NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,43 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace NetinaShop.Repository.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class EditBrandAddEnglishName : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Name",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands",
|
||||||
|
newName: "PersianName");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "EnglishName",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "EnglishName",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "PersianName",
|
||||||
|
schema: "public",
|
||||||
|
table: "Brands",
|
||||||
|
newName: "Name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -312,6 +312,10 @@ namespace NetinaShop.Repository.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("EnglishName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<bool>("HasSpecialPage")
|
b.Property<bool>("HasSpecialPage")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
@ -324,11 +328,11 @@ namespace NetinaShop.Repository.Migrations
|
||||||
b.Property<string>("ModifiedBy")
|
b.Property<string>("ModifiedBy")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("PageUrl")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("PageUrl")
|
b.Property<string>("PersianName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue