From ccce08d389ccbd76d9990c0b6d0819bea8b9d3df Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Thu, 22 Feb 2024 20:34:51 +0330 Subject: [PATCH] feat : add english name for brands , add displayed change for products --- .../Controller/ProductController.cs | 7 + NetinaShop.Api/Controller/SeedController.cs | 8 +- .../CommandQueries/Commands/BrandCommands.cs | 4 +- .../Commands/ProductCommands.cs | 2 + NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs | 3 +- NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs | 3 +- .../Entities/Brands/Brand.Aggregate.cs | 4 +- NetinaShop.Domain/Entities/Brands/Brand.cs | 8 +- NetinaShop.Domain/Mappers/BrandMapper.g.cs | 33 +- NetinaShop.Domain/Mappers/ProductMapper.g.cs | 32 +- NetinaShop.Domain/MapsterRegister.cs | 4 +- .../Services/Scrapers/DigikalaScraper.cs | 2 +- .../Brands/CreateBrandCommandHandler.cs | 4 +- .../Handlers/Brands/GetBrandsQueryHandler.cs | 2 +- .../Brands/UpdateBrandCommandHandler.cs | 2 +- .../ChangeProductDisplayedCommandHandler.cs | 35 + ...102310_EditBrandAddEnglishName.Designer.cs | 1689 +++++++++++++++++ .../20240222102310_EditBrandAddEnglishName.cs | 43 + .../ApplicationContextModelSnapshot.cs | 8 +- 19 files changed, 1837 insertions(+), 56 deletions(-) create mode 100644 NetinaShop.Repository/Handlers/Products/ChangeProductDisplayedCommandHandler.cs create mode 100644 NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs create mode 100644 NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.cs diff --git a/NetinaShop.Api/Controller/ProductController.cs b/NetinaShop.Api/Controller/ProductController.cs index 8c187e9..e0296d9 100644 --- a/NetinaShop.Api/Controller/ProductController.cs +++ b/NetinaShop.Api/Controller/ProductController.cs @@ -26,6 +26,10 @@ public class ProductController : ICarterModule .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); + group.MapPut("{productId}", ChangeDisplayedAsync) + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .HasApiVersion(1.0); + group.MapDelete("{id}", Delete) .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); @@ -49,6 +53,9 @@ public class ProductController : ICarterModule CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + public async Task ChangeDisplayedAsync(Guid productId, [FromQuery]bool beDisplayed, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new ChangeProductDisplayedCommand(productId, beDisplayed), cancellationToken)); + // DELETE:Delete Entity public async Task Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(new DeleteProductCommand(id), cancellationToken)); diff --git a/NetinaShop.Api/Controller/SeedController.cs b/NetinaShop.Api/Controller/SeedController.cs index 4b940f4..53d3ca4 100644 --- a/NetinaShop.Api/Controller/SeedController.cs +++ b/NetinaShop.Api/Controller/SeedController.cs @@ -65,13 +65,13 @@ public class SeedController : ICarterModule if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==") throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized); Dictionary brands = new Dictionary(); - var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند", "محصولات بدون برند", false,string.Empty, - new List())); + var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند","NoBrand", "محصولات بدون برند", false,string.Empty, + new List()), cancellationToken); brands.Add(0, baseBrand.Id); foreach (var requestDto in request) { - var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name, requestDto.Description, false, - string.Empty, new List())); + var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name,string.Empty, requestDto.Description, false, + string.Empty, new List()), cancellationToken); brands.Add(requestDto.BaseBrandId,sDto.Id); } diff --git a/NetinaShop.Domain/CommandQueries/Commands/BrandCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/BrandCommands.cs index f2621d6..dede498 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/BrandCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/BrandCommands.cs @@ -1,8 +1,8 @@ namespace NetinaShop.Domain.CommandQueries.Commands; -public sealed record CreateBrandCommand(string Name,string Description , bool HasSpecialPage , string PageUrl, List Files) : IRequest; +public sealed record CreateBrandCommand(string PersianName,string EnglishName, string Description , bool HasSpecialPage , string PageUrl, List Files) : IRequest; -public sealed record UpdateBrandCommand(Guid Id, string Name, string Description, bool HasSpecialPage, string PageUrl, List Files) : IRequest; +public sealed record UpdateBrandCommand(Guid Id,string PersianName, string EnglishName, string Description, bool HasSpecialPage, string PageUrl, List Files) : IRequest; public sealed record DeleteBrandCommand(Guid Id) : IRequest; diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs index c3b363f..1d298b7 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs @@ -41,6 +41,8 @@ public sealed record UpdateProductCommand( List Specifications, List Files) : IRequest; +public sealed record ChangeProductDisplayedCommand(Guid Id,bool BeDisplayed) : IRequest; + public sealed record DeleteProductCommand(Guid Id) : IRequest; public sealed record CalculateProductDiscountCommand(object Product) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs index 40dabfd..195276f 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs @@ -2,7 +2,8 @@ public class BrandLDto : BaseDto { - 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 bool HasSpecialPage { get; set; } public string PageUrl { get; set; } = string.Empty; diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs index 6aeb141..a59ec84 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs @@ -2,7 +2,8 @@ public class BrandSDto : BaseDto { - 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 bool HasSpecialPage { get; set; } public string PageUrl { get; set; } = string.Empty; diff --git a/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs b/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs index 83ac8f3..b557949 100644 --- a/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Brands/Brand.Aggregate.cs @@ -2,9 +2,9 @@ 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) diff --git a/NetinaShop.Domain/Entities/Brands/Brand.cs b/NetinaShop.Domain/Entities/Brands/Brand.cs index 638e011..7ef8cd8 100644 --- a/NetinaShop.Domain/Entities/Brands/Brand.cs +++ b/NetinaShop.Domain/Entities/Brands/Brand.cs @@ -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; HasSpecialPage = hasSpecialPage; 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 bool HasSpecialPage { get; internal set; } public string PageUrl { get; internal set; } = string.Empty; diff --git a/NetinaShop.Domain/Mappers/BrandMapper.g.cs b/NetinaShop.Domain/Mappers/BrandMapper.g.cs index b40588a..f6f618e 100644 --- a/NetinaShop.Domain/Mappers/BrandMapper.g.cs +++ b/NetinaShop.Domain/Mappers/BrandMapper.g.cs @@ -14,7 +14,8 @@ namespace NetinaShop.Domain.Mappers { return p1 == null ? null : new Brand() { - Name = p1.Name, + PersianName = p1.PersianName, + EnglishName = p1.EnglishName, Description = p1.Description, HasSpecialPage = p1.HasSpecialPage, PageUrl = p1.PageUrl, @@ -31,7 +32,8 @@ namespace NetinaShop.Domain.Mappers } Brand result = p4 ?? new Brand(); - result.Name = p3.Name; + result.PersianName = p3.PersianName; + result.EnglishName = p3.EnglishName; result.Description = p3.Description; result.HasSpecialPage = p3.HasSpecialPage; result.PageUrl = p3.PageUrl; @@ -43,7 +45,8 @@ namespace NetinaShop.Domain.Mappers } public static Expression> ProjectToBrand => p7 => new Brand() { - Name = p7.Name, + PersianName = p7.PersianName, + EnglishName = p7.EnglishName, Description = p7.Description, HasSpecialPage = p7.HasSpecialPage, PageUrl = p7.PageUrl, @@ -65,7 +68,8 @@ namespace NetinaShop.Domain.Mappers { return p9 == null ? null : new BrandLDto() { - Name = p9.Name, + PersianName = p9.PersianName, + EnglishName = p9.EnglishName, Description = p9.Description, HasSpecialPage = p9.HasSpecialPage, PageUrl = p9.PageUrl, @@ -82,7 +86,8 @@ namespace NetinaShop.Domain.Mappers } BrandLDto result = p12 ?? new BrandLDto(); - result.Name = p11.Name; + result.PersianName = p11.PersianName; + result.EnglishName = p11.EnglishName; result.Description = p11.Description; result.HasSpecialPage = p11.HasSpecialPage; result.PageUrl = p11.PageUrl; @@ -94,7 +99,8 @@ namespace NetinaShop.Domain.Mappers } public static Expression> ProjectToLDto => p15 => new BrandLDto() { - Name = p15.Name, + PersianName = p15.PersianName, + EnglishName = p15.EnglishName, Description = p15.Description, HasSpecialPage = p15.HasSpecialPage, PageUrl = p15.PageUrl, @@ -115,7 +121,8 @@ namespace NetinaShop.Domain.Mappers { return p17 == null ? null : new Brand() { - Name = p17.Name, + PersianName = p17.PersianName, + EnglishName = p17.EnglishName, Description = p17.Description, HasSpecialPage = p17.HasSpecialPage, PageUrl = p17.PageUrl, @@ -131,7 +138,8 @@ namespace NetinaShop.Domain.Mappers } Brand result = p19 ?? new Brand(); - result.Name = p18.Name; + result.PersianName = p18.PersianName; + result.EnglishName = p18.EnglishName; result.Description = p18.Description; result.HasSpecialPage = p18.HasSpecialPage; result.PageUrl = p18.PageUrl; @@ -144,7 +152,8 @@ namespace NetinaShop.Domain.Mappers { return p20 == null ? null : new BrandSDto() { - Name = p20.Name, + PersianName = p20.PersianName, + EnglishName = p20.EnglishName, Description = p20.Description, HasSpecialPage = p20.HasSpecialPage, PageUrl = p20.PageUrl, @@ -161,7 +170,8 @@ namespace NetinaShop.Domain.Mappers } BrandSDto result = p22 ?? new BrandSDto(); - result.Name = p21.Name; + result.PersianName = p21.PersianName; + result.EnglishName = p21.EnglishName; result.Description = p21.Description; result.HasSpecialPage = p21.HasSpecialPage; result.PageUrl = p21.PageUrl; @@ -173,7 +183,8 @@ namespace NetinaShop.Domain.Mappers } public static Expression> ProjectToSDto => p23 => new BrandSDto() { - Name = p23.Name, + PersianName = p23.PersianName, + EnglishName = p23.EnglishName, Description = p23.Description, HasSpecialPage = p23.HasSpecialPage, PageUrl = p23.PageUrl, diff --git a/NetinaShop.Domain/Mappers/ProductMapper.g.cs b/NetinaShop.Domain/Mappers/ProductMapper.g.cs index 9c990d7..9bd3daf 100644 --- a/NetinaShop.Domain/Mappers/ProductMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ProductMapper.g.cs @@ -30,11 +30,7 @@ namespace NetinaShop.Domain.Mappers HasExpressDelivery = p1.HasExpressDelivery, MaxOrderCount = p1.MaxOrderCount, BrandId = p1.BrandId, - Brand = new Brand() - { - Name = p1.BrandName, - Id = p1.BrandId - }, + Brand = new Brand() {Id = p1.BrandId}, CategoryId = p1.CategoryId, Category = new ProductCategory() { @@ -95,11 +91,7 @@ namespace NetinaShop.Domain.Mappers HasExpressDelivery = p17.HasExpressDelivery, MaxOrderCount = p17.MaxOrderCount, BrandId = p17.BrandId, - Brand = new Brand() - { - Name = p17.BrandName, - Id = p17.BrandId - }, + Brand = new Brand() {Id = p17.BrandId}, CategoryId = p17.CategoryId, Category = new ProductCategory() { @@ -159,7 +151,7 @@ namespace NetinaShop.Domain.Mappers MaxOrderCount = p21.MaxOrderCount, Stock = p21.Stock, BrandId = p21.BrandId, - BrandName = p21.Brand == null ? null : p21.Brand.Name, + BrandName = p21.Brand == null ? null : p21.Brand.PersianName, CategoryId = p21.CategoryId, CategoryName = p21.Category == null ? null : p21.Category.Name, Specifications = funcMain9(p21.Specifications), @@ -190,7 +182,7 @@ namespace NetinaShop.Domain.Mappers result.MaxOrderCount = p25.MaxOrderCount; result.Stock = p25.Stock; 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.CategoryName = p25.Category == null ? null : p25.Category.Name; result.Specifications = funcMain12(p25.Specifications, result.Specifications); @@ -216,7 +208,7 @@ namespace NetinaShop.Domain.Mappers MaxOrderCount = p33.MaxOrderCount, Stock = p33.Stock, BrandId = p33.BrandId, - BrandName = p33.Brand == null ? null : p33.Brand.Name, + BrandName = p33.Brand == null ? null : p33.Brand.PersianName, CategoryId = p33.CategoryId, CategoryName = p33.Category == null ? null : p33.Category.Name, Specifications = p33.Specifications.Select(p34 => new SpecificationSDto() @@ -274,11 +266,7 @@ namespace NetinaShop.Domain.Mappers Viewed = p37.Viewed, MaxOrderCount = p37.MaxOrderCount, BrandId = p37.BrandId, - Brand = new Brand() - { - Name = p37.BrandName, - Id = p37.BrandId - }, + Brand = new Brand() {Id = p37.BrandId}, CategoryId = p37.CategoryId, Category = new ProductCategory() { @@ -343,7 +331,7 @@ namespace NetinaShop.Domain.Mappers MainImage = p44.Files.FirstOrDefault(funcMain17) != null ? p44.Files.FirstOrDefault(funcMain18).FileLocation : (p44.Files.Count > 0 ? p44.Files.FirstOrDefault().FileLocation : string.Empty), CategoryId = p44.CategoryId, 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, Id = p44.Id, CreatedAt = p44.CreatedAt @@ -375,7 +363,7 @@ namespace NetinaShop.Domain.Mappers result.MainImage = p45.Files.FirstOrDefault(funcMain17) != null ? p45.Files.FirstOrDefault(funcMain18).FileLocation : (p45.Files.Count > 0 ? p45.Files.FirstOrDefault().FileLocation : string.Empty); result.CategoryId = p45.CategoryId; 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.Id = p45.Id; result.CreatedAt = p45.CreatedAt; @@ -402,7 +390,7 @@ namespace NetinaShop.Domain.Mappers MainImage = p47.Files.FirstOrDefault(f => f.IsPrimary) != null ? p47.Files.FirstOrDefault(f => f.IsPrimary).FileLocation : (p47.Files.Count > 0 ? p47.Files.FirstOrDefault().FileLocation : string.Empty), CategoryId = p47.CategoryId, 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, Id = p47.Id, CreatedAt = p47.CreatedAt @@ -505,7 +493,6 @@ namespace NetinaShop.Domain.Mappers { Brand result = p8 ?? new Brand(); - result.Name = p5.BrandName; result.Id = p5.BrandId; return result; @@ -802,7 +789,6 @@ namespace NetinaShop.Domain.Mappers { Brand result = p41 ?? new Brand(); - result.Name = p38.BrandName; result.Id = p38.BrandId; return result; diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index aa377da..9d86c13 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -25,7 +25,7 @@ public class MapsterRegister : IRegister config.NewConfig() .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("BrandName", o => o.Brand == null ? null : o.Brand.Name) + .Map("BrandName", o => o.Brand == null ? null : o.Brand.PersianName) .IgnoreNullValues(false) .TwoWays(); @@ -56,7 +56,7 @@ public class MapsterRegister : IRegister config.NewConfig() .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) .TwoWays(); diff --git a/NetinaShop.Infrastructure/Services/Scrapers/DigikalaScraper.cs b/NetinaShop.Infrastructure/Services/Scrapers/DigikalaScraper.cs index 34b7cb4..10d9421 100644 --- a/NetinaShop.Infrastructure/Services/Scrapers/DigikalaScraper.cs +++ b/NetinaShop.Infrastructure/Services/Scrapers/DigikalaScraper.cs @@ -92,7 +92,7 @@ public class DigikalaScraper : IDigikalaScraper { var nonBrand = await _repositoryWrapper.SetRepository() .TableNoTracking - .FirstOrDefaultAsync(b => b.Name == "بدون برند", cancellationToken); + .FirstOrDefaultAsync(b => b.PersianName == "بدون برند", cancellationToken); if (nonBrand == null) throw new AppException("NoneBrand is not exist"); diff --git a/NetinaShop.Repository/Handlers/Brands/CreateBrandCommandHandler.cs b/NetinaShop.Repository/Handlers/Brands/CreateBrandCommandHandler.cs index 65d1572..f588e49 100644 --- a/NetinaShop.Repository/Handlers/Brands/CreateBrandCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/CreateBrandCommandHandler.cs @@ -4,7 +4,7 @@ namespace NetinaShop.Repository.Handlers.Brands; public class CreateBrandCommandHandler : IRequestHandler { - private IRepositoryWrapper _repositoryWrapper; + private readonly IRepositoryWrapper _repositoryWrapper; public CreateBrandCommandHandler(IRepositoryWrapper repositoryWrapper) { @@ -12,7 +12,7 @@ public class CreateBrandCommandHandler : IRequestHandler 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) { ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); diff --git a/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs b/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs index 6cf107b..ecb728a 100644 --- a/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/GetBrandsQueryHandler.cs @@ -46,7 +46,7 @@ public class GetBrandsQueryHandler : IRequestHandler() .TableNoTracking - .Where(b => b.Name.Trim().Contains(request.BrandName.Trim())) + .Where(b => b.PersianName.Trim().Contains(request.BrandName.Trim())) .OrderByDescending(b => b.CreatedAt); } else diff --git a/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs b/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs index e84c406..7aa23ea 100644 --- a/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Brands/UpdateBrandCommandHandler.cs @@ -17,7 +17,7 @@ public class UpdateBrandCommandHandler : IRequestHandler b.Id == request.Id, cancellationToken); if (ent == null) 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.CreatedAt = ent.CreatedAt; newEnt.CreatedBy = ent.CreatedBy; diff --git a/NetinaShop.Repository/Handlers/Products/ChangeProductDisplayedCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/ChangeProductDisplayedCommandHandler.cs new file mode 100644 index 0000000..09c41c6 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Products/ChangeProductDisplayedCommandHandler.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; + +namespace NetinaShop.Repository.Handlers.Products; + +public class ChangeProductDisplayedCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public ChangeProductDisplayedCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(ChangeProductDisplayedCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .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() + .Update(newEnt); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs b/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs new file mode 100644 index 0000000..584e62f --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.Designer.cs @@ -0,0 +1,1689 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetinaShop.Repository.Models; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20240222102310_EditBrandAddEnglishName")] + partial class EditBrandAddEnglishName + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountCodePrice") + .HasColumnType("double precision"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("ProductDiscountPrice") + .HasColumnType("double precision"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("DiscountId"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddressId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("OrderId") + .IsUnique(); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("BuildingUnit") + .IsRequired() + .HasColumnType("text"); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("LocationLat") + .HasColumnType("real"); + + b.Property("LocationLong") + .HasColumnType("real"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Plaque") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Province") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.Property("WorkingDays") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.UserAddress", "Address") + .WithMany() + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithOne("OrderDelivery") + .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Address"); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany("Addresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDelivery"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.cs b/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.cs new file mode 100644 index 0000000..61b4977 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240222102310_EditBrandAddEnglishName.cs @@ -0,0 +1,43 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditBrandAddEnglishName : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Name", + schema: "public", + table: "Brands", + newName: "PersianName"); + + migrationBuilder.AddColumn( + name: "EnglishName", + schema: "public", + table: "Brands", + type: "text", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EnglishName", + schema: "public", + table: "Brands"); + + migrationBuilder.RenameColumn( + name: "PersianName", + schema: "public", + table: "Brands", + newName: "Name"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index 74e96f8..6f5f172 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -312,6 +312,10 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + b.Property("HasSpecialPage") .HasColumnType("boolean"); @@ -324,11 +328,11 @@ namespace NetinaShop.Repository.Migrations b.Property("ModifiedBy") .HasColumnType("text"); - b.Property("Name") + b.Property("PageUrl") .IsRequired() .HasColumnType("text"); - b.Property("PageUrl") + b.Property("PersianName") .IsRequired() .HasColumnType("text");