From d442ed17eeb9979c184a02654a5e80365aca249c Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Fri, 9 Feb 2024 19:43:17 +0330 Subject: [PATCH] feat : products , ordering system , discount add discount page and CRUD , complete products CRUD , improve ordering system --- .../Controller/OrderBagController.cs | 12 +- NetinaShop.Api/Controller/RoleController.cs | 4 +- NetinaShop.Common/NetinaShop.Common.csproj | 8 +- .../EntityServices/Abstracts/IUserService.cs | 1 + .../AddToOrderBagCommandHandler.cs | 25 +- .../RemoveFromOrderBagCommandHandler.cs | 24 +- NetinaShop.Core/EntityServices/UserService.cs | 28 +- .../Commands/OrderBagCommands.cs | 8 +- .../Commands/ProductCommands.cs | 2 + .../Dtos/LargDtos/ProductLDto.cs | 1 + .../Dtos/RequestDtos/OrderBagRequestDto.cs | 7 + .../Entities/Products/Product.Aggregate.cs | 18 +- .../Entities/Products/Product.cs | 5 + NetinaShop.Domain/Enums/Gender.cs | 2 + NetinaShop.Domain/Mappers/ProductMapper.g.cs | 73 +- NetinaShop.Domain/NetinaShop.Domain.csproj | 8 +- .../Discounts/UpdateDiscountCommandHandler.cs | 2 +- .../Products/CreateProductCommandHandler.cs | 5 +- .../Products/UpdateProductCommandHandler.cs | 1 + ...0209142029_EditProductIsEnable.Designer.cs | 1608 +++++++++++++++++ .../20240209142029_EditProductIsEnable.cs | 31 + .../ApplicationContextModelSnapshot.cs | 3 + .../Program.cs | 4 +- 23 files changed, 1789 insertions(+), 91 deletions(-) create mode 100644 NetinaShop.Domain/Dtos/RequestDtos/OrderBagRequestDto.cs create mode 100644 NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.Designer.cs create mode 100644 NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.cs diff --git a/NetinaShop.Api/Controller/OrderBagController.cs b/NetinaShop.Api/Controller/OrderBagController.cs index 20afe69..27b354a 100644 --- a/NetinaShop.Api/Controller/OrderBagController.cs +++ b/NetinaShop.Api/Controller/OrderBagController.cs @@ -14,11 +14,11 @@ public class OrderBagController : ICarterModule .WithDisplayName("GetUserCurrentOrderBagAsync") .HasApiVersion(1.0); - group.MapPost("add/{productId}", AddProductToBagAsync) + group.MapPost("add", AddProductToBagAsync) .WithDisplayName("AddProductToBag") .HasApiVersion(1.0); - group.MapPost("remove/{productId}", RemoveFromOrderBagAsync) + group.MapDelete("remove", RemoveFromOrderBagAsync) .WithDisplayName("RemoveFromOrderBag") .HasApiVersion(1.0); @@ -40,12 +40,12 @@ public class OrderBagController : ICarterModule public async Task GetUserCurrentOrderBagAsync(IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(new GetUserOrderBagQuery(), cancellationToken)); - public async Task AddProductToBagAsync( Guid productId, [FromQuery]int count, IMediator mediator, CancellationToken cancellationToken) - => TypedResults.Ok(await mediator.Send(new AddToOrderBagCommand(productId,count), cancellationToken)); + public async Task AddProductToBagAsync([FromBody] List requestDtos, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new AddToOrderBagCommand(requestDtos), cancellationToken)); - public async Task RemoveFromOrderBagAsync(Guid productId, [FromQuery] int count, IMediator mediator, CancellationToken cancellationToken) - => TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(productId, count), cancellationToken)); + public async Task RemoveFromOrderBagAsync([FromBody] List requestDtos, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(requestDtos), cancellationToken)); public async Task AddDiscountToOrderBagAsync(Guid orderId, [FromQuery] string discountCode, IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken)); diff --git a/NetinaShop.Api/Controller/RoleController.cs b/NetinaShop.Api/Controller/RoleController.cs index 750f852..2e81091 100644 --- a/NetinaShop.Api/Controller/RoleController.cs +++ b/NetinaShop.Api/Controller/RoleController.cs @@ -34,8 +34,8 @@ public class RoleController : ICarterModule } // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, IUserService userService, CancellationToken cancellationToken) - => TypedResults.Ok(await userService.GetRolesAsync(page, cancellationToken)); + public async Task GetAllAsync([FromQuery] int? page, [FromQuery]string? roleName, IUserService userService, CancellationToken cancellationToken) + => TypedResults.Ok(await userService.GetRolesAsync(page,roleName, cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, IUserService userService, CancellationToken cancellationToken) diff --git a/NetinaShop.Common/NetinaShop.Common.csproj b/NetinaShop.Common/NetinaShop.Common.csproj index 7da31c7..346c5b2 100644 --- a/NetinaShop.Common/NetinaShop.Common.csproj +++ b/NetinaShop.Common/NetinaShop.Common.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/NetinaShop.Core/EntityServices/Abstracts/IUserService.cs b/NetinaShop.Core/EntityServices/Abstracts/IUserService.cs index e7fcb63..86a9c24 100644 --- a/NetinaShop.Core/EntityServices/Abstracts/IUserService.cs +++ b/NetinaShop.Core/EntityServices/Abstracts/IUserService.cs @@ -13,6 +13,7 @@ public interface IUserService : IScopedDependency Task> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default); + Task> GetRolesAsync(int? page,string? roleName, CancellationToken cancellationToken = default); Task GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default); Task CreateRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default); Task EditRoleAsync(RoleActionRequestDto request, CancellationToken cancellationToken = default); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs index d8beb89..0d072a6 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/AddToOrderBagCommandHandler.cs @@ -20,18 +20,23 @@ public class AddToOrderBagCommandHandler : IRequestHandler() - .TableNoTracking - .FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken); - - if (product == null) - throw new AppException("Product not found ",ApiResultStatusCode.NotFound); - if (!product.IsEnable) - throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest); - var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken); - orderBag.AddToOrderBag(product, request.Count); + foreach (var requestDto in request.RequestDtos) + { + + var product = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(p => p.Id == requestDto.ProductId, cancellationToken); + + if (product == null) + throw new AppException("Product not found ", ApiResultStatusCode.NotFound); + if (!product.IsEnable) + throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest); + + + orderBag.AddToOrderBag(product, requestDto.Count); + } _repositoryWrapper.SetRepository().Update(orderBag); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs index 79b62f9..7107fe6 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/RemoveFromOrderBagCommandHandler.cs @@ -19,18 +19,22 @@ public class RemoveFromOrderBagCommandHandler : IRequestHandler() - .TableNoTracking - .FirstOrDefaultAsync(p => p.Id == request.ProductId, cancellationToken); - - if (product == null) - throw new AppException("Product not found ", ApiResultStatusCode.NotFound); - if (!product.IsEnable) - throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest); - var orderBag = await _mediator.Send(new GetUserOrderBagQuery(), cancellationToken); - orderBag.RemoveFromOrderBag(product, request.Count); + foreach (var requestDto in request.RequestDtos) + { + var product = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(p => p.Id == requestDto.ProductId, cancellationToken); + + if (product == null) + throw new AppException("Product not found ", ApiResultStatusCode.NotFound); + if (!product.IsEnable) + throw new AppException("Product is not enable", ApiResultStatusCode.BadRequest); + + + orderBag.RemoveFromOrderBag(product, requestDto.Count); + } _repositoryWrapper.SetRepository().Update(orderBag); diff --git a/NetinaShop.Core/EntityServices/UserService.cs b/NetinaShop.Core/EntityServices/UserService.cs index 86f198c..e5292dc 100644 --- a/NetinaShop.Core/EntityServices/UserService.cs +++ b/NetinaShop.Core/EntityServices/UserService.cs @@ -1,4 +1,5 @@ using StackExchange.Redis; +using System.Linq; using System.Security.Claims; namespace NetinaShop.Core.EntityServices; @@ -71,6 +72,16 @@ public class UserService : IUserService .Skip(page * 15).Take(15) .Select(ApplicationUserMapper.ProjectToSDto) .ToListAsync(cancellationToken); + foreach (var user in users) + { + var roles = await _userManager.GetRolesAsync(user.AdaptToApplicationUser()); + foreach (var roleName in roles) + { + var role = await _roleManager.FindByNameAsync(roleName); + if (role != null) + user.RoleName += role.PersianName + " "; + } + } return users; } @@ -258,6 +269,20 @@ public class UserService : IUserService return roles; } + public async Task> GetRolesAsync(int? page, string? roleName, CancellationToken cancellationToken = default) + { + IQueryable roles; + if (roleName!=null) + roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin" && r.PersianName.Trim().ToLower().Contains(roleName)); + else + roles = _roleManager.Roles.Where(r => r.Name != "RootAdmin"); + if (page != null) + roles = roles.Skip(page.Value * 15).Take(15); + else + roles = roles; + return await roles.ToListAsync(cancellationToken); + } + public async Task GetRoleAsync(Guid roleId, CancellationToken cancellationToken = default) { var role = (await _roleManager.FindByIdAsync(roleId.ToString())); @@ -324,9 +349,6 @@ public class UserService : IUserService foreach (var claim in request.Permissions) await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim)); - foreach (var claim in roleClaims) - await _roleManager.RemoveClaimAsync(applicationRole, claim); - return true; } diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs index 4a2c973..b9c6074 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs @@ -1,9 +1,11 @@ -namespace NetinaShop.Domain.CommandQueries.Commands; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.CommandQueries.Commands; public sealed record CreateOrderCommand(string DiscountCode, List OrderProducts, OrderDeliverySDto OrderDelivery) : IRequest; -public sealed record AddToOrderBagCommand(Guid ProductId, int Count) : IRequest; -public sealed record RemoveFromOrderBagCommand(Guid ProductId, int Count) : IRequest; +public sealed record AddToOrderBagCommand(List RequestDtos) : IRequest; +public sealed record RemoveFromOrderBagCommand(List RequestDtos) : IRequest; public sealed record SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest; public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest; diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs index cab8893..f1b3434 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs @@ -10,6 +10,7 @@ string Warranty, bool BeDisplayed, double Cost, double PackingCost, +int Stock, bool HasExpressDelivery, int MaxOrderCount, bool IsSpecialOffer, @@ -30,6 +31,7 @@ public sealed record UpdateProductCommand( bool BeDisplayed, double Cost, double PackingCost, + int Stock, bool HasExpressDelivery, int MaxOrderCount, bool IsSpecialOffer, diff --git a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs index 28f863c..44c9116 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs @@ -13,6 +13,7 @@ public class ProductLDto : BaseDto public int MaxOrderCount { get; set; } public double Cost { get; set; } public double PackingCost { get; set; } + public int Stock { get; set; } public Guid BrandId { get; set; } public string BrandName { get; set; } = string.Empty; public Guid CategoryId { get; set; } diff --git a/NetinaShop.Domain/Dtos/RequestDtos/OrderBagRequestDto.cs b/NetinaShop.Domain/Dtos/RequestDtos/OrderBagRequestDto.cs new file mode 100644 index 0000000..6e122a8 --- /dev/null +++ b/NetinaShop.Domain/Dtos/RequestDtos/OrderBagRequestDto.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.Dtos.RequestDtos; + +public class OrderBagRequestDto +{ + public Guid ProductId { get; set; } + public int Count { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs index 34c4e16..7d209d0 100644 --- a/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs @@ -7,11 +7,27 @@ public partial class Product double cost, double packingCost, bool hasExpressDelivery, + int stock, int maxOrderCount, Guid brandId, Guid categoryId) { - return new Product(persianName, englishName, summery, expertCheck, tags, warranty, beDisplayed,cost, packingCost,hasExpressDelivery,maxOrderCount, brandId,categoryId); + return new Product( + persianName, + englishName, + summery, + expertCheck, + tags, + warranty, + beDisplayed, + cost, + packingCost, + stock, + hasExpressDelivery, + maxOrderCount, + stock > 0, + brandId, + categoryId); } public void AddRate(float rate) diff --git a/NetinaShop.Domain/Entities/Products/Product.cs b/NetinaShop.Domain/Entities/Products/Product.cs index 177f738..1032459 100644 --- a/NetinaShop.Domain/Entities/Products/Product.cs +++ b/NetinaShop.Domain/Entities/Products/Product.cs @@ -23,8 +23,10 @@ public partial class Product : ApiEntity bool beDisplayed, double cost, double packingCost, + int stock, bool hasExpressDelivery, int maxOrderCount, + bool isEnable, Guid brandId, Guid categoryId) { @@ -37,8 +39,10 @@ public partial class Product : ApiEntity BeDisplayed = beDisplayed; Cost = cost; PackingCost = packingCost; + Stock = stock; HasExpressDelivery = hasExpressDelivery; MaxOrderCount = maxOrderCount; + IsEnable = isEnable; BrandId = brandId; CategoryId = categoryId; } @@ -52,6 +56,7 @@ public partial class Product : ApiEntity public bool IsEnable { get; internal set; } public bool BeDisplayed { get; internal set; } public double PackingCost { get; internal set; } + public int Stock { get; internal set; } public float Rate { get; internal set; } public int ReviewCount { get; internal set; } public int Viewed { get; internal set; } diff --git a/NetinaShop.Domain/Enums/Gender.cs b/NetinaShop.Domain/Enums/Gender.cs index a7ed7d6..2478c92 100644 --- a/NetinaShop.Domain/Enums/Gender.cs +++ b/NetinaShop.Domain/Enums/Gender.cs @@ -2,6 +2,8 @@ public enum Gender { + [Display(Name = "مرد")] Male, + [Display(Name = "بانو")] Female } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductMapper.g.cs b/NetinaShop.Domain/Mappers/ProductMapper.g.cs index 3ff1c20..cd92337 100644 --- a/NetinaShop.Domain/Mappers/ProductMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ProductMapper.g.cs @@ -26,6 +26,7 @@ namespace NetinaShop.Domain.Mappers Cost = p1.Cost, BeDisplayed = p1.BeDisplayed, PackingCost = p1.PackingCost, + Stock = p1.Stock, HasExpressDelivery = p1.HasExpressDelivery, MaxOrderCount = p1.MaxOrderCount, BrandId = p1.BrandId, @@ -54,6 +55,7 @@ namespace NetinaShop.Domain.Mappers result.Cost = p5.Cost; result.BeDisplayed = p5.BeDisplayed; result.PackingCost = p5.PackingCost; + result.Stock = p5.Stock; result.HasExpressDelivery = p5.HasExpressDelivery; result.MaxOrderCount = p5.MaxOrderCount; result.BrandId = p5.BrandId; @@ -77,6 +79,7 @@ namespace NetinaShop.Domain.Mappers Cost = p13.Cost, BeDisplayed = p13.BeDisplayed, PackingCost = p13.PackingCost, + Stock = p13.Stock, HasExpressDelivery = p13.HasExpressDelivery, MaxOrderCount = p13.MaxOrderCount, BrandId = p13.BrandId, @@ -132,6 +135,7 @@ namespace NetinaShop.Domain.Mappers MaxOrderCount = p17.MaxOrderCount, Cost = p17.Cost, PackingCost = p17.PackingCost, + Stock = p17.Stock, BrandId = p17.BrandId, BrandName = p17.Brand == null ? null : p17.Brand.Name, CategoryId = p17.CategoryId, @@ -162,6 +166,7 @@ namespace NetinaShop.Domain.Mappers result.MaxOrderCount = p21.MaxOrderCount; result.Cost = p21.Cost; result.PackingCost = p21.PackingCost; + result.Stock = p21.Stock; result.BrandId = p21.BrandId; result.BrandName = p21.Brand == null ? null : p21.Brand.Name; result.CategoryId = p21.CategoryId; @@ -187,6 +192,7 @@ namespace NetinaShop.Domain.Mappers MaxOrderCount = p29.MaxOrderCount, Cost = p29.Cost, PackingCost = p29.PackingCost, + Stock = p29.Stock, BrandId = p29.BrandId, BrandName = p29.Brand.Name, CategoryId = p29.CategoryId, @@ -291,41 +297,28 @@ namespace NetinaShop.Domain.Mappers } public static ProductSDto AdaptToSDto(this Product p40) { - if (p40 == null) + return p40 == null ? null : new ProductSDto() { - return null; - } - ProductSDto result = new ProductSDto(); - - result.PersianName = p40.PersianName; - result.EnglishName = p40.EnglishName; - result.Summery = p40.Summery; - result.ExpertCheck = p40.ExpertCheck; - result.Tags = p40.Tags; - result.Warranty = p40.Warranty; - result.Cost = p40.Cost; - result.IsEnable = p40.IsEnable; - result.BeDisplayed = p40.BeDisplayed; - result.PackingCost = p40.PackingCost; - result.Rate = p40.Rate; - result.ReviewCount = p40.ReviewCount; - result.Viewed = p40.Viewed; - result.CategoryId = p40.CategoryId; - result.BrandId = p40.BrandId; - result.Id = p40.Id; - result.CreatedAt = p40.CreatedAt; - - if (!(p40.Brand == null)) - { - result.BrandName = p40.Brand == null ? null : p40.Brand.Name; - } - - if (!(p40.Category == null)) - { - result.CategoryName = p40.Category == null ? null : p40.Category.Name; - } - return result; - + PersianName = p40.PersianName, + EnglishName = p40.EnglishName, + Summery = p40.Summery, + ExpertCheck = p40.ExpertCheck, + Tags = p40.Tags, + Warranty = p40.Warranty, + Cost = p40.Cost, + IsEnable = p40.IsEnable, + BeDisplayed = p40.BeDisplayed, + PackingCost = p40.PackingCost, + Rate = p40.Rate, + ReviewCount = p40.ReviewCount, + Viewed = p40.Viewed, + CategoryId = p40.CategoryId, + BrandId = p40.BrandId, + BrandName = p40.Brand == null ? null : p40.Brand.Name, + CategoryName = p40.Category == null ? null : p40.Category.Name, + Id = p40.Id, + CreatedAt = p40.CreatedAt + }; } public static ProductSDto AdaptTo(this Product p41, ProductSDto p42) { @@ -350,18 +343,10 @@ namespace NetinaShop.Domain.Mappers result.Viewed = p41.Viewed; result.CategoryId = p41.CategoryId; result.BrandId = p41.BrandId; + result.BrandName = p41.Brand == null ? null : p41.Brand.Name; + result.CategoryName = p41.Category == null ? null : p41.Category.Name; result.Id = p41.Id; result.CreatedAt = p41.CreatedAt; - - if (!(p41.Brand == null)) - { - result.BrandName = p41.Brand == null ? null : p41.Brand.Name; - } - - if (!(p41.Category == null)) - { - result.CategoryName = p41.Category == null ? null : p41.Category.Name; - } return result; } diff --git a/NetinaShop.Domain/NetinaShop.Domain.csproj b/NetinaShop.Domain/NetinaShop.Domain.csproj index e9ef5fc..41b085e 100644 --- a/NetinaShop.Domain/NetinaShop.Domain.csproj +++ b/NetinaShop.Domain/NetinaShop.Domain.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs index 68612de..0adc24c 100644 --- a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs @@ -38,7 +38,7 @@ public class UpdateDiscountCommandHandler : IRequestHandler().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); + var productEnt = await _repositoryWrapper.SetRepository().TableNoTracking.FirstOrDefaultAsync(d => d.Id == request.Id, cancellationToken); if (productEnt == null) throw new AppException("Discount not found", ApiResultStatusCode.NotFound); diff --git a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs index 214b9a4..06d5d52 100644 --- a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs @@ -14,7 +14,10 @@ public class CreateProductCommandHandler : IRequestHandler Handle(CreateProductCommand request, CancellationToken cancellationToken) { var ent = Product.Create(request.PersianName, request.EnglishName, request.Summery, request.ExpertCheck, - request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost,request.HasExpressDelivery,request.MaxOrderCount, + request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost, + request.HasExpressDelivery, + request.Stock, + request.MaxOrderCount, request.BrandId,request.CategoryId); foreach (var specification in request.Specifications) diff --git a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs index 0412472..5193836 100644 --- a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs @@ -24,6 +24,7 @@ public class UpdateProductCommandHandler : IRequestHandler +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("20240209142029_EditProductIsEnable")] + partial class EditProductIsEnable + { + /// + 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.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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PostalCode") + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + 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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .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("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("PostalCode") + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .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") + .IsRequired() + .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") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + 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.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.Orders.Order", "Order") + .WithMany("OrderDeliveries") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + 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("OrderDeliveries"); + + b.Navigation("OrderProducts"); + }); + + 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/20240209142029_EditProductIsEnable.cs b/NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.cs new file mode 100644 index 0000000..1020543 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240209142029_EditProductIsEnable.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditProductIsEnable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Stock", + schema: "public", + table: "Products", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Stock", + schema: "public", + table: "Products"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index 561ba36..3ecac16 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -721,6 +721,9 @@ namespace NetinaShop.Repository.Migrations b.Property("ReviewCount") .HasColumnType("integer"); + b.Property("Stock") + .HasColumnType("integer"); + b.Property("Summery") .IsRequired() .HasColumnType("text"); diff --git a/Tools/NetinaShop.WordPressDBConverter/Program.cs b/Tools/NetinaShop.WordPressDBConverter/Program.cs index aa3aef1..4c88ba6 100644 --- a/Tools/NetinaShop.WordPressDBConverter/Program.cs +++ b/Tools/NetinaShop.WordPressDBConverter/Program.cs @@ -105,12 +105,12 @@ try var price = postMetas.FirstOrDefault(pm => pm.post_id == wordPressPostDto.ID && pm.meta_key == "_price"); if (price != null && double.TryParse(price.meta_value, out double dPrice)) product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, - wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0, + wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, dPrice, 0,10, false,10,false,brandId, categoryId, new DiscountSDto(),new List(), new List()); else product = new CreateProductCommand(wordPressPostDto.post_title, string.Empty, wordPressPostDto.post_content, - wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,false,10, + wordPressPostDto.post_excerpt, string.Empty, string.Empty, true, 0, 0,10,false,10, false,brandId,categoryId, new DiscountSDto(),new List(), new List());