diff --git a/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs index 14642b8..18df185 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs @@ -16,6 +16,7 @@ bool HasPriceCeiling, bool IsInfinity, long UseCount, bool IsForInvitation, +bool IsSpecialOffer, Guid ProductId, Guid CategoryId) : IRequest; @@ -36,6 +37,7 @@ public sealed record UpdateDiscountCommand(Guid Id, bool IsInfinity, long UseCount, bool IsForInvitation, + bool IsSpecialOffer, Guid ProductId, Guid CategoryId) : IRequest; diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs index 0d2ae1e..cab8893 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs @@ -12,8 +12,10 @@ double Cost, double PackingCost, bool HasExpressDelivery, int MaxOrderCount, +bool IsSpecialOffer, Guid BrandId, Guid CategoryId, +DiscountSDto SpecialOffer, List Specifications, List Files):IRequest; @@ -30,8 +32,11 @@ public sealed record UpdateProductCommand( double PackingCost, bool HasExpressDelivery, int MaxOrderCount, + bool IsSpecialOffer, Guid BrandId, Guid CategoryId, + DiscountSDto SpecialOffer, List Specifications, List Files) : IRequest; + public sealed record DeleteProductCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs index 63a25d8..50126bb 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/DiscountLDto.cs @@ -17,7 +17,10 @@ public class DiscountLDto : BaseDto public bool HasPriceCeiling { get; set; } public bool IsInfinity { get; set; } public long UseCount { get; set; } + public bool IsSpecialOffer { get; set; } public bool IsForInvitation { get; set; } public Guid ProductId { get; set; } + public string ProductName { get; set; } = string.Empty; public Guid CategoryId { get; set; } + public string CategoryName { get; set; } = string.Empty; } \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs index 950c122..28f863c 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs @@ -17,9 +17,12 @@ public class ProductLDto : BaseDto public string BrandName { get; set; } = string.Empty; public Guid CategoryId { get; set; } public string CategoryName { get; set; } = string.Empty; + public bool IsSpecialOffer { get; set; } public List Specifications { get; set; } = new(); public List Reviews { get; set; } = new(); public List Categories { get; set; } = new(); public List Files { get; set; } = new(); + + public DiscountSDto? SpecialOffer { get; set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs index 51e5ca9..0e9e00b 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs @@ -17,5 +17,6 @@ public class DiscountSDto : BaseDto public bool HasPriceCeiling { get; set; } public bool IsInfinity { get; set; } public long UseCount { get; set; } + public bool IsSpecialOffer { get; set; } public bool IsForInvitation { get; set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs index 4cc8046..c845c2e 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/ProductSDto.cs @@ -14,6 +14,7 @@ public class ProductSDto : BaseDto public bool HasDiscount { get; set; } public double CostWithDiscount { get; set; } public bool IsEnable { get; set; } + public bool IsSpecial { get; set; } public bool BeDisplayed { get; set; } public double PackingCost { get; set; } public float Rate { get; set; } diff --git a/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs b/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs index 4d31296..2bba88c 100644 --- a/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs +++ b/NetinaShop.Domain/Entities/Discounts/CategoryDiscount.cs @@ -9,9 +9,9 @@ public partial class CategoryDiscount : Discount } - public CategoryDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, Guid categoryId) + public CategoryDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer, Guid categoryId) : base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, - isForInvitation) + isForInvitation, isSpecialOffer) { CategoryId = categoryId; } diff --git a/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs b/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs index 4e0d373..c825b9c 100644 --- a/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Discounts/Discount.Aggregate.cs @@ -2,11 +2,25 @@ public partial class Discount { - public static Discount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation) + public static Discount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer) { - return new Discount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, - expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, - isForInvitation); + return new Discount(code, + discountPercent, + discountAmount, + hasCode, + amountType, + type, + count, + startDate, + expireDate, + priceFloor, + hasPriceFloor, + priceCeiling, + hasPriceCeiling, + isInfinity, + useCount, + isForInvitation, + isSpecialOffer); } public bool IsExpired() @@ -15,20 +29,20 @@ public partial class Discount public partial class ProductDiscount { - public static ProductDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation , Guid productId) + public static ProductDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation ,bool isSpecialOffer, Guid productId) { return new ProductDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, - isForInvitation, productId); + isForInvitation, isSpecialOffer, productId); } } public partial class CategoryDiscount { - public static CategoryDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, Guid categoryId) + public static CategoryDiscount Create(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation, bool isSpecialOffer, Guid categoryId) { return new CategoryDiscount(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, - isForInvitation, categoryId); + isForInvitation,isSpecialOffer, categoryId); } } diff --git a/NetinaShop.Domain/Entities/Discounts/Discount.cs b/NetinaShop.Domain/Entities/Discounts/Discount.cs index 51a2b75..a209f56 100644 --- a/NetinaShop.Domain/Entities/Discounts/Discount.cs +++ b/NetinaShop.Domain/Entities/Discounts/Discount.cs @@ -12,7 +12,23 @@ public partial class Discount : ApiEntity } - public Discount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation) + public Discount(string code, + int discountPercent, + long discountAmount, + bool hasCode, + DiscountAmountType amountType, + DiscountType type, + int count, + DateTime startDate, + DateTime expireDate, + long priceFloor, + bool hasPriceFloor, + long priceCeiling, + bool hasPriceCeiling, + bool isInfinity, + long useCount, + bool isForInvitation, + bool isSpecialOffer) { Code = code; DiscountPercent = discountPercent; @@ -30,6 +46,7 @@ public partial class Discount : ApiEntity IsInfinity = isInfinity; UseCount = useCount; IsForInvitation = isForInvitation; + IsSpecialOffer = isSpecialOffer; } public string Code { get; internal set; } = string.Empty; public int DiscountPercent { get; internal set; } @@ -46,6 +63,7 @@ public partial class Discount : ApiEntity public bool HasPriceCeiling { get; internal set; } public bool IsInfinity { get; internal set; } public long UseCount { get; internal set; } + public bool IsSpecialOffer { get; internal set; } public bool IsForInvitation { get; internal set; } public List Orders { get; internal set; } = new(); diff --git a/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs b/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs index b129d7f..c2739c3 100644 --- a/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs +++ b/NetinaShop.Domain/Entities/Discounts/ProductDiscount.cs @@ -7,8 +7,8 @@ public partial class ProductDiscount : Discount } - public ProductDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,Guid productId) - : base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, isForInvitation) + public ProductDiscount(string code, int discountPercent, long discountAmount, bool hasCode, DiscountAmountType amountType, DiscountType type, int count, DateTime startDate, DateTime expireDate, long priceFloor, bool hasPriceFloor, long priceCeiling, bool hasPriceCeiling, bool isInfinity, long useCount, bool isForInvitation,bool isSpecialOffer,Guid productId) + : base(code, discountPercent, discountAmount, hasCode, amountType, type, count, startDate, expireDate, priceFloor, hasPriceFloor, priceCeiling, hasPriceCeiling, isInfinity, useCount, isForInvitation, isSpecialOffer) { ProductId = productId; } diff --git a/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs index 6f290f4..80b74c3 100644 --- a/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs @@ -13,14 +13,14 @@ public class CreateDiscountCommandHandler : IRequestHandler().Add(ent); break; case DiscountType.Category: var catDis = CategoryDiscount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, - request.IsForInvitation, request.CategoryId); + request.IsForInvitation,request.IsSpecialOffer, request.CategoryId); _repositoryWrapper.SetRepository().Add(catDis); break; @@ -28,14 +28,14 @@ public class CreateDiscountCommandHandler : IRequestHandler().Add(productDis); break; default: var def = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, - request.IsForInvitation); + request.IsForInvitation,request.IsSpecialOffer); _repositoryWrapper.SetRepository().Add(def); break; } diff --git a/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs index 46622be..b230bf9 100644 --- a/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs @@ -12,7 +12,7 @@ public class GetDiscountsQueryHandler : IRequestHandler().TableNoTracking .OrderByDescending(b => b.CreatedAt) - .Skip(request.Page * 10).Take(10) + .Skip(request.Page * 15).Take(15) .Select(DiscountMapper.ProjectToSDto) .ToListAsync(cancellationToken); } diff --git a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs index 196af7f..cb34b04 100644 --- a/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/UpdateDiscountCommandHandler.cs @@ -16,7 +16,7 @@ public class UpdateDiscountCommandHandler : IRequestHandler().TableNoTracking.FirstOrDefaultAsync(d=>d.Id==request.Id,cancellationToken); if (ent == null) throw new AppException("Discount not found", ApiResultStatusCode.NotFound); - var newEnt = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation); + var newEnt = Discount.Create(request.Code, request.DiscountPercent, request.DiscountAmount, request.HasCode, request.AmountType, request.Type, request.Count, request.StartDate, request.ExpireDate, request.PriceFloor, request.HasPriceFloor, request.PriceCeiling, request.HasPriceCeiling, request.IsInfinity, request.UseCount, request.IsForInvitation, request.IsSpecialOffer); newEnt.Id = ent.Id; _repositoryWrapper.SetRepository().Update(newEnt); break; @@ -28,7 +28,7 @@ public class UpdateDiscountCommandHandler : IRequestHandler().Update(catDis); break; @@ -41,7 +41,7 @@ public class UpdateDiscountCommandHandler : IRequestHandler().Update(productDis); break; diff --git a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs index fb963fd..214b9a4 100644 --- a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs @@ -3,10 +3,12 @@ public class CreateProductCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; - public CreateProductCommandHandler(IRepositoryWrapper repositoryWrapper) + public CreateProductCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator) { _repositoryWrapper = repositoryWrapper; + _mediator = mediator; } public async Task Handle(CreateProductCommand request, CancellationToken cancellationToken) @@ -28,6 +30,27 @@ public class CreateProductCommandHandler : IRequestHandler().Add(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + if (request.IsSpecialOffer) + { + var discount = request.SpecialOffer.Adapt(); + discount.ProductId = ent.Id; + discount.IsSpecialOffer = true; + discount.Type = DiscountType.Product; + discount.HasCode = false; + discount.IsInfinity = true; + if (request.SpecialOffer.Id == default) + { + var discountRequest = discount.Adapt(); + await _mediator.Send(discountRequest, cancellationToken); + } + else + { + var discountRequest = discount.Adapt(); + await _mediator.Send(discountRequest, cancellationToken); + } + } + return ent.AdaptToLDto(); } } \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs index 152db43..07dbcfa 100644 --- a/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/GetProductQueryHandler.cs @@ -14,8 +14,23 @@ public class GetProductQueryHandler : IRequestHandler b.Id == request.Id) .Select(ProductMapper.ProjectToLDto) .FirstOrDefaultAsync(cancellationToken); + if (ent == null) throw new AppException("Product not found", ApiResultStatusCode.NotFound); + + var specialOffer = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(pd => pd.IsSpecialOffer && pd.ProductId == ent.Id) + .Select(DiscountMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + ent.SpecialOffer = specialOffer; + + if (ent.SpecialOffer == null || ent.SpecialOffer.ExpireDate.Date < DateTime.Today.Date) + ent.IsSpecialOffer = false; + else + ent.IsSpecialOffer = true; + return ent; } } \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs index 896e630..794bafa 100644 --- a/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/GetProductsQueryHandler.cs @@ -12,7 +12,7 @@ public class GetProductsQueryHandler : IRequestHandler().TableNoTracking; if (request.ProductName != null) - products = products.Where( p => p.PersianName.ToLower().Trim().Contains(request.ProductName.ToLower().Trim())); + products = products.Where(p => p.PersianName.ToLower().Trim().Contains(request.ProductName.ToLower().Trim())); if (request.CategoryId != default) products = products.Where(p => p.CategoryId == request.CategoryId); if (request.BrandId != default) @@ -62,7 +62,9 @@ public class GetProductsQueryHandler : IRequestHandler() .TableNoTracking - .FirstOrDefaultAsync(d => d.HasCode == false && d.ProductId == productSDto.Id && d.ExpireDate.Date > DateTime.Today.Date, cancellationToken); + .Where(d => d.HasCode == false && d.ProductId == productSDto.Id && d.ExpireDate.Date > DateTime.Today.Date) + .OrderByDescending(d => d.CreatedAt) + .FirstOrDefaultAsync(cancellationToken); if (productDiscount != null && !productDiscount.IsExpired()) { @@ -73,7 +75,10 @@ public class GetProductsQueryHandler : IRequestHandler 0) + productSDto.DiscountPercent = (100 * productSDto.CostWithDiscount) / productSDto.Cost; + if (productDiscount.IsSpecialOffer) + productSDto.IsSpecial = true; } } diff --git a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs index 19259bd..d5884fe 100644 --- a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs @@ -3,10 +3,12 @@ public class UpdateProductCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; - public UpdateProductCommandHandler(IRepositoryWrapper repositoryWrapper) + public UpdateProductCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator) { _repositoryWrapper = repositoryWrapper; + _mediator = mediator; } public async Task Handle(UpdateProductCommand request, CancellationToken cancellationToken) { @@ -37,7 +39,6 @@ public class UpdateProductCommandHandler : IRequestHandler s.Id == default)) { newEnt.AddSpecification(specification.Title, specification.Detail, specification.Value, specification.IsFeature, specification.ParentId); @@ -59,8 +60,31 @@ public class UpdateProductCommandHandler : IRequestHandler().Update(newEnt); await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + if (request.IsSpecialOffer) + { + var discount = request.SpecialOffer.Adapt(); + discount.ProductId = newEnt.Id; + discount.IsSpecialOffer = true; + discount.Type = DiscountType.Product; + discount.HasCode = false; + discount.IsInfinity = true; + if (request.SpecialOffer.Id == default) + { + var discountRequest = discount.Adapt(); + await _mediator.Send(discountRequest, cancellationToken); + } + else + { + var discountRequest = discount.Adapt(); + await _mediator.Send(discountRequest, cancellationToken); + } + } + return true; } } \ No newline at end of file diff --git a/NetinaShop.Repository/Migrations/20240202154106_editDiscount.Designer.cs b/NetinaShop.Repository/Migrations/20240202154106_editDiscount.Designer.cs new file mode 100644 index 0000000..8b5e7b7 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240202154106_editDiscount.Designer.cs @@ -0,0 +1,1586 @@ +// +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("20240202154106_editDiscount")] + partial class editDiscount + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.0") + .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") + .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("HasSpecialPage") + .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("PageUrl") + .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("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") + .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") + .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") + .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("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") + .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") + .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("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") + .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("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("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("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") + .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("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .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) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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) + .IsRequired(); + + 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/20240202154106_editDiscount.cs b/NetinaShop.Repository/Migrations/20240202154106_editDiscount.cs new file mode 100644 index 0000000..d4acdcb --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240202154106_editDiscount.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class editDiscount : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsSpecialOffer", + schema: "public", + table: "Discounts", + type: "boolean", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsSpecialOffer", + schema: "public", + table: "Discounts"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index af91875..a22981c 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -326,6 +326,9 @@ namespace NetinaShop.Repository.Migrations b.Property("IsRemoved") .HasColumnType("boolean"); + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + b.Property("ModifiedAt") .HasColumnType("timestamp without time zone"); diff --git a/Tools/NetinaShop.WordPressDBConverter/Program.cs b/Tools/NetinaShop.WordPressDBConverter/Program.cs index 1bc1e77..aa3aef1 100644 --- a/Tools/NetinaShop.WordPressDBConverter/Program.cs +++ b/Tools/NetinaShop.WordPressDBConverter/Program.cs @@ -106,13 +106,13 @@ try 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, - false,10, brandId, categoryId, - new List(), new List()); + 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, - brandId,categoryId, - new List(), new List()); + false,brandId,categoryId, + new DiscountSDto(),new List(), new List()); products.Add(product); }