From 0a1c080581c1675ef2bd7ec4567949eef08f8e8d Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sun, 31 Dec 2023 19:55:22 +0330 Subject: [PATCH] add version 0.0.0.1 complete basic controller , complet basic entities , complete authorize , complete commands and queries , complete cqrs and handlers --- .version | 1 + .../AppSettings/appsettings.Development.json | 3 + NetinaShop.Api/Controller/AuthController.cs | 1 + .../Controller/DiscountController.cs | 5 +- .../Controller/OrderBagController.cs | 60 ++ NetinaShop.Api/Controller/OrderController.cs | 32 ++ .../Controller/ProductController.cs | 4 +- .../Controller/ShippingController.cs | 12 +- NetinaShop.Api/Program.cs | 1 + .../MiddleWares/ExceptionHandlerMiddleware.cs | 15 +- .../Extensions/EnumExtensions.cs | 3 +- .../Extensions/PropertyExtensions.cs | 3 +- .../Models/Api/ApiResultStatusCode.cs | 3 +- NetinaShop.Common/Models/Entity/ApiEntity.cs | 4 +- NetinaShop.Core/NetinaShop.Core.csproj | 1 - .../Commands/DiscountCommands.cs | 4 +- .../Commands/OrderBagCommands.cs | 12 + .../CommandQueries/Commands/OrderCommands.cs | 7 + .../Commands/ProductCommands.cs | 10 +- .../Commands/ShippingCommands.cs | 6 +- .../CommandQueries/Queries/OrderBagQueries.cs | 3 + .../CommandQueries/Queries/OrderQueries.cs | 6 + .../CommandQueries/Queries/ShippingQueries.cs | 4 + NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs | 4 +- NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs | 22 + .../Dtos/LargDtos/ProductLDto.cs | 2 +- .../RequestDtos/OrderProductRequestDto.cs | 7 + .../SubmitOrderPaymentResponseDto.cs | 7 + NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs | 4 +- NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs | 4 +- .../Dtos/SmallDtos/DiscountSDto.cs | 4 +- .../Dtos/SmallDtos/OrderDeliverySDto.cs | 12 + .../Dtos/SmallDtos/OrderProductSDto.cs | 14 + NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs | 17 + .../Dtos/SmallDtos/ProductCategorySDto.cs | 9 - .../Dtos/SmallDtos/ShippingSDto.cs | 4 +- .../Dtos/SmallDtos/StorageFileSDto.cs | 4 +- .../Entities/Blogs/Blog.Aggregate.cs | 4 +- .../Entities/Blogs/BlogStorageFile.cs | 4 +- .../Entities/Brands/BrandStorageFile.cs | 4 +- .../Entities/Categories/Category.cs | 2 +- .../Categories/CategoryStorageFile.cs | 4 +- .../Entities/Orders/Order.Aggregate.cs | 112 ++++ NetinaShop.Domain/Entities/Orders/Order.cs | 59 +- .../Entities/Orders/OrderDelivery.cs | 19 +- .../Entities/Orders/OrderProduct.cs | 29 +- .../Entities/Products/Product.Aggregate.cs | 20 +- .../Entities/Products/Product.cs | 17 +- .../Entities/Products/ProductCategory.cs | 22 - .../Entities/Warehouses/Shipping.cs | 5 +- .../Warehouses/Warehouses.Aggregate.cs | 4 +- NetinaShop.Domain/Enums/OrderPaymentMethod.cs | 11 + NetinaShop.Domain/Mappers/OrderMapper.g.cs | 533 +++++++++++++++++ .../Mappers/ProductCategoryMapper.g.cs | 66 --- NetinaShop.Domain/Mappers/ProductMapper.g.cs | 537 +++++++----------- NetinaShop.Domain/MapsterRegister.cs | 4 +- NetinaShop.Domain/Models/Claims/ClaimDto.cs | 4 +- .../Models/Settings/SiteSettings.cs | 6 + NetinaShop.Domain/NetinaShop.Domain.csproj | 4 +- .../Abstracts/IPaymentService.cs | 7 + .../CreateCategoryCommandHandler.cs | 6 +- .../DeleteCategoryCommandHandler.cs | 4 +- .../Categories/GetCategoriesQueryHandler.cs | 6 +- .../Categories/GetCategoryQueryHandler.cs | 7 +- .../UpdateCategoryCommandHandler.cs | 4 +- .../CalculateDiscountCommandHandler.cs | 59 ++ .../Discounts/CreateDiscountCommandHandler.cs | 4 +- .../OrderBags/AddToOrderBagCommandHandler.cs | 45 ++ .../OrderBags/GetUserOrderBagQueryHandler.cs | 42 ++ .../RemoveFromOrderBagCommandHandler.cs | 44 ++ .../OrderBags/SubmitDiscountCommandHandler.cs | 29 + .../SubmitOrderDeliveryCommandHandler.cs | 38 ++ .../SubmitOrderPaymentCommandHandler.cs | 51 ++ .../Orders/CalculateOrderCommandHandler.cs | 43 ++ .../Orders/CreateBaseOrderCommandHandler.cs | 27 + .../Orders/DeleteOrderCommandHandler.cs | 24 + .../Handlers/Orders/GetOrderQueryHandler.cs | 38 ++ .../Handlers/Orders/GetOrdersQueryHandler.cs | 23 + .../Products/CreateProductCommandHandler.cs | 7 +- .../Products/DeleteProductCommandHandler.cs | 4 +- .../Products/UpdateProductCommandHandler.cs | 19 +- .../CreateShippingCommandHandler.cs | 5 +- .../Warehouses/GetShippingQueryHandler.cs | 22 + .../Warehouses/GetShippingsQueryHandler.cs | 23 + .../UpdateShippingCommandHandler.cs | 2 +- ...ner.cs => 20231231111356_Init.Designer.cs} | 313 +++++----- ...1073413_init.cs => 20231231111356_Init.cs} | 229 ++++---- .../ApplicationContextModelSnapshot.cs | 309 +++++----- .../NetinaShop.Repository.csproj | 1 + .../Repositories/Base/ReadRepository.cs | 7 +- .../Repositories/Entity/DiscountRepository.cs | 5 +- NetinaShop.sln | 15 +- 92 files changed, 2182 insertions(+), 1064 deletions(-) create mode 100644 .version create mode 100644 NetinaShop.Api/Controller/OrderBagController.cs create mode 100644 NetinaShop.Api/Controller/OrderController.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/OrderBagQueries.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs create mode 100644 NetinaShop.Domain/CommandQueries/Queries/ShippingQueries.cs create mode 100644 NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs create mode 100644 NetinaShop.Domain/Dtos/RequestDtos/OrderProductRequestDto.cs create mode 100644 NetinaShop.Domain/Dtos/ResponseDtos/SubmitOrderPaymentResponseDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs create mode 100644 NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs delete mode 100644 NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs create mode 100644 NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs delete mode 100644 NetinaShop.Domain/Entities/Products/ProductCategory.cs create mode 100644 NetinaShop.Domain/Enums/OrderPaymentMethod.cs create mode 100644 NetinaShop.Domain/Mappers/OrderMapper.g.cs delete mode 100644 NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs create mode 100644 NetinaShop.Repository/Abstracts/IPaymentService.cs create mode 100644 NetinaShop.Repository/Handlers/Discounts/CalculateDiscountCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/AddToOrderBagCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/GetUserOrderBagQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/RemoveFromOrderBagCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/SubmitDiscountCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/SubmitOrderDeliveryCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/OrderBags/SubmitOrderPaymentCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Orders/CalculateOrderCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs create mode 100644 NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs rename NetinaShop.Repository/Migrations/{20231211073413_init.Designer.cs => 20231231111356_Init.Designer.cs} (92%) rename NetinaShop.Repository/Migrations/{20231211073413_init.cs => 20231231111356_Init.cs} (92%) diff --git a/.version b/.version new file mode 100644 index 0000000..b87eee8 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +0.0.0.1 \ No newline at end of file diff --git a/NetinaShop.Api/AppSettings/appsettings.Development.json b/NetinaShop.Api/AppSettings/appsettings.Development.json index 6d1ab7b..de28cc0 100644 --- a/NetinaShop.Api/AppSettings/appsettings.Development.json +++ b/NetinaShop.Api/AppSettings/appsettings.Development.json @@ -12,6 +12,9 @@ "Microsoft.AspNetCore.Http.Connections": "Debug" } }, + "ShopSettings": { + "TaxesFee": 9 + }, "SiteSettings": { "BaseUrl": "http://localhost:32770", "KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B", diff --git a/NetinaShop.Api/Controller/AuthController.cs b/NetinaShop.Api/Controller/AuthController.cs index 2c8955e..4cf758f 100644 --- a/NetinaShop.Api/Controller/AuthController.cs +++ b/NetinaShop.Api/Controller/AuthController.cs @@ -11,6 +11,7 @@ public class AuthController : ICarterModule group.MapPost("login/password", LoginWithPassword) .WithDisplayName("LoginWithPassword") .HasApiVersion(1.0); + group.MapPost("login/swagger", LoginSwagger) .WithDisplayName("LoginSwagger") .HasApiVersion(1.0); diff --git a/NetinaShop.Api/Controller/DiscountController.cs b/NetinaShop.Api/Controller/DiscountController.cs index 8d11ce0..1654767 100644 --- a/NetinaShop.Api/Controller/DiscountController.cs +++ b/NetinaShop.Api/Controller/DiscountController.cs @@ -1,7 +1,4 @@ -using MediatR; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace NetinaShop.Api.Controller; +namespace NetinaShop.Api.Controller; public class DiscountController : ICarterModule { diff --git a/NetinaShop.Api/Controller/OrderBagController.cs b/NetinaShop.Api/Controller/OrderBagController.cs new file mode 100644 index 0000000..20afe69 --- /dev/null +++ b/NetinaShop.Api/Controller/OrderBagController.cs @@ -0,0 +1,60 @@ +using NetinaShop.Domain.Enums; + +namespace NetinaShop.Api.Controller; + +public class OrderBagController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("OrderBag") + .MapGroup("api/order/bag") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetUserCurrentOrderBagAsync) + .WithDisplayName("GetUserCurrentOrderBagAsync") + .HasApiVersion(1.0); + + group.MapPost("add/{productId}", AddProductToBagAsync) + .WithDisplayName("AddProductToBag") + .HasApiVersion(1.0); + + group.MapPost("remove/{productId}", RemoveFromOrderBagAsync) + .WithDisplayName("RemoveFromOrderBag") + .HasApiVersion(1.0); + + + group.MapPost("discount/{orderId}", AddDiscountToOrderBagAsync) + .WithDisplayName("AddDiscountToOrderBag") + .HasApiVersion(1.0); + + + group.MapPost("shipping/{orderId}", AddShippingToOrderBagAsync) + .WithDisplayName("AddShippingToOrderBag") + .HasApiVersion(1.0); + + group.MapPost("payment/{orderId}", SubmitOrderPaymentAsync) + .WithDisplayName("SubmitOrderPayment") + .HasApiVersion(1.0); + } + + 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 RemoveFromOrderBagAsync(Guid productId, [FromQuery] int count, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new RemoveFromOrderBagCommand(productId, count), cancellationToken)); + + public async Task AddDiscountToOrderBagAsync(Guid orderId, [FromQuery] string discountCode, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken)); + + public async Task AddShippingToOrderBagAsync(Guid orderId, [FromBody] SubmitOrderDeliveryCommand request, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok( + await mediator.Send(new SubmitOrderDeliveryCommand(request.Address, request.PostalCode, + request.ReceiverPhoneNumber, request.ReceiverFullName, orderId, request.ShippingId), cancellationToken)); + + public async Task SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok( await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken)); +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/OrderController.cs b/NetinaShop.Api/Controller/OrderController.cs new file mode 100644 index 0000000..735a548 --- /dev/null +++ b/NetinaShop.Api/Controller/OrderController.cs @@ -0,0 +1,32 @@ +namespace NetinaShop.Api.Controller; +public class OrderController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Order") + .MapGroup("api/order") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllOrders") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetOneOrder") + .HasApiVersion(1.0); + + group.MapDelete("{id}", DeleteAsync) + .WithDisplayName("DeleteOneOrder") + .HasApiVersion(1.0); + + } + + public async Task GetAllAsync(IMediator mediator, [FromQuery] int page = 0, CancellationToken cancellationToken = default) + => TypedResults.Ok(await mediator.Send(new GetOrdersQuery(page), cancellationToken)); + + public async Task GetAsync(IMediator mediator,Guid id, CancellationToken cancellationToken = default) + => TypedResults.Ok(await mediator.Send(new GetOrderLDtoQuery(id), cancellationToken)); + + public async Task DeleteAsync(IMediator mediator, Guid id, CancellationToken cancellationToken = default) + => TypedResults.Ok(await mediator.Send(new DeleteOrderCommand(id), cancellationToken)); +} diff --git a/NetinaShop.Api/Controller/ProductController.cs b/NetinaShop.Api/Controller/ProductController.cs index 1fe53b8..6b85bad 100644 --- a/NetinaShop.Api/Controller/ProductController.cs +++ b/NetinaShop.Api/Controller/ProductController.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Products; - -namespace NetinaShop.Api.Controller; +namespace NetinaShop.Api.Controller; public class ProductController : ICarterModule { diff --git a/NetinaShop.Api/Controller/ShippingController.cs b/NetinaShop.Api/Controller/ShippingController.cs index bd7395c..bfa4ba8 100644 --- a/NetinaShop.Api/Controller/ShippingController.cs +++ b/NetinaShop.Api/Controller/ShippingController.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Warehouses; - -namespace NetinaShop.Api.Controller; +namespace NetinaShop.Api.Controller; public class ShippingController : ICarterModule { @@ -30,12 +28,12 @@ public class ShippingController : ICarterModule } // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) - => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.OrderByDescending(b => b.CreatedAt).Skip(page * 10).Take(10).ToListAsync(cancellationToken)); + public async Task GetAllAsync([FromQuery] int page, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetShippingsQuery(page),cancellationToken)); // GET:Get An Entity By Id - public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) - => TypedResults.Ok(await repositoryWrapper.SetRepository().TableNoTracking.Where(b => b.Id == id).FirstOrDefaultAsync(cancellationToken)); + public async Task GetAsync(Guid id, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetShippingQuery(id), cancellationToken)); // POST:Create Entity public async Task Post([FromBody] CreateShippingCommand request, IMediator mediator, CancellationToken cancellationToken) diff --git a/NetinaShop.Api/Program.cs b/NetinaShop.Api/Program.cs index ea7295d..66e9c5c 100644 --- a/NetinaShop.Api/Program.cs +++ b/NetinaShop.Api/Program.cs @@ -14,6 +14,7 @@ if (builder.Environment.IsProduction()) var configuration = builder.Configuration; var siteSetting = configuration.GetSection(nameof(SiteSettings)).Get(); builder.Services.Configure(configuration.GetSection(nameof(SiteSettings))); +builder.Services.Configure(configuration.GetSection(nameof(ShopSettings))); diff --git a/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs b/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs index ac9f1ec..56ef71e 100644 --- a/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs +++ b/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs @@ -94,13 +94,16 @@ public class ExceptionHandlerMiddleware if (_env.IsDevelopment()) { - var dic = new Dictionary + if (exception?.InnerException?.Message != null) { - ["Exception"] = exception.Message, - ["InnerException"] = exception.InnerException?.Message, - ["StackTrace"] = exception.StackTrace - }; - message = JsonConvert.SerializeObject(dic); + var dic = new Dictionary + { + ["Exception"] = exception.Message, + ["InnerException"] = exception?.InnerException?.Message, + ["StackTrace"] = exception?.StackTrace + }; + message = JsonConvert.SerializeObject(dic); + } } message = exception.Message; diff --git a/NetinaShop.Common/Extensions/EnumExtensions.cs b/NetinaShop.Common/Extensions/EnumExtensions.cs index 42c184e..b0a5e4b 100644 --- a/NetinaShop.Common/Extensions/EnumExtensions.cs +++ b/NetinaShop.Common/Extensions/EnumExtensions.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.Reflection; +using System.Reflection; namespace NetinaShop.Common.Extensions { diff --git a/NetinaShop.Common/Extensions/PropertyExtensions.cs b/NetinaShop.Common/Extensions/PropertyExtensions.cs index 1e70e2b..850dabc 100644 --- a/NetinaShop.Common/Extensions/PropertyExtensions.cs +++ b/NetinaShop.Common/Extensions/PropertyExtensions.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.Reflection; +using System.Reflection; namespace NetinaShop.Common.Extensions { diff --git a/NetinaShop.Common/Models/Api/ApiResultStatusCode.cs b/NetinaShop.Common/Models/Api/ApiResultStatusCode.cs index a4f187a..bb71b80 100644 --- a/NetinaShop.Common/Models/Api/ApiResultStatusCode.cs +++ b/NetinaShop.Common/Models/Api/ApiResultStatusCode.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.Net; +using System.Net; namespace NetinaShop.Common.Models.Api { diff --git a/NetinaShop.Common/Models/Entity/ApiEntity.cs b/NetinaShop.Common/Models/Entity/ApiEntity.cs index c43143f..617c85b 100644 --- a/NetinaShop.Common/Models/Entity/ApiEntity.cs +++ b/NetinaShop.Common/Models/Entity/ApiEntity.cs @@ -25,14 +25,14 @@ public abstract class ApiEntity : IApiEntity , IEquatable - public bool Equals(ApiEntity? other) + public bool Equals(ApiEntity other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Id.Equals(other.Id); } - public override bool Equals(object? obj) + public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; diff --git a/NetinaShop.Core/NetinaShop.Core.csproj b/NetinaShop.Core/NetinaShop.Core.csproj index a83ffd2..44bc97d 100644 --- a/NetinaShop.Core/NetinaShop.Core.csproj +++ b/NetinaShop.Core/NetinaShop.Core.csproj @@ -24,7 +24,6 @@ - diff --git a/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs index fa5fb5f..14642b8 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/DiscountCommands.cs @@ -39,4 +39,6 @@ public sealed record UpdateDiscountCommand(Guid Id, Guid ProductId, Guid CategoryId) : IRequest; -public sealed record DeleteDiscountCommand(Guid Id) : IRequest; \ No newline at end of file +public sealed record DeleteDiscountCommand(Guid Id) : IRequest; + +public sealed record CalculateDiscountCommand(string DiscountCode,Order Order) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs new file mode 100644 index 0000000..4a2c973 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs @@ -0,0 +1,12 @@ +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 SubmitDiscountCommand(Guid OrderId,string DiscountCode) : IRequest; +public sealed record SubmitOrderDeliveryCommand(string Address, string PostalCode, string ReceiverPhoneNumber, string ReceiverFullName, Guid OrderId, Guid ShippingId) : IRequest; + +public sealed record SubmitOrderPaymentCommand(Guid OrderId, OrderPaymentMethod PaymentMethod) : IRequest; + diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs new file mode 100644 index 0000000..1a87922 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderCommands.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreateBaseOrderCommand(Guid UserId) : IRequest; + +public sealed record CalculateOrderCommand(Guid OrderId) : IRequest; + +public sealed record DeleteOrderCommand(Guid OrderId) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs index 3caf7d8..b5bff90 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ProductCommands.cs @@ -7,9 +7,12 @@ string Summery, string ExpertCheck, string Tags, string Warranty, +bool BeDisplayed, +double Cost, +double PackingCost, Guid BrandId, string BrandNames , -List Categories, +Guid CategoryId, List Specifications, List Files):IRequest; @@ -21,9 +24,12 @@ public sealed record UpdateProductCommand( string ExpertCheck, string Tags, string Warranty, + bool BeDisplayed, + double Cost, + double PackingCost, Guid BrandId, string BrandNames, - List Categories, + Guid CategoryId, List Specifications, List Files) : IRequest; public sealed record DeleteProductCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs index 8e53e78..9253418 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/ShippingCommands.cs @@ -5,7 +5,8 @@ public sealed record CreateShippingCommand ( string WarehouseName, bool IsFastShipping , bool IsShipBySeller , - bool IsOriginalWarehouse) : IRequest; + bool IsOriginalWarehouse, + double DeliveryCost) : IRequest; public sealed record UpdateShippingCommand( Guid Id, @@ -13,7 +14,8 @@ public sealed record UpdateShippingCommand( string WarehouseName, bool IsFastShipping, bool IsShipBySeller, - bool IsOriginalWarehouse) : IRequest; + bool IsOriginalWarehouse, + double DeliveryCost) : IRequest; public sealed record DeleteShippingCommand( Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/OrderBagQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/OrderBagQueries.cs new file mode 100644 index 0000000..dbb644c --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/OrderBagQueries.cs @@ -0,0 +1,3 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public record GetUserOrderBagQuery() : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs new file mode 100644 index 0000000..443d48e --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs @@ -0,0 +1,6 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public sealed record GetOrderLDtoQuery(Guid Id) : IRequest; + +public sealed record GetOrderQuery(Guid Id) : IRequest; +public sealed record GetOrdersQuery(int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/ShippingQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/ShippingQueries.cs new file mode 100644 index 0000000..5171889 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/ShippingQueries.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public sealed record GetShippingsQuery(int Page = 0) : IRequest>; +public sealed record GetShippingQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs index 18829be..40dabfd 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/BrandLDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Brands; - -namespace NetinaShop.Domain.Dtos.LargDtos; +namespace NetinaShop.Domain.Dtos.LargDtos; public class BrandLDto : BaseDto { diff --git a/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs new file mode 100644 index 0000000..b21a9e6 --- /dev/null +++ b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs @@ -0,0 +1,22 @@ +namespace NetinaShop.Domain.Dtos.LargDtos; +public class OrderLDto : BaseDto +{ + public long TotalPrice { get; set; } + public long DeliveryPrice { get; set; } + public long TaxesPrice { get; set; } + public long ServicePrice { get; set; } + public long PackingPrice { get; set; } + public long TotalProductsPrice { get; set; } + public long DiscountPrice { get; set; } + public bool IsPayed { get; set; } + public OrderStatus OrderStatus { get; set; } + public DateTime DoneAt { get; set; } + public DateTime OrderAt { get; set; } + public int PreparingMinute { get; set; } + public string DiscountCode { get; set; } = string.Empty; + + public List OrderProducts { get; internal set; } = new(); + + public List OrderDeliveries { get; internal set; } = new(); +} + diff --git a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs index f66c436..6b2e4a0 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/ProductLDto.cs @@ -13,6 +13,6 @@ public class ProductLDto : BaseDto public List Specifications { get; set; } = new(); public List Reviews { get; set; } = new(); - public List Categories { get; set; } = new(); + public List Categories { get; set; } = new(); public List Files { get; set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/RequestDtos/OrderProductRequestDto.cs b/NetinaShop.Domain/Dtos/RequestDtos/OrderProductRequestDto.cs new file mode 100644 index 0000000..64abbd1 --- /dev/null +++ b/NetinaShop.Domain/Dtos/RequestDtos/OrderProductRequestDto.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.Dtos.RequestDtos; +public class OrderProductRequestDto +{ + public int Count { get; internal set; } + public Guid ProductId { get; internal set; } +} + diff --git a/NetinaShop.Domain/Dtos/ResponseDtos/SubmitOrderPaymentResponseDto.cs b/NetinaShop.Domain/Dtos/ResponseDtos/SubmitOrderPaymentResponseDto.cs new file mode 100644 index 0000000..773891b --- /dev/null +++ b/NetinaShop.Domain/Dtos/ResponseDtos/SubmitOrderPaymentResponseDto.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Domain.Dtos.ResponseDtos; + +public class SubmitOrderPaymentResponseDto +{ + public string PaymentUrl { get; set; } = string.Empty; + public bool NeedToPayOnline { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs index 83e63bf..96c2c01 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/BlogSDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Blogs; - -namespace NetinaShop.Domain.Dtos.SmallDtos; +namespace NetinaShop.Domain.Dtos.SmallDtos; public class BlogSDto : BaseDto { diff --git a/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs index 1fa0af1..6aeb141 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/BrandSDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Brands; - -namespace NetinaShop.Domain.Dtos.SmallDtos; +namespace NetinaShop.Domain.Dtos.SmallDtos; public class BrandSDto : BaseDto { diff --git a/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs index 18df5ca..51e5ca9 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/DiscountSDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Discounts; - -namespace NetinaShop.Domain.Dtos.SmallDtos; +namespace NetinaShop.Domain.Dtos.SmallDtos; public class DiscountSDto : BaseDto { diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs new file mode 100644 index 0000000..ddc72cc --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs @@ -0,0 +1,12 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class OrderDeliverySDto : BaseDto +{ + public string Address { get; set; } = string.Empty; + public string PostalCode { get; set; } = string.Empty; + public string ReceiverPhoneNumber { get; set; } = string.Empty; + public string ReceiverFullName { get; set; } = string.Empty; + public Guid OrderId { get; set; } + public Guid ShippingId { get; internal set; } +} + diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs new file mode 100644 index 0000000..d34fdff --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs @@ -0,0 +1,14 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class OrderProductSDto : BaseDto +{ + public int Count { get; internal set; } + public float ProductFee { get; internal set; } + public float ProductCost { get; internal set; } + public OrderStatus OrderProductStatus { get; internal set; } + + public Guid ProductId { get; internal set; } + + public Guid OrderId { get; internal set; } +} + diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs new file mode 100644 index 0000000..d37cf1c --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs @@ -0,0 +1,17 @@ +namespace NetinaShop.Domain.Dtos.SmallDtos; +public class OrderSDto : BaseDto +{ + public long TotalPrice { get; set; } + public long DeliveryPrice { get; set; } + public long TaxesPrice { get; set; } + public long ServicePrice { get; set; } + public long PackingPrice { get; set; } + public long TotalProductsPrice { get; set; } + public long DiscountPrice { get; set; } + public bool IsPayed { get; set; } + public OrderStatus OrderStatus { get; set; } + public DateTime DoneAt { get; set; } + public DateTime OrderAt { get; set; } + public int PreparingMinute { get; set; } + public string DiscountCode { get; set; } = string.Empty; +} diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs deleted file mode 100644 index 3642468..0000000 --- a/NetinaShop.Domain/Dtos/SmallDtos/ProductCategorySDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NetinaShop.Domain.Dtos.SmallDtos; - -public class ProductCategorySDto : BaseDto -{ - - public Guid CategoryId { get; set; } - public string CategoryName { get; set; } = string.Empty; - public Guid ProductId { get; set; } -} \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs index 3d34620..a43a6b8 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/ShippingSDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Warehouses; - -namespace NetinaShop.Domain.Dtos.SmallDtos; +namespace NetinaShop.Domain.Dtos.SmallDtos; public class ShippingSDto : BaseDto { diff --git a/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs index 5e856f7..3c73894 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/StorageFileSDto.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.StorageFiles; - -namespace NetinaShop.Domain.Dtos.SmallDtos; +namespace NetinaShop.Domain.Dtos.SmallDtos; public class StorageFileSDto : BaseDto { diff --git a/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs b/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs index 0338968..9b0bfdb 100644 --- a/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Blogs/Blog.Aggregate.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.StorageFiles; - -namespace NetinaShop.Domain.Entities.Blogs; +namespace NetinaShop.Domain.Entities.Blogs; public partial class Blog { diff --git a/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs b/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs index b6bf22f..9de2a22 100644 --- a/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs +++ b/NetinaShop.Domain/Entities/Blogs/BlogStorageFile.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.StorageFiles; - -namespace NetinaShop.Domain.Entities.Blogs; +namespace NetinaShop.Domain.Entities.Blogs; public partial class BlogStorageFile : StorageFile { diff --git a/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs b/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs index ad78a6f..9cab078 100644 --- a/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs +++ b/NetinaShop.Domain/Entities/Brands/BrandStorageFile.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.StorageFiles; - -namespace NetinaShop.Domain.Entities.Brands; +namespace NetinaShop.Domain.Entities.Brands; public partial class BrandStorageFile : StorageFile { diff --git a/NetinaShop.Domain/Entities/Categories/Category.cs b/NetinaShop.Domain/Entities/Categories/Category.cs index ebfea65..a381b51 100644 --- a/NetinaShop.Domain/Entities/Categories/Category.cs +++ b/NetinaShop.Domain/Entities/Categories/Category.cs @@ -22,6 +22,6 @@ public partial class Category : ApiEntity public Category? Parent { get; internal set; } public List Children { get; internal set; } = new(); - public List Products { get; internal set; } = new(); + public List Products { get; internal set; } = new(); public List Files { get; internal set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs b/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs index 263ba45..4e10313 100644 --- a/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs +++ b/NetinaShop.Domain/Entities/Categories/CategoryStorageFile.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.StorageFiles; - -namespace NetinaShop.Domain.Entities.Categories; +namespace NetinaShop.Domain.Entities.Categories; public partial class CategoryStorageFile : StorageFile { diff --git a/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs new file mode 100644 index 0000000..513e7ee --- /dev/null +++ b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs @@ -0,0 +1,112 @@ +namespace NetinaShop.Domain.Entities.Orders; + +public partial class Order +{ + public static Order Create(Guid userId) + { + return new Order(0, 0, 0, 0, 0, 0, 0, false, OrderStatus.OrderBag, DateTime.MinValue, DateTime.MinValue, 0, string.Empty, userId, OrderPaymentMethod.OnlinePayment); + + } + + public void AddToOrderBag(Product product, int count) + { + var orderProduct = OrderProducts.FirstOrDefault(op => op.ProductId == product.Id); + if (orderProduct == null) + { + orderProduct = OrderProduct.Create(count, product.Cost,product.PackingCost, OrderStatus.OrderBag, product.Id,product.CategoryId, this.Id); + OrderProducts.Add(orderProduct); + } + else + { + orderProduct.SetCount(count); + } + } + public void RemoveFromOrderBag(Product product, int count) + { + var orderProduct = OrderProducts.FirstOrDefault(op => op.ProductId == product.Id); + if (orderProduct != null) + { + orderProduct.SetCount(count); + if (orderProduct.Count == 0) + OrderProducts.Remove(orderProduct); + } + } + + public void SetDiscount(string discountCode) + => DiscountCode = discountCode; + public void AddOrderProduct(OrderProduct orderProduct) + => OrderProducts.Add(orderProduct); + + public void SetSubmitOrder(OrderPaymentMethod paymentMethod) + { + switch (paymentMethod) + { + case OrderPaymentMethod.OnlinePayment: + OrderStatus = OrderStatus.Paid; + IsPayed = true; + PayedAt = DateTime.Now; + OrderAt = DateTime.Now; + PaymentMethod = paymentMethod; + break; + case OrderPaymentMethod.CardTransfer: + OrderStatus = OrderStatus.Submitted; + IsPayed = false; + OrderAt = DateTime.Now; + PaymentMethod = paymentMethod; + break; + case OrderPaymentMethod.Cash: + OrderStatus = OrderStatus.Submitted; + IsPayed = false; + OrderAt = DateTime.Now; + PaymentMethod = paymentMethod; + break; + } + } + + public void AddOrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + { + var orderDelivery = OrderDelivery.Create(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId); + OrderDeliveries.Add(orderDelivery); + } + + public void SetTotalPrice(double totalProductPrice, + double packingPrice, + double servicePrice, + double deliveryPrice, + double discountPrice, + double taxesPrice) + { + TotalProductsPrice = totalProductPrice; + PackingPrice = packingPrice; + ServicePrice = servicePrice; + DeliveryPrice = deliveryPrice; + TaxesPrice = taxesPrice; + DiscountPrice = discountPrice; + TotalPrice = (totalProductPrice + packingPrice + servicePrice + deliveryPrice + taxesPrice) - discountPrice; + } + +} + +public partial class OrderProduct +{ + public static OrderProduct Create(int count, double productFee, double packingFee, OrderStatus orderProductStatus, Guid productId, Guid productCategoryId, Guid orderId) + { + var productCost = count * productFee; + var packingCost = count * packingFee; + return new OrderProduct(count, productFee, productCost,packingFee,packingCost, orderProductStatus, productId,productCategoryId, orderId); + } + + public void SetCount(int count) + { + Count = count; + var productCost = ProductFee * Count; + } +} + +public partial class OrderDelivery +{ + public static OrderDelivery Create(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + { + return new OrderDelivery(address, postalCode, receiverPhoneNumber, receiverFullName, deliveryCost, shippingId, orderId); + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/Order.cs b/NetinaShop.Domain/Entities/Orders/Order.cs index 155d0d4..a7e411f 100644 --- a/NetinaShop.Domain/Entities/Orders/Order.cs +++ b/NetinaShop.Domain/Entities/Orders/Order.cs @@ -1,20 +1,63 @@ namespace NetinaShop.Domain.Entities.Orders; -public class Order : ApiEntity +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] +[GenerateMapper] + +public partial class Order : ApiEntity { - public long TotalPrice { get; internal set; } - public long DeliveryPrice { get; internal set; } - public long TaxesPrice { get; internal set; } - public long ServicePrice { get; internal set; } - public long PackingPrice { get; internal set; } - public long TotalProductsPrice { get; internal set; } - public long DiscountPrice { get; internal set; } + public Order() + { + + } + public Order( + double totalPrice, + double deliveryPrice, + double taxesPrice, + double servicePrice, + double packingPrice, + double totalProductsPrice, + double discountPrice, + bool isPayed, OrderStatus orderStatus, DateTime doneAt, DateTime orderAt, int preparingMinute, string discountCode, Guid userId, OrderPaymentMethod paymentMethod) + { + TotalPrice = totalPrice; + DeliveryPrice = deliveryPrice; + TaxesPrice = taxesPrice; + ServicePrice = servicePrice; + PackingPrice = packingPrice; + TotalProductsPrice = totalProductsPrice; + DiscountPrice = discountPrice; + IsPayed = isPayed; + OrderStatus = orderStatus; + DoneAt = doneAt; + OrderAt = orderAt; + PreparingMinute = preparingMinute; + DiscountCode = discountCode; + UserId = userId; + PaymentMethod = paymentMethod; + } + + public double TotalProductsPrice { get; internal set; } + public double PackingPrice { get; internal set; } + public double ServicePrice { get; internal set; } + public double DeliveryPrice { get; internal set; } + public double DiscountPrice { get; internal set; } + public double TaxesPrice { get; internal set; } + public double TotalPrice { get; internal set; } public bool IsPayed { get; internal set; } + public DateTime PayedAt { get; internal set; } + public OrderPaymentMethod PaymentMethod { get; internal set; } public OrderStatus OrderStatus { get; internal set; } public DateTime DoneAt { get; internal set; } public DateTime OrderAt { get; internal set; } public int PreparingMinute { get; internal set; } public string DiscountCode { get; internal set; } = string.Empty; + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } + public List OrderProducts { get; internal set; } = new(); + + public List OrderDeliveries { get; internal set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs b/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs index ccb562f..b9ba396 100644 --- a/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs +++ b/NetinaShop.Domain/Entities/Orders/OrderDelivery.cs @@ -1,11 +1,28 @@ namespace NetinaShop.Domain.Entities.Orders; -public class OrderDelivery : ApiEntity +public partial class OrderDelivery : ApiEntity { + public OrderDelivery() + { + + } + public OrderDelivery(string address, string postalCode, string receiverPhoneNumber, string receiverFullName, double deliveryCost, Guid shippingId, Guid orderId) + { + Address = address; + PostalCode = postalCode; + ReceiverPhoneNumber = receiverPhoneNumber; + ReceiverFullName = receiverFullName; + DeliveryCost = deliveryCost; + ShippingId = shippingId; + OrderId = orderId; + } public string Address { get; internal set; } = string.Empty; public string PostalCode { get; internal set; } = string.Empty; public string ReceiverPhoneNumber { get; internal set; } = string.Empty; public string ReceiverFullName { get; internal set; } = string.Empty; + public double DeliveryCost { get; internal set; } + public Guid ShippingId { get; internal set; } + public Shipping? Shipping { get; internal set; } public Guid OrderId { get; internal set; } public Order? Order { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/OrderProduct.cs b/NetinaShop.Domain/Entities/Orders/OrderProduct.cs index eb9cef5..08ed5bd 100644 --- a/NetinaShop.Domain/Entities/Orders/OrderProduct.cs +++ b/NetinaShop.Domain/Entities/Orders/OrderProduct.cs @@ -1,15 +1,32 @@ -using NetinaShop.Domain.Entities.Products; +namespace NetinaShop.Domain.Entities.Orders; -namespace NetinaShop.Domain.Entities.Orders; - -public class OrderProduct : ApiEntity +public partial class OrderProduct : ApiEntity { + public OrderProduct() + { + + } + public OrderProduct(int count, double productFee, double productCost, double packingFee, double packingCost, OrderStatus orderProductStatus, Guid productId, Guid productCategoryId, Guid orderId) + { + Count = count; + ProductFee = productFee; + ProductCost = productCost; + OrderProductStatus = orderProductStatus; + ProductId = productId; + OrderId = orderId; + ProductCategoryId = productCategoryId; + PackingFee = packingFee; + PackingCost = packingCost; + } public int Count { get; internal set; } - public float ProductFee { get; internal set; } - public float ProductCost { get; internal set; } + public double ProductFee { get; internal set; } + public double ProductCost { get; internal set; } + public double PackingFee { get; internal set; } + public double PackingCost { get; internal set; } public OrderStatus OrderProductStatus { get; internal set; } public Guid ProductId { get; internal set; } + public Guid ProductCategoryId { get; internal set; } public Product? Product { get; internal set; } public Guid OrderId { get; internal set; } diff --git a/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs index da8730a..a2fbede 100644 --- a/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Products/Product.Aggregate.cs @@ -2,18 +2,10 @@ public partial class Product { - public static Product Create(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId) + public static Product Create(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, bool beDisplayed, double cost, double packingCost, Guid brandId,Guid categoryId) { - return new Product(persianName, englishName, summery, expertCheck, tags, warranty, brandId); + return new Product(persianName, englishName, summery, expertCheck, tags, warranty, beDisplayed,cost,packingCost, brandId,categoryId); } - - public ProductCategory AddCategory(Guid categoryId) - { - var ent = ProductCategory.Create(categoryId, Id); - Categories.Add(ent); - return ent; - } - public ProductStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType) { var ent = ProductStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, Id); @@ -29,14 +21,6 @@ public partial class Product } } -public partial class ProductCategory -{ - public static ProductCategory Create(Guid categoryId, Guid productId) - { - return new ProductCategory(categoryId, productId); - } -} - public partial class ProductStorageFile { public static ProductStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, diff --git a/NetinaShop.Domain/Entities/Products/Product.cs b/NetinaShop.Domain/Entities/Products/Product.cs index feb966d..b2223c8 100644 --- a/NetinaShop.Domain/Entities/Products/Product.cs +++ b/NetinaShop.Domain/Entities/Products/Product.cs @@ -7,10 +7,10 @@ public partial class Product : ApiEntity { public Product() { - + } - public Product(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, Guid brandId) + public Product(string persianName, string englishName, string summery, string expertCheck, string tags, string warranty, bool beDisplayed, double cost, double packingCost, Guid brandId, Guid categoryId) { PersianName = persianName; EnglishName = englishName; @@ -18,7 +18,11 @@ public partial class Product : ApiEntity ExpertCheck = expertCheck; Tags = tags; Warranty = warranty; + BeDisplayed = beDisplayed; + Cost = cost; + PackingCost = packingCost; BrandId = brandId; + CategoryId = categoryId; } public string PersianName { get; internal set; } = string.Empty; public string EnglishName { get; internal set; } = string.Empty; @@ -26,13 +30,20 @@ public partial class Product : ApiEntity public string ExpertCheck { get; internal set; } = string.Empty; public string Tags { get; internal set; } = string.Empty; public string Warranty { get; set; } = string.Empty; + public double Cost { get; set; } + public bool IsEnable { get; set; } + public bool BeDisplayed { get; set; } + public double PackingCost { get; set; } + public Guid BrandId { get; internal set; } public Brand? Brand { get; set; } + public Guid CategoryId { get; internal set; } + public Category? Category { get; internal set; } + public List Specifications { get; internal set; } = new(); public List Reviews { get; internal set; } = new(); - public List Categories { get; internal set; } = new(); public List Files { get; internal set; } = new(); public List OrderProducts { get; internal set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Products/ProductCategory.cs b/NetinaShop.Domain/Entities/Products/ProductCategory.cs deleted file mode 100644 index de7fced..0000000 --- a/NetinaShop.Domain/Entities/Products/ProductCategory.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace NetinaShop.Domain.Entities.Products; -[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] -[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] -[GenerateMapper] -public partial class ProductCategory : ApiEntity -{ - public ProductCategory(Guid categoryId, Guid productId) - { - CategoryId = categoryId; - ProductId = productId; - } - - public ProductCategory() - { - - } - public Guid CategoryId { get; internal set; } - public Category? Category { get; internal set; } - public Guid ProductId { get; internal set; } - public Product? Product { get; internal set; } -} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs index 84036ef..d83a339 100644 --- a/NetinaShop.Domain/Entities/Warehouses/Shipping.cs +++ b/NetinaShop.Domain/Entities/Warehouses/Shipping.cs @@ -7,16 +7,16 @@ public partial class Shipping : ApiEntity { public Shipping() { - } - public Shipping(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse) + public Shipping(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost) { Title = title; WarehouseName = warehouseName; IsFastShipping = isFastShipping; IsShipBySeller = isShipBySeller; IsOriginalWarehouse = isOriginalWarehouse; + DeliveryCost = deliveryCost; } public string Title { get; internal set; } = string.Empty; @@ -24,4 +24,5 @@ public partial class Shipping : ApiEntity public bool IsFastShipping { get; internal set; } public bool IsShipBySeller { get; internal set; } public bool IsOriginalWarehouse { get; internal set; } + public double DeliveryCost { get; internal set; } } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs index ca20152..eec54dc 100644 --- a/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Warehouses/Warehouses.Aggregate.cs @@ -7,8 +7,8 @@ public partial class Warehouses public partial class Shipping { - public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse) + public static Shipping Create(string title, string warehouseName, bool isFastShipping, bool isShipBySeller, bool isOriginalWarehouse, double deliveryCost) { - return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse); + return new Shipping(title, warehouseName, isFastShipping, isShipBySeller, isOriginalWarehouse,deliveryCost); } } \ No newline at end of file diff --git a/NetinaShop.Domain/Enums/OrderPaymentMethod.cs b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs new file mode 100644 index 0000000..462ea8e --- /dev/null +++ b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs @@ -0,0 +1,11 @@ +namespace NetinaShop.Domain.Enums; + +public enum OrderPaymentMethod +{ + [Display(Name = "پرداخت درب محل")] + Cash, + [Display(Name = "پرداخت انلاین")] + OnlinePayment, + [Display(Name = "پرداخت کارت به کارت")] + CardTransfer +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/OrderMapper.g.cs b/NetinaShop.Domain/Mappers/OrderMapper.g.cs new file mode 100644 index 0000000..4d5d2fd --- /dev/null +++ b/NetinaShop.Domain/Mappers/OrderMapper.g.cs @@ -0,0 +1,533 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using NetinaShop.Domain.Dtos.LargDtos; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class OrderMapper + { + public static Order AdaptToOrder(this OrderLDto p1) + { + return p1 == null ? null : new Order() + { + TotalProductsPrice = (double)p1.TotalProductsPrice, + PackingPrice = (double)p1.PackingPrice, + ServicePrice = (double)p1.ServicePrice, + DeliveryPrice = (double)p1.DeliveryPrice, + DiscountPrice = (double)p1.DiscountPrice, + TaxesPrice = (double)p1.TaxesPrice, + TotalPrice = (double)p1.TotalPrice, + IsPayed = p1.IsPayed, + OrderStatus = p1.OrderStatus, + DoneAt = p1.DoneAt, + OrderAt = p1.OrderAt, + PreparingMinute = p1.PreparingMinute, + DiscountCode = p1.DiscountCode, + OrderProducts = funcMain1(p1.OrderProducts), + OrderDeliveries = funcMain2(p1.OrderDeliveries), + Id = p1.Id + }; + } + public static Order AdaptTo(this OrderLDto p4, Order p5) + { + if (p4 == null) + { + return null; + } + Order result = p5 ?? new Order(); + + result.TotalProductsPrice = (double)p4.TotalProductsPrice; + result.PackingPrice = (double)p4.PackingPrice; + result.ServicePrice = (double)p4.ServicePrice; + result.DeliveryPrice = (double)p4.DeliveryPrice; + result.DiscountPrice = (double)p4.DiscountPrice; + result.TaxesPrice = (double)p4.TaxesPrice; + result.TotalPrice = (double)p4.TotalPrice; + result.IsPayed = p4.IsPayed; + result.OrderStatus = p4.OrderStatus; + result.DoneAt = p4.DoneAt; + result.OrderAt = p4.OrderAt; + result.PreparingMinute = p4.PreparingMinute; + result.DiscountCode = p4.DiscountCode; + result.OrderProducts = funcMain3(p4.OrderProducts, result.OrderProducts); + result.OrderDeliveries = funcMain4(p4.OrderDeliveries, result.OrderDeliveries); + result.Id = p4.Id; + return result; + + } + public static Expression> ProjectToOrder => p10 => new Order() + { + TotalProductsPrice = (double)p10.TotalProductsPrice, + PackingPrice = (double)p10.PackingPrice, + ServicePrice = (double)p10.ServicePrice, + DeliveryPrice = (double)p10.DeliveryPrice, + DiscountPrice = (double)p10.DiscountPrice, + TaxesPrice = (double)p10.TaxesPrice, + TotalPrice = (double)p10.TotalPrice, + IsPayed = p10.IsPayed, + OrderStatus = p10.OrderStatus, + DoneAt = p10.DoneAt, + OrderAt = p10.OrderAt, + PreparingMinute = p10.PreparingMinute, + DiscountCode = p10.DiscountCode, + OrderProducts = p10.OrderProducts.Select(p11 => new OrderProduct() + { + Count = p11.Count, + ProductFee = (double)p11.ProductFee, + ProductCost = (double)p11.ProductCost, + OrderProductStatus = p11.OrderProductStatus, + ProductId = p11.ProductId, + OrderId = p11.OrderId, + Id = p11.Id + }).ToList(), + OrderDeliveries = p10.OrderDeliveries.Select(p12 => new OrderDelivery() + { + Address = p12.Address, + PostalCode = p12.PostalCode, + ReceiverPhoneNumber = p12.ReceiverPhoneNumber, + ReceiverFullName = p12.ReceiverFullName, + ShippingId = p12.ShippingId, + OrderId = p12.OrderId, + Id = p12.Id + }).ToList(), + Id = p10.Id + }; + public static OrderLDto AdaptToLDto(this Order p13) + { + return p13 == null ? null : new OrderLDto() + { + TotalPrice = (long)p13.TotalPrice, + DeliveryPrice = (long)p13.DeliveryPrice, + TaxesPrice = (long)p13.TaxesPrice, + ServicePrice = (long)p13.ServicePrice, + PackingPrice = (long)p13.PackingPrice, + TotalProductsPrice = (long)p13.TotalProductsPrice, + DiscountPrice = (long)p13.DiscountPrice, + IsPayed = p13.IsPayed, + OrderStatus = p13.OrderStatus, + DoneAt = p13.DoneAt, + OrderAt = p13.OrderAt, + PreparingMinute = p13.PreparingMinute, + DiscountCode = p13.DiscountCode, + OrderProducts = funcMain5(p13.OrderProducts), + OrderDeliveries = funcMain6(p13.OrderDeliveries), + Id = p13.Id + }; + } + public static OrderLDto AdaptTo(this Order p16, OrderLDto p17) + { + if (p16 == null) + { + return null; + } + OrderLDto result = p17 ?? new OrderLDto(); + + result.TotalPrice = (long)p16.TotalPrice; + result.DeliveryPrice = (long)p16.DeliveryPrice; + result.TaxesPrice = (long)p16.TaxesPrice; + result.ServicePrice = (long)p16.ServicePrice; + result.PackingPrice = (long)p16.PackingPrice; + result.TotalProductsPrice = (long)p16.TotalProductsPrice; + result.DiscountPrice = (long)p16.DiscountPrice; + result.IsPayed = p16.IsPayed; + result.OrderStatus = p16.OrderStatus; + result.DoneAt = p16.DoneAt; + result.OrderAt = p16.OrderAt; + result.PreparingMinute = p16.PreparingMinute; + result.DiscountCode = p16.DiscountCode; + result.OrderProducts = funcMain7(p16.OrderProducts, result.OrderProducts); + result.OrderDeliveries = funcMain8(p16.OrderDeliveries, result.OrderDeliveries); + result.Id = p16.Id; + return result; + + } + public static Expression> ProjectToLDto => p22 => new OrderLDto() + { + TotalPrice = (long)p22.TotalPrice, + DeliveryPrice = (long)p22.DeliveryPrice, + TaxesPrice = (long)p22.TaxesPrice, + ServicePrice = (long)p22.ServicePrice, + PackingPrice = (long)p22.PackingPrice, + TotalProductsPrice = (long)p22.TotalProductsPrice, + DiscountPrice = (long)p22.DiscountPrice, + IsPayed = p22.IsPayed, + OrderStatus = p22.OrderStatus, + DoneAt = p22.DoneAt, + OrderAt = p22.OrderAt, + PreparingMinute = p22.PreparingMinute, + DiscountCode = p22.DiscountCode, + OrderProducts = p22.OrderProducts.Select(p23 => new OrderProductSDto() + { + Count = p23.Count, + ProductFee = (float)p23.ProductFee, + ProductCost = (float)p23.ProductCost, + OrderProductStatus = p23.OrderProductStatus, + ProductId = p23.ProductId, + OrderId = p23.OrderId, + Id = p23.Id + }).ToList(), + OrderDeliveries = p22.OrderDeliveries.Select(p24 => new OrderDeliverySDto() + { + Address = p24.Address, + PostalCode = p24.PostalCode, + ReceiverPhoneNumber = p24.ReceiverPhoneNumber, + ReceiverFullName = p24.ReceiverFullName, + OrderId = p24.OrderId, + ShippingId = p24.ShippingId, + Id = p24.Id + }).ToList(), + Id = p22.Id + }; + public static Order AdaptToOrder(this OrderSDto p25) + { + return p25 == null ? null : new Order() + { + TotalProductsPrice = (double)p25.TotalProductsPrice, + PackingPrice = (double)p25.PackingPrice, + ServicePrice = (double)p25.ServicePrice, + DeliveryPrice = (double)p25.DeliveryPrice, + DiscountPrice = (double)p25.DiscountPrice, + TaxesPrice = (double)p25.TaxesPrice, + TotalPrice = (double)p25.TotalPrice, + IsPayed = p25.IsPayed, + OrderStatus = p25.OrderStatus, + DoneAt = p25.DoneAt, + OrderAt = p25.OrderAt, + PreparingMinute = p25.PreparingMinute, + DiscountCode = p25.DiscountCode, + Id = p25.Id + }; + } + public static Order AdaptTo(this OrderSDto p26, Order p27) + { + if (p26 == null) + { + return null; + } + Order result = p27 ?? new Order(); + + result.TotalProductsPrice = (double)p26.TotalProductsPrice; + result.PackingPrice = (double)p26.PackingPrice; + result.ServicePrice = (double)p26.ServicePrice; + result.DeliveryPrice = (double)p26.DeliveryPrice; + result.DiscountPrice = (double)p26.DiscountPrice; + result.TaxesPrice = (double)p26.TaxesPrice; + result.TotalPrice = (double)p26.TotalPrice; + result.IsPayed = p26.IsPayed; + result.OrderStatus = p26.OrderStatus; + result.DoneAt = p26.DoneAt; + result.OrderAt = p26.OrderAt; + result.PreparingMinute = p26.PreparingMinute; + result.DiscountCode = p26.DiscountCode; + result.Id = p26.Id; + return result; + + } + public static OrderSDto AdaptToSDto(this Order p28) + { + return p28 == null ? null : new OrderSDto() + { + TotalPrice = (long)p28.TotalPrice, + DeliveryPrice = (long)p28.DeliveryPrice, + TaxesPrice = (long)p28.TaxesPrice, + ServicePrice = (long)p28.ServicePrice, + PackingPrice = (long)p28.PackingPrice, + TotalProductsPrice = (long)p28.TotalProductsPrice, + DiscountPrice = (long)p28.DiscountPrice, + IsPayed = p28.IsPayed, + OrderStatus = p28.OrderStatus, + DoneAt = p28.DoneAt, + OrderAt = p28.OrderAt, + PreparingMinute = p28.PreparingMinute, + DiscountCode = p28.DiscountCode, + Id = p28.Id + }; + } + public static OrderSDto AdaptTo(this Order p29, OrderSDto p30) + { + if (p29 == null) + { + return null; + } + OrderSDto result = p30 ?? new OrderSDto(); + + result.TotalPrice = (long)p29.TotalPrice; + result.DeliveryPrice = (long)p29.DeliveryPrice; + result.TaxesPrice = (long)p29.TaxesPrice; + result.ServicePrice = (long)p29.ServicePrice; + result.PackingPrice = (long)p29.PackingPrice; + result.TotalProductsPrice = (long)p29.TotalProductsPrice; + result.DiscountPrice = (long)p29.DiscountPrice; + result.IsPayed = p29.IsPayed; + result.OrderStatus = p29.OrderStatus; + result.DoneAt = p29.DoneAt; + result.OrderAt = p29.OrderAt; + result.PreparingMinute = p29.PreparingMinute; + result.DiscountCode = p29.DiscountCode; + result.Id = p29.Id; + return result; + + } + public static Expression> ProjectToSDto => p31 => new OrderSDto() + { + TotalPrice = (long)p31.TotalPrice, + DeliveryPrice = (long)p31.DeliveryPrice, + TaxesPrice = (long)p31.TaxesPrice, + ServicePrice = (long)p31.ServicePrice, + PackingPrice = (long)p31.PackingPrice, + TotalProductsPrice = (long)p31.TotalProductsPrice, + DiscountPrice = (long)p31.DiscountPrice, + IsPayed = p31.IsPayed, + OrderStatus = p31.OrderStatus, + DoneAt = p31.DoneAt, + OrderAt = p31.OrderAt, + PreparingMinute = p31.PreparingMinute, + DiscountCode = p31.DiscountCode, + Id = p31.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + OrderProductSDto item = p2[i]; + result.Add(item == null ? null : new OrderProduct() + { + Count = item.Count, + ProductFee = (double)item.ProductFee, + ProductCost = (double)item.ProductCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p3) + { + if (p3 == null) + { + return null; + } + List result = new List(p3.Count); + + int i = 0; + int len = p3.Count; + + while (i < len) + { + OrderDeliverySDto item = p3[i]; + result.Add(item == null ? null : new OrderDelivery() + { + Address = item.Address, + PostalCode = item.PostalCode, + ReceiverPhoneNumber = item.ReceiverPhoneNumber, + ReceiverFullName = item.ReceiverFullName, + ShippingId = item.ShippingId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p6, List p7) + { + if (p6 == null) + { + return null; + } + List result = new List(p6.Count); + + int i = 0; + int len = p6.Count; + + while (i < len) + { + OrderProductSDto item = p6[i]; + result.Add(item == null ? null : new OrderProduct() + { + Count = item.Count, + ProductFee = (double)item.ProductFee, + ProductCost = (double)item.ProductCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p8, List p9) + { + if (p8 == null) + { + return null; + } + List result = new List(p8.Count); + + int i = 0; + int len = p8.Count; + + while (i < len) + { + OrderDeliverySDto item = p8[i]; + result.Add(item == null ? null : new OrderDelivery() + { + Address = item.Address, + PostalCode = item.PostalCode, + ReceiverPhoneNumber = item.ReceiverPhoneNumber, + ReceiverFullName = item.ReceiverFullName, + ShippingId = item.ShippingId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain5(List p14) + { + if (p14 == null) + { + return null; + } + List result = new List(p14.Count); + + int i = 0; + int len = p14.Count; + + while (i < len) + { + OrderProduct item = p14[i]; + result.Add(item == null ? null : new OrderProductSDto() + { + Count = item.Count, + ProductFee = (float)item.ProductFee, + ProductCost = (float)item.ProductCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain6(List p15) + { + if (p15 == null) + { + return null; + } + List result = new List(p15.Count); + + int i = 0; + int len = p15.Count; + + while (i < len) + { + OrderDelivery item = p15[i]; + result.Add(item == null ? null : new OrderDeliverySDto() + { + Address = item.Address, + PostalCode = item.PostalCode, + ReceiverPhoneNumber = item.ReceiverPhoneNumber, + ReceiverFullName = item.ReceiverFullName, + OrderId = item.OrderId, + ShippingId = item.ShippingId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain7(List p18, List p19) + { + if (p18 == null) + { + return null; + } + List result = new List(p18.Count); + + int i = 0; + int len = p18.Count; + + while (i < len) + { + OrderProduct item = p18[i]; + result.Add(item == null ? null : new OrderProductSDto() + { + Count = item.Count, + ProductFee = (float)item.ProductFee, + ProductCost = (float)item.ProductCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + OrderId = item.OrderId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain8(List p20, List p21) + { + if (p20 == null) + { + return null; + } + List result = new List(p20.Count); + + int i = 0; + int len = p20.Count; + + while (i < len) + { + OrderDelivery item = p20[i]; + result.Add(item == null ? null : new OrderDeliverySDto() + { + Address = item.Address, + PostalCode = item.PostalCode, + ReceiverPhoneNumber = item.ReceiverPhoneNumber, + ReceiverFullName = item.ReceiverFullName, + OrderId = item.OrderId, + ShippingId = item.ShippingId, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs b/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs deleted file mode 100644 index 01bd238..0000000 --- a/NetinaShop.Domain/Mappers/ProductCategoryMapper.g.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Linq.Expressions; -using NetinaShop.Domain.Dtos.SmallDtos; -using NetinaShop.Domain.Entities.Products; - -namespace NetinaShop.Domain.Mappers -{ - public static partial class ProductCategoryMapper - { - public static ProductCategory AdaptToProductCategory(this ProductCategorySDto p1) - { - return p1 == null ? null : new ProductCategory() - { - CategoryId = p1.CategoryId, - ProductId = p1.ProductId, - Id = p1.Id - }; - } - public static ProductCategory AdaptTo(this ProductCategorySDto p2, ProductCategory p3) - { - if (p2 == null) - { - return null; - } - ProductCategory result = p3 ?? new ProductCategory(); - - result.CategoryId = p2.CategoryId; - result.ProductId = p2.ProductId; - result.Id = p2.Id; - return result; - - } - public static ProductCategorySDto AdaptToSDto(this ProductCategory p4) - { - return p4 == null ? null : new ProductCategorySDto() - { - CategoryId = p4.CategoryId, - CategoryName = p4.Category == null ? null : p4.Category.Name, - ProductId = p4.ProductId, - Id = p4.Id - }; - } - public static ProductCategorySDto AdaptTo(this ProductCategory p5, ProductCategorySDto p6) - { - if (p5 == null) - { - return null; - } - ProductCategorySDto result = p6 ?? new ProductCategorySDto(); - - result.CategoryId = p5.CategoryId; - result.CategoryName = p5.Category == null ? null : p5.Category.Name; - result.ProductId = p5.ProductId; - result.Id = p5.Id; - return result; - - } - public static Expression> ProjectToSDto => p7 => new ProductCategorySDto() - { - CategoryId = p7.CategoryId, - CategoryName = p7.Category.Name, - ProductId = p7.ProductId, - Id = p7.Id - }; - } -} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/ProductMapper.g.cs b/NetinaShop.Domain/Mappers/ProductMapper.g.cs index 3dfab34..6aaf8e5 100644 --- a/NetinaShop.Domain/Mappers/ProductMapper.g.cs +++ b/NetinaShop.Domain/Mappers/ProductMapper.g.cs @@ -23,246 +23,229 @@ namespace NetinaShop.Domain.Mappers BrandId = p1.BrandId, Specifications = funcMain1(p1.Specifications), Reviews = funcMain2(p1.Reviews), - Categories = funcMain3(p1.Categories), - Files = funcMain4(p1.Files), + Files = funcMain3(p1.Files), Id = p1.Id }; } - public static Product AdaptTo(this ProductLDto p6, Product p7) + public static Product AdaptTo(this ProductLDto p5, Product p6) { - if (p6 == null) + if (p5 == null) { return null; } - Product result = p7 ?? new Product(); + Product result = p6 ?? new Product(); - result.PersianName = p6.PersianName; - result.EnglishName = p6.EnglishName; - result.Summery = p6.Summery; - result.ExpertCheck = p6.ExpertCheck; - result.Tags = p6.Tags; - result.Warranty = p6.Warranty; - result.BrandId = p6.BrandId; - result.Specifications = funcMain5(p6.Specifications, result.Specifications); - result.Reviews = funcMain6(p6.Reviews, result.Reviews); - result.Categories = funcMain7(p6.Categories, result.Categories); - result.Files = funcMain8(p6.Files, result.Files); - result.Id = p6.Id; + result.PersianName = p5.PersianName; + result.EnglishName = p5.EnglishName; + result.Summery = p5.Summery; + result.ExpertCheck = p5.ExpertCheck; + result.Tags = p5.Tags; + result.Warranty = p5.Warranty; + result.BrandId = p5.BrandId; + result.Specifications = funcMain4(p5.Specifications, result.Specifications); + result.Reviews = funcMain5(p5.Reviews, result.Reviews); + result.Files = funcMain6(p5.Files, result.Files); + result.Id = p5.Id; return result; } - public static Expression> ProjectToProduct => p16 => new Product() + public static Expression> ProjectToProduct => p13 => new Product() { - PersianName = p16.PersianName, - EnglishName = p16.EnglishName, - Summery = p16.Summery, - ExpertCheck = p16.ExpertCheck, - Tags = p16.Tags, - Warranty = p16.Warranty, - BrandId = p16.BrandId, - Specifications = p16.Specifications.Select(p17 => new Specification() + PersianName = p13.PersianName, + EnglishName = p13.EnglishName, + Summery = p13.Summery, + ExpertCheck = p13.ExpertCheck, + Tags = p13.Tags, + Warranty = p13.Warranty, + BrandId = p13.BrandId, + Specifications = p13.Specifications.Select(p14 => new Specification() { - Title = p17.Title, - Detail = p17.Detail, - Value = p17.Value, - IsFeature = p17.IsFeature, - ProductId = p17.ProductId, - ParentId = p17.ParentId, - Id = p17.Id + Title = p14.Title, + Detail = p14.Detail, + Value = p14.Value, + IsFeature = p14.IsFeature, + ProductId = p14.ProductId, + ParentId = p14.ParentId, + Id = p14.Id }).ToList(), - Reviews = p16.Reviews.Select(p18 => new Review() + Reviews = p13.Reviews.Select(p15 => new Review() { - Title = p18.Title, - Comment = p18.Comment, - Rate = p18.Rate, - IsBuyer = p18.IsBuyer, - ProductId = p18.ProductId, - UserId = p18.UserId, - Id = p18.Id + Title = p15.Title, + Comment = p15.Comment, + Rate = p15.Rate, + IsBuyer = p15.IsBuyer, + ProductId = p15.ProductId, + UserId = p15.UserId, + Id = p15.Id }).ToList(), - Categories = p16.Categories.Select(p19 => new ProductCategory() + Files = p13.Files.Select(p16 => new ProductStorageFile() { - CategoryId = p19.CategoryId, - ProductId = p19.ProductId, - Id = p19.Id - }).ToList(), - Files = p16.Files.Select(p20 => new ProductStorageFile() - { - Name = p20.Name, - FileLocation = p20.FileLocation, - FileName = p20.FileName, - IsHeader = p20.IsHeader, - IsPrimary = p20.IsPrimary, - FileType = p20.FileType, - Id = p20.Id + Name = p16.Name, + FileLocation = p16.FileLocation, + FileName = p16.FileName, + IsHeader = p16.IsHeader, + IsPrimary = p16.IsPrimary, + FileType = p16.FileType, + Id = p16.Id }).ToList(), - Id = p16.Id + Id = p13.Id }; - public static ProductLDto AdaptToLDto(this Product p21) + public static ProductLDto AdaptToLDto(this Product p17) { - return p21 == null ? null : new ProductLDto() + return p17 == null ? null : new ProductLDto() { - PersianName = p21.PersianName, - EnglishName = p21.EnglishName, - Summery = p21.Summery, - ExpertCheck = p21.ExpertCheck, - Tags = p21.Tags, - Warranty = p21.Warranty, - BrandId = p21.BrandId, - Specifications = funcMain9(p21.Specifications), - Reviews = funcMain10(p21.Reviews), - Categories = funcMain11(p21.Categories), - Files = funcMain12(p21.Files), - Id = p21.Id + PersianName = p17.PersianName, + EnglishName = p17.EnglishName, + Summery = p17.Summery, + ExpertCheck = p17.ExpertCheck, + Tags = p17.Tags, + Warranty = p17.Warranty, + BrandId = p17.BrandId, + Specifications = funcMain7(p17.Specifications), + Reviews = funcMain8(p17.Reviews), + Files = funcMain9(p17.Files), + Id = p17.Id }; } - public static ProductLDto AdaptTo(this Product p26, ProductLDto p27) + public static ProductLDto AdaptTo(this Product p21, ProductLDto p22) { - if (p26 == null) + if (p21 == null) { return null; } - ProductLDto result = p27 ?? new ProductLDto(); + ProductLDto result = p22 ?? new ProductLDto(); - result.PersianName = p26.PersianName; - result.EnglishName = p26.EnglishName; - result.Summery = p26.Summery; - result.ExpertCheck = p26.ExpertCheck; - result.Tags = p26.Tags; - result.Warranty = p26.Warranty; - result.BrandId = p26.BrandId; - result.Specifications = funcMain13(p26.Specifications, result.Specifications); - result.Reviews = funcMain14(p26.Reviews, result.Reviews); - result.Categories = funcMain15(p26.Categories, result.Categories); - result.Files = funcMain16(p26.Files, result.Files); - result.Id = p26.Id; + result.PersianName = p21.PersianName; + result.EnglishName = p21.EnglishName; + result.Summery = p21.Summery; + result.ExpertCheck = p21.ExpertCheck; + result.Tags = p21.Tags; + result.Warranty = p21.Warranty; + result.BrandId = p21.BrandId; + result.Specifications = funcMain10(p21.Specifications, result.Specifications); + result.Reviews = funcMain11(p21.Reviews, result.Reviews); + result.Files = funcMain12(p21.Files, result.Files); + result.Id = p21.Id; return result; } - public static Expression> ProjectToLDto => p36 => new ProductLDto() + public static Expression> ProjectToLDto => p29 => new ProductLDto() { - PersianName = p36.PersianName, - EnglishName = p36.EnglishName, - Summery = p36.Summery, - ExpertCheck = p36.ExpertCheck, - Tags = p36.Tags, - Warranty = p36.Warranty, - BrandId = p36.BrandId, - Specifications = p36.Specifications.Select(p37 => new SpecificationSDto() + PersianName = p29.PersianName, + EnglishName = p29.EnglishName, + Summery = p29.Summery, + ExpertCheck = p29.ExpertCheck, + Tags = p29.Tags, + Warranty = p29.Warranty, + BrandId = p29.BrandId, + Specifications = p29.Specifications.Select(p30 => new SpecificationSDto() { - Title = p37.Title, - Detail = p37.Detail, - Value = p37.Value, - IsFeature = p37.IsFeature, - ProductId = p37.ProductId, - ParentId = p37.ParentId, - Id = p37.Id + Title = p30.Title, + Detail = p30.Detail, + Value = p30.Value, + IsFeature = p30.IsFeature, + ProductId = p30.ProductId, + ParentId = p30.ParentId, + Id = p30.Id }).ToList(), - Reviews = p36.Reviews.Select(p38 => new ReviewSDto() + Reviews = p29.Reviews.Select(p31 => new ReviewSDto() { - Title = p38.Title, - Comment = p38.Comment, - Rate = p38.Rate, - IsBuyer = p38.IsBuyer, - ProductId = p38.ProductId, - UserId = p38.UserId, - Id = p38.Id + Title = p31.Title, + Comment = p31.Comment, + Rate = p31.Rate, + IsBuyer = p31.IsBuyer, + ProductId = p31.ProductId, + UserId = p31.UserId, + Id = p31.Id }).ToList(), - Categories = p36.Categories.Select(p39 => new ProductCategorySDto() + Files = p29.Files.Select(p32 => new StorageFileSDto() { - CategoryId = p39.CategoryId, - CategoryName = p39.Category.Name, - ProductId = p39.ProductId, - Id = p39.Id - }).ToList(), - Files = p36.Files.Select(p40 => new StorageFileSDto() - { - Name = p40.Name, - FileLocation = p40.FileLocation, - FileName = p40.FileName, - IsHeader = p40.IsHeader, - IsPrimary = p40.IsPrimary, - FileType = p40.FileType, - Id = p40.Id + Name = p32.Name, + FileLocation = p32.FileLocation, + FileName = p32.FileName, + IsHeader = p32.IsHeader, + IsPrimary = p32.IsPrimary, + FileType = p32.FileType, + Id = p32.Id }).ToList(), - Id = p36.Id + Id = p29.Id }; - public static Product AdaptToProduct(this ProductSDto p41) + public static Product AdaptToProduct(this ProductSDto p33) { - return p41 == null ? null : new Product() + return p33 == null ? null : new Product() { - PersianName = p41.PersianName, - EnglishName = p41.EnglishName, - Summery = p41.Summery, - ExpertCheck = p41.ExpertCheck, - Tags = p41.Tags, - Warranty = p41.Warranty, - BrandId = p41.BrandId, - Id = p41.Id + PersianName = p33.PersianName, + EnglishName = p33.EnglishName, + Summery = p33.Summery, + ExpertCheck = p33.ExpertCheck, + Tags = p33.Tags, + Warranty = p33.Warranty, + BrandId = p33.BrandId, + Id = p33.Id }; } - public static Product AdaptTo(this ProductSDto p42, Product p43) + public static Product AdaptTo(this ProductSDto p34, Product p35) { - if (p42 == null) + if (p34 == null) { return null; } - Product result = p43 ?? new Product(); + Product result = p35 ?? new Product(); - result.PersianName = p42.PersianName; - result.EnglishName = p42.EnglishName; - result.Summery = p42.Summery; - result.ExpertCheck = p42.ExpertCheck; - result.Tags = p42.Tags; - result.Warranty = p42.Warranty; - result.BrandId = p42.BrandId; - result.Id = p42.Id; + result.PersianName = p34.PersianName; + result.EnglishName = p34.EnglishName; + result.Summery = p34.Summery; + result.ExpertCheck = p34.ExpertCheck; + result.Tags = p34.Tags; + result.Warranty = p34.Warranty; + result.BrandId = p34.BrandId; + result.Id = p34.Id; return result; } - public static ProductSDto AdaptToSDto(this Product p44) + public static ProductSDto AdaptToSDto(this Product p36) { - return p44 == null ? null : new ProductSDto() + return p36 == null ? null : new ProductSDto() { - PersianName = p44.PersianName, - EnglishName = p44.EnglishName, - Summery = p44.Summery, - ExpertCheck = p44.ExpertCheck, - Tags = p44.Tags, - Warranty = p44.Warranty, - BrandId = p44.BrandId, - Id = p44.Id + PersianName = p36.PersianName, + EnglishName = p36.EnglishName, + Summery = p36.Summery, + ExpertCheck = p36.ExpertCheck, + Tags = p36.Tags, + Warranty = p36.Warranty, + BrandId = p36.BrandId, + Id = p36.Id }; } - public static ProductSDto AdaptTo(this Product p45, ProductSDto p46) + public static ProductSDto AdaptTo(this Product p37, ProductSDto p38) { - if (p45 == null) + if (p37 == null) { return null; } - ProductSDto result = p46 ?? new ProductSDto(); + ProductSDto result = p38 ?? new ProductSDto(); - result.PersianName = p45.PersianName; - result.EnglishName = p45.EnglishName; - result.Summery = p45.Summery; - result.ExpertCheck = p45.ExpertCheck; - result.Tags = p45.Tags; - result.Warranty = p45.Warranty; - result.BrandId = p45.BrandId; - result.Id = p45.Id; + result.PersianName = p37.PersianName; + result.EnglishName = p37.EnglishName; + result.Summery = p37.Summery; + result.ExpertCheck = p37.ExpertCheck; + result.Tags = p37.Tags; + result.Warranty = p37.Warranty; + result.BrandId = p37.BrandId; + result.Id = p37.Id; return result; } - public static Expression> ProjectToSDto => p47 => new ProductSDto() + public static Expression> ProjectToSDto => p39 => new ProductSDto() { - PersianName = p47.PersianName, - EnglishName = p47.EnglishName, - Summery = p47.Summery, - ExpertCheck = p47.ExpertCheck, - Tags = p47.Tags, - Warranty = p47.Warranty, - BrandId = p47.BrandId, - Id = p47.Id + PersianName = p39.PersianName, + EnglishName = p39.EnglishName, + Summery = p39.Summery, + ExpertCheck = p39.ExpertCheck, + Tags = p39.Tags, + Warranty = p39.Warranty, + BrandId = p39.BrandId, + Id = p39.Id }; private static List funcMain1(List p2) @@ -325,46 +308,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain3(List p4) + private static List funcMain3(List p4) { if (p4 == null) { return null; } - List result = new List(p4.Count); + List result = new List(p4.Count); int i = 0; int len = p4.Count; while (i < len) { - ProductCategorySDto item = p4[i]; - result.Add(item == null ? null : new ProductCategory() - { - CategoryId = item.CategoryId, - ProductId = item.ProductId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain4(List p5) - { - if (p5 == null) - { - return null; - } - List result = new List(p5.Count); - - int i = 0; - int len = p5.Count; - - while (i < len) - { - StorageFileSDto item = p5[i]; + StorageFileSDto item = p4[i]; result.Add(item == null ? null : new ProductStorageFile() { Name = item.Name, @@ -381,20 +338,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain5(List p8, List p9) + private static List funcMain4(List p7, List p8) { - if (p8 == null) + if (p7 == null) { return null; } - List result = new List(p8.Count); + List result = new List(p7.Count); int i = 0; - int len = p8.Count; + int len = p7.Count; while (i < len) { - SpecificationSDto item = p8[i]; + SpecificationSDto item = p7[i]; result.Add(item == null ? null : new Specification() { Title = item.Title, @@ -411,20 +368,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain6(List p10, List p11) + private static List funcMain5(List p9, List p10) { - if (p10 == null) + if (p9 == null) { return null; } - List result = new List(p10.Count); + List result = new List(p9.Count); int i = 0; - int len = p10.Count; + int len = p9.Count; while (i < len) { - ReviewSDto item = p10[i]; + ReviewSDto item = p9[i]; result.Add(item == null ? null : new Review() { Title = item.Title, @@ -441,46 +398,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain7(List p12, List p13) + private static List funcMain6(List p11, List p12) { - if (p12 == null) + if (p11 == null) { return null; } - List result = new List(p12.Count); + List result = new List(p11.Count); int i = 0; - int len = p12.Count; + int len = p11.Count; while (i < len) { - ProductCategorySDto item = p12[i]; - result.Add(item == null ? null : new ProductCategory() - { - CategoryId = item.CategoryId, - ProductId = item.ProductId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain8(List p14, List p15) - { - if (p14 == null) - { - return null; - } - List result = new List(p14.Count); - - int i = 0; - int len = p14.Count; - - while (i < len) - { - StorageFileSDto item = p14[i]; + StorageFileSDto item = p11[i]; result.Add(item == null ? null : new ProductStorageFile() { Name = item.Name, @@ -497,20 +428,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain9(List p22) + private static List funcMain7(List p18) { - if (p22 == null) + if (p18 == null) { return null; } - List result = new List(p22.Count); + List result = new List(p18.Count); int i = 0; - int len = p22.Count; + int len = p18.Count; while (i < len) { - Specification item = p22[i]; + Specification item = p18[i]; result.Add(item == null ? null : new SpecificationSDto() { Title = item.Title, @@ -527,20 +458,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain10(List p23) + private static List funcMain8(List p19) { - if (p23 == null) + if (p19 == null) { return null; } - List result = new List(p23.Count); + List result = new List(p19.Count); int i = 0; - int len = p23.Count; + int len = p19.Count; while (i < len) { - Review item = p23[i]; + Review item = p19[i]; result.Add(item == null ? null : new ReviewSDto() { Title = item.Title, @@ -557,47 +488,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain11(List p24) + private static List funcMain9(List p20) { - if (p24 == null) + if (p20 == null) { return null; } - List result = new List(p24.Count); + List result = new List(p20.Count); int i = 0; - int len = p24.Count; + int len = p20.Count; while (i < len) { - ProductCategory item = p24[i]; - result.Add(item == null ? null : new ProductCategorySDto() - { - CategoryId = item.CategoryId, - CategoryName = item.Category == null ? null : item.Category.Name, - ProductId = item.ProductId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain12(List p25) - { - if (p25 == null) - { - return null; - } - List result = new List(p25.Count); - - int i = 0; - int len = p25.Count; - - while (i < len) - { - ProductStorageFile item = p25[i]; + ProductStorageFile item = p20[i]; result.Add(item == null ? null : new StorageFileSDto() { Name = item.Name, @@ -614,20 +518,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain13(List p28, List p29) + private static List funcMain10(List p23, List p24) { - if (p28 == null) + if (p23 == null) { return null; } - List result = new List(p28.Count); + List result = new List(p23.Count); int i = 0; - int len = p28.Count; + int len = p23.Count; while (i < len) { - Specification item = p28[i]; + Specification item = p23[i]; result.Add(item == null ? null : new SpecificationSDto() { Title = item.Title, @@ -644,20 +548,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain14(List p30, List p31) + private static List funcMain11(List p25, List p26) { - if (p30 == null) + if (p25 == null) { return null; } - List result = new List(p30.Count); + List result = new List(p25.Count); int i = 0; - int len = p30.Count; + int len = p25.Count; while (i < len) { - Review item = p30[i]; + Review item = p25[i]; result.Add(item == null ? null : new ReviewSDto() { Title = item.Title, @@ -674,47 +578,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain15(List p32, List p33) + private static List funcMain12(List p27, List p28) { - if (p32 == null) + if (p27 == null) { return null; } - List result = new List(p32.Count); + List result = new List(p27.Count); int i = 0; - int len = p32.Count; + int len = p27.Count; while (i < len) { - ProductCategory item = p32[i]; - result.Add(item == null ? null : new ProductCategorySDto() - { - CategoryId = item.CategoryId, - CategoryName = item.Category == null ? null : item.Category.Name, - ProductId = item.ProductId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain16(List p34, List p35) - { - if (p34 == null) - { - return null; - } - List result = new List(p34.Count); - - int i = 0; - int len = p34.Count; - - while (i < len) - { - ProductStorageFile item = p34[i]; + ProductStorageFile item = p27[i]; result.Add(item == null ? null : new StorageFileSDto() { Name = item.Name, diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index 794be12..88b913e 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Brands; - -namespace NetinaShop.Domain; +namespace NetinaShop.Domain; public class MapsterRegister : IRegister { diff --git a/NetinaShop.Domain/Models/Claims/ClaimDto.cs b/NetinaShop.Domain/Models/Claims/ClaimDto.cs index 6b33ed4..ce97ac2 100644 --- a/NetinaShop.Domain/Models/Claims/ClaimDto.cs +++ b/NetinaShop.Domain/Models/Claims/ClaimDto.cs @@ -11,8 +11,8 @@ public class ClaimDto : INotifyPropertyChanged public string Detail { get; set; } = string.Empty; public bool IsSelected { get; set; } = false; - public event PropertyChangedEventHandler PropertyChanged; - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + public event PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } diff --git a/NetinaShop.Domain/Models/Settings/SiteSettings.cs b/NetinaShop.Domain/Models/Settings/SiteSettings.cs index 42fb700..1aebd7c 100644 --- a/NetinaShop.Domain/Models/Settings/SiteSettings.cs +++ b/NetinaShop.Domain/Models/Settings/SiteSettings.cs @@ -1,5 +1,11 @@ namespace NetinaShop.Domain.Models.Settings; +public class ShopSettings +{ + public double TaxesFee { get; set; } + public double ServiceFee { get; set; } + public bool ServiceIsPercent { get; set; } +} public class SiteSettings { public JwtSettings JwtSettings { get; set; } = new JwtSettings(); diff --git a/NetinaShop.Domain/NetinaShop.Domain.csproj b/NetinaShop.Domain/NetinaShop.Domain.csproj index 5c97f52..292a3bb 100644 --- a/NetinaShop.Domain/NetinaShop.Domain.csproj +++ b/NetinaShop.Domain/NetinaShop.Domain.csproj @@ -36,8 +36,6 @@ - - @@ -64,6 +62,8 @@ + + diff --git a/NetinaShop.Repository/Abstracts/IPaymentService.cs b/NetinaShop.Repository/Abstracts/IPaymentService.cs new file mode 100644 index 0000000..e65036c --- /dev/null +++ b/NetinaShop.Repository/Abstracts/IPaymentService.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Repository.Abstracts; + +public interface IPaymentService : IScopedDependency +{ + Task GetPaymentLinkAsync(Guid orderId, double amount, string description); + Task VerifiedPaymentAsync(string fishNumber, Guid orderId); +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs index 14ccfee..2e6c27a 100644 --- a/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Categories/CreateCategoryCommandHandler.cs @@ -1,8 +1,4 @@ -using NetinaShop.Domain.Entities.Categories; -using NetinaShop.Repository.Repositories.Base; -using NetinaShop.Repository.Repositories.Base.Contracts; - -namespace NetinaShop.Repository.Handlers.Categories; +namespace NetinaShop.Repository.Handlers.Categories; public class CreateCategoryCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs index da49b33..7d56556 100644 --- a/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Categories/DeleteCategoryCommandHandler.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Categories; - -namespace NetinaShop.Repository.Handlers.Categories; +namespace NetinaShop.Repository.Handlers.Categories; public class DeleteCategoryCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs b/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs index 41ad6fa..463f2e5 100644 --- a/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Categories/GetCategoriesQueryHandler.cs @@ -1,8 +1,4 @@ -using NetinaShop.Domain.CommandQueries.Queries; -using NetinaShop.Domain.Dtos.SmallDtos; -using NetinaShop.Domain.Entities.Categories; - -namespace NetinaShop.Repository.Handlers.Categories; +namespace NetinaShop.Repository.Handlers.Categories; public class GetCategoriesQueryHandler : IRequestHandler> { diff --git a/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs b/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs index 4ff87ac..530abf0 100644 --- a/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Categories/GetCategoryQueryHandler.cs @@ -1,9 +1,6 @@ -using NetinaShop.Domain.CommandQueries.Queries; -using NetinaShop.Domain.Entities.Categories; +namespace NetinaShop.Repository.Handlers.Categories; -namespace NetinaShop.Repository.Handlers.Categories; - -public class GetCategoryQueryHandler : IRequestHandler> +public class GetCategoryQueryHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; diff --git a/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs b/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs index 158197e..1582ede 100644 --- a/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Categories/UpdateCategoryCommandHandler.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Categories; - -namespace NetinaShop.Repository.Handlers.Categories; +namespace NetinaShop.Repository.Handlers.Categories; public class UpdateCategoryCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Discounts/CalculateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/CalculateDiscountCommandHandler.cs new file mode 100644 index 0000000..ff855b3 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Discounts/CalculateDiscountCommandHandler.cs @@ -0,0 +1,59 @@ +namespace NetinaShop.Repository.Handlers.Discounts; + +public class CalculateDiscountCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CalculateDiscountCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CalculateDiscountCommand request, CancellationToken cancellationToken) + { + if (request.Order == null) + throw new AppException("Order is null", ApiResultStatusCode.BadRequest); + var discount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken); + if (discount == null) + throw new AppException("Discount not found", ApiResultStatusCode.NotFound); + + double discountPrice = 0; + + if (discount.Type == DiscountType.All) + { + var totalPrice = request.Order.OrderProducts.Sum(op => op.ProductCost); + discountPrice = discount.AmountType == DiscountAmountType.Amount + ? totalPrice - discount.DiscountAmount + : totalPrice - ((totalPrice / 100) * discount.DiscountAmount); + } + else if (discount.Type == DiscountType.Category) + { + var categoryDiscount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken); + + var totalPrice = request.Order.OrderProducts.Where(op=>op.ProductCategoryId == categoryDiscount!.CategoryId).Sum(op => op.ProductCost); + discountPrice = discount.AmountType == DiscountAmountType.Amount + ? totalPrice - discount.DiscountAmount + : totalPrice - ((totalPrice / 100) * discount.DiscountAmount); + } + else if (discount.Type == DiscountType.Product) + { + var productDiscount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken); + + var totalPrice = request.Order.OrderProducts.Where(op => op.ProductId == productDiscount!.ProductId).Sum(op => op.ProductCost); + discountPrice = discount.AmountType == DiscountAmountType.Amount + ? totalPrice - discount.DiscountAmount + : totalPrice - ((totalPrice / 100) * discount.DiscountAmount); + } + else if (discount.Type == DiscountType.Subscriber) + { + throw new NotImplementedException("Subscribe discount not implemented"); + } + + return discountPrice; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs index 8bb2f9b..6f290f4 100644 --- a/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Discounts/CreateDiscountCommandHandler.cs @@ -1,6 +1,4 @@ -using NetinaShop.Repository.Repositories.Base; - -namespace NetinaShop.Repository.Handlers.Discounts; +namespace NetinaShop.Repository.Handlers.Discounts; public class CreateDiscountCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/OrderBags/AddToOrderBagCommandHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/AddToOrderBagCommandHandler.cs new file mode 100644 index 0000000..caf1e13 --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/AddToOrderBagCommandHandler.cs @@ -0,0 +1,45 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class AddToOrderBagCommandHandler : IRequestHandler +{ + private readonly IMediator _mediator; + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + + public AddToOrderBagCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) + { + _mediator = mediator; + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + } + + public async Task Handle(AddToOrderBagCommand request, CancellationToken cancellationToken) + { + if (_currentUserService.UserId == null) + throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + + var product = await _repositoryWrapper.SetRepository() + .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); + + _repositoryWrapper.SetRepository().Update(orderBag); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + await _mediator.Send(new CalculateOrderCommand(orderBag.Id), cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/OrderBags/GetUserOrderBagQueryHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/GetUserOrderBagQueryHandler.cs new file mode 100644 index 0000000..90ac509 --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/GetUserOrderBagQueryHandler.cs @@ -0,0 +1,42 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class GetUserOrderBagQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + private readonly IMediator _mediator; + + public GetUserOrderBagQueryHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService,IMediator mediator) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + _mediator = mediator; + } + public async Task Handle(GetUserOrderBagQuery request, CancellationToken cancellationToken) + { + if (_currentUserService.UserId == null) + throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new AppException("User id wrong",ApiResultStatusCode.BadRequest); + + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(o => o.UserId == userId && o.OrderStatus == OrderStatus.OrderBag,cancellationToken); + + if (order == null) + order = await _mediator.Send(new CreateBaseOrderCommand(userId),cancellationToken); + else + { + var orderProducts = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(op=>op.OrderId==order.Id) + .ToListAsync(cancellationToken); + + orderProducts.ForEach(op=>order.AddOrderProduct(op)); + } + + return order; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/OrderBags/RemoveFromOrderBagCommandHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/RemoveFromOrderBagCommandHandler.cs new file mode 100644 index 0000000..061197d --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/RemoveFromOrderBagCommandHandler.cs @@ -0,0 +1,44 @@ +using Order = NetinaShop.Domain.Entities.Orders.Order; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class RemoveFromOrderBagCommandHandler : IRequestHandler +{ + private readonly ICurrentUserService _currentUserService; + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; + + public RemoveFromOrderBagCommandHandler(ICurrentUserService currentUserService, IRepositoryWrapper repositoryWrapper,IMediator mediator) + { + _currentUserService = currentUserService; + _repositoryWrapper = repositoryWrapper; + _mediator = mediator; + } + public async Task Handle(RemoveFromOrderBagCommand request, CancellationToken cancellationToken) + { + if (_currentUserService.UserId == null) + throw new AppException("User id notfound", ApiResultStatusCode.BadRequest); + if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + throw new AppException("User id wrong", ApiResultStatusCode.BadRequest); + + var product = await _repositoryWrapper.SetRepository() + .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); + + + _repositoryWrapper.SetRepository().Update(orderBag); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await _mediator.Send(new CalculateOrderCommand(orderBag.Id), cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/OrderBags/SubmitDiscountCommandHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/SubmitDiscountCommandHandler.cs new file mode 100644 index 0000000..7ae463f --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/SubmitDiscountCommandHandler.cs @@ -0,0 +1,29 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class SubmitDiscountCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; + + public SubmitDiscountCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator) + { + _repositoryWrapper = repositoryWrapper; + _mediator = mediator; + } + public async Task Handle(SubmitDiscountCommand request, CancellationToken cancellationToken) + { + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + if (order == null) + throw new AppException("Order not found", ApiResultStatusCode.NotFound); + order.SetDiscount(request.DiscountCode); + _repositoryWrapper.SetRepository().Update(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderDeliveryCommandHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderDeliveryCommandHandler.cs new file mode 100644 index 0000000..f059e5b --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderDeliveryCommandHandler.cs @@ -0,0 +1,38 @@ +using NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class SubmitOrderDeliveryCommandHandler : IRequestHandler +{ + private readonly IMediator _mediator; + private readonly IRepositoryWrapper _repositoryWrapper; + + public SubmitOrderDeliveryCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper) + { + _mediator = mediator; + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken) + { + var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken); + var shipping = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken); + if (shipping == null) + throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); + foreach (var orderDelivery in order.OrderDeliveries) + { + _repositoryWrapper.SetRepository() + .Delete(orderDelivery); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + order.OrderDeliveries.Clear(); + order.AddOrderDelivery(request.Address,request.PostalCode,request.ReceiverPhoneNumber,request.ReceiverFullName,shipping.DeliveryCost,request.ShippingId,request.OrderId); + + _repositoryWrapper.SetRepository().Update(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderPaymentCommandHandler.cs b/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderPaymentCommandHandler.cs new file mode 100644 index 0000000..4fd0bfc --- /dev/null +++ b/NetinaShop.Repository/Handlers/OrderBags/SubmitOrderPaymentCommandHandler.cs @@ -0,0 +1,51 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.OrderBags; + +public class SubmitOrderPaymentCommandHandler : IRequestHandler +{ + private readonly IMediator _mediator; + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IPaymentService _paymentService; + + public SubmitOrderPaymentCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper, IPaymentService paymentService) + { + _mediator = mediator; + _repositoryWrapper = repositoryWrapper; + _paymentService = paymentService; + } + public async Task Handle(SubmitOrderPaymentCommand request, CancellationToken cancellationToken) + { + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + + if (order == null) + throw new AppException("Order not found", ApiResultStatusCode.NotFound); + + var response = new SubmitOrderPaymentResponseDto(); + + if (request.PaymentMethod == OrderPaymentMethod.OnlinePayment) + { + response.NeedToPayOnline = true; + response.PaymentUrl = await _paymentService.GetPaymentLinkAsync(order.Id, order.TotalPrice, $"پرداخت سفارش {order.Id}"); + } + else if (request.PaymentMethod == OrderPaymentMethod.Cash) + { + response.NeedToPayOnline = false; + order.SetSubmitOrder(request.PaymentMethod); + _repositoryWrapper.SetRepository().Update(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + else if (request.PaymentMethod == OrderPaymentMethod.CardTransfer) + { + response.NeedToPayOnline = false; + order.SetSubmitOrder(request.PaymentMethod); + _repositoryWrapper.SetRepository().Update(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + + return response; + + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/CalculateOrderCommandHandler.cs b/NetinaShop.Repository/Handlers/Orders/CalculateOrderCommandHandler.cs new file mode 100644 index 0000000..07da1bf --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/CalculateOrderCommandHandler.cs @@ -0,0 +1,43 @@ +using Microsoft.IdentityModel.Tokens; +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class CalculateOrderCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; + private readonly ShopSettings _shopSettings; + + public CalculateOrderCommandHandler(IRepositoryWrapper repositoryWrapper,IMediator mediator,IOptionsSnapshot snapshot) + { + _repositoryWrapper = repositoryWrapper; + _mediator = mediator; + _shopSettings = snapshot.Value; + } + public async Task Handle(CalculateOrderCommand request, CancellationToken cancellationToken) + { + var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken); + if (order.OrderStatus != OrderStatus.OrderBag) + throw new AppException("Order is not in bag status and cant be calculate", ApiResultStatusCode.BadRequest); + var totalProductPrice = order.OrderProducts.Sum(op => op.ProductCost); + var totalPackingPrice = order.OrderProducts.Sum(op => op.PackingCost); + var servicePrice = _shopSettings.ServiceIsPercent + ? (totalProductPrice / 100) * _shopSettings.ServiceFee + : _shopSettings.ServiceFee; + var deliveryPrice = order.OrderDeliveries.Sum(op => op.DeliveryCost); + double discountPrice = 0; + if (!order.DiscountCode.IsNullOrEmpty()) + { + discountPrice = await _mediator.Send(new CalculateDiscountCommand(order.DiscountCode, order),cancellationToken); + } + + var taxesPrice = (((totalProductPrice - discountPrice) + totalPackingPrice + servicePrice) / 100) * _shopSettings.TaxesFee; + + order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice); + + _repositoryWrapper.SetRepository().Update(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return order; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs b/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs new file mode 100644 index 0000000..0c075ce --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/CreateBaseOrderCommandHandler.cs @@ -0,0 +1,27 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class CreateBaseOrderCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreateBaseOrderCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateBaseOrderCommand request, CancellationToken cancellationToken) + { + if (request.UserId == default) + throw new AppException("User id is null"); + + var order = Order.Create(request.UserId); + + _repositoryWrapper.SetRepository() + .Add(order); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + return order; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs b/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs new file mode 100644 index 0000000..9673252 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/DeleteOrderCommandHandler.cs @@ -0,0 +1,24 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class DeleteOrderCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteOrderCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteOrderCommand request, CancellationToken cancellationToken) + { + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + if (order == null) + throw new AppException("Order not found", ApiResultStatusCode.NotFound); + _repositoryWrapper.SetRepository().Delete(order); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs new file mode 100644 index 0000000..610f903 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/GetOrderQueryHandler.cs @@ -0,0 +1,38 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class GetOrderQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetOrderQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetOrderQuery request, CancellationToken cancellationToken) + { + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(o => o.Id == request.Id, cancellationToken); + + if (order == null) + throw new AppException("Order not found", ApiResultStatusCode.NotFound); + + var orderProducts = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(op => op.OrderId == order.Id) + .ToListAsync(cancellationToken); + + orderProducts.ForEach(op => order.AddOrderProduct(op)); + + var orderDeliveries = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(od => od.OrderId == request.Id) + .ToListAsync(cancellationToken); + + orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.Address,od.PostalCode,od.ReceiverPhoneNumber,od.ReceiverFullName,od.DeliveryCost,od.ShippingId,od.OrderId)); + + return order; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs new file mode 100644 index 0000000..658e8ae --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs @@ -0,0 +1,23 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class GetOrdersQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetOrdersQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public Task> Handle(GetOrdersQuery request, CancellationToken cancellationToken) + { + return _repositoryWrapper.SetRepository() + .TableNoTracking + .Skip(request.Page * 15) + .Take(15) + .Select(OrderMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs index a87b0c7..f1ed718 100644 --- a/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/CreateProductCommandHandler.cs @@ -12,18 +12,13 @@ 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.BrandId); + request.Tags, request.Warranty,request.BeDisplayed,request.Cost,request.PackingCost, request.BrandId,request.CategoryId); foreach (var specification in request.Specifications) { ent.AddSpecification(specification.Title, specification.Detail, specification.Value, specification.IsFeature, specification.ParentId); } - foreach (var category in request.Categories) - { - ent.AddCategory(category); - } - foreach (var file in request.Files) { ent.AddFile(file.Name, file.FileLocation, file.FileName, file.IsHeader, file.IsPrimary, file.FileType); diff --git a/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs index 6247318..50a66a3 100644 --- a/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/DeleteProductCommandHandler.cs @@ -1,6 +1,4 @@ -using NetinaShop.Repository.Repositories.Base; - -namespace NetinaShop.Repository.Handlers.Products; +namespace NetinaShop.Repository.Handlers.Products; public class DeleteProductCommandHandler : IRequestHandler { diff --git a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs index 1636067..9fdf251 100644 --- a/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Products/UpdateProductCommandHandler.cs @@ -16,7 +16,7 @@ public class UpdateProductCommandHandler : IRequestHandler().TableNoTracking @@ -35,23 +35,6 @@ public class UpdateProductCommandHandler : IRequestHandler().TableNoTracking - .Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken); - foreach (var dbCat in dbCats) - { - if (request.Categories.Any(s => s == dbCat.CategoryId)) - { - _repositoryWrapper.SetRepository().Delete(dbCat); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); - } - } - foreach (var category in request.Categories) - { - if (dbCats.Any(c => c.Id == category)) - newEnt.AddCategory(category); - } - - var dbFiles = await _repositoryWrapper.SetRepository().TableNoTracking .Where(s => s.ProductId == ent.Id).ToListAsync(cancellationToken); diff --git a/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs index 88216fa..b24b7cf 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/CreateShippingCommandHandler.cs @@ -1,5 +1,4 @@ -using NetinaShop.Domain.Dtos.SmallDtos; -using NetinaShop.Domain.Entities.Warehouses; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Repository.Handlers.Warehouses; @@ -14,7 +13,7 @@ public class CreateShippingCommandHandler : IRequestHandler Handle(CreateShippingCommand request, CancellationToken cancellationToken) { var ent = Shipping.Create(request.Title, request.WarehouseName, request.IsFastShipping, request.IsShipBySeller, - request.IsOriginalWarehouse); + request.IsOriginalWarehouse,request.DeliveryCost); _repositoryWrapper.SetRepository().Add(ent); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return ent.AdaptToSDto(); diff --git a/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs new file mode 100644 index 0000000..2950bbf --- /dev/null +++ b/NetinaShop.Repository/Handlers/Warehouses/GetShippingQueryHandler.cs @@ -0,0 +1,22 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.Warehouses; + +public class GetShippingQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetShippingQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetShippingQuery request, CancellationToken cancellationToken) + { + var shippingMethod = await _repositoryWrapper.SetRepository().TableNoTracking.Where(b => b.Id == request.Id) + .Select(ShippingMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (shippingMethod == null) + throw new AppException("Shipping method not found", ApiResultStatusCode.NotFound); + return shippingMethod; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs new file mode 100644 index 0000000..8a8e457 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Warehouses/GetShippingsQueryHandler.cs @@ -0,0 +1,23 @@ +using NetinaShop.Domain.Entities.Warehouses; + +namespace NetinaShop.Repository.Handlers.Warehouses; + +public class GetShippingsQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetShippingsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetShippingsQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper + .SetRepository() + .TableNoTracking.OrderByDescending(b => b.CreatedAt) + .Skip(request.Page * 10) + .Take(10) + .Select(ShippingMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs index a7a821a..e08fd14 100644 --- a/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs +++ b/NetinaShop.Repository/Handlers/Warehouses/UpdateShippingCommandHandler.cs @@ -18,7 +18,7 @@ public class UpdateShippingCommandHandler : IRequestHandler().Update(newEnt); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/NetinaShop.Repository/Migrations/20231211073413_init.Designer.cs b/NetinaShop.Repository/Migrations/20231231111356_Init.Designer.cs similarity index 92% rename from NetinaShop.Repository/Migrations/20231211073413_init.Designer.cs rename to NetinaShop.Repository/Migrations/20231231111356_Init.Designer.cs index 681186a..ec778f0 100644 --- a/NetinaShop.Repository/Migrations/20231211073413_init.Designer.cs +++ b/NetinaShop.Repository/Migrations/20231231111356_Init.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace NetinaShop.Repository.Migrations { [DbContext(typeof(ApplicationContext))] - [Migration("20231211073413_init")] - partial class init + [Migration("20231231111356_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -146,7 +146,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -159,7 +158,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ReadingTime") @@ -169,7 +167,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Summery") @@ -201,7 +198,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -215,7 +211,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -226,7 +221,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -244,7 +238,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -261,7 +254,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -276,7 +268,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -294,7 +285,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -308,7 +298,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -322,7 +311,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -352,7 +340,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("DiscountAmount") @@ -391,7 +378,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PriceCeiling") @@ -404,7 +390,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("StartDate") @@ -435,11 +420,10 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); - b.Property("DeliveryPrice") - .HasColumnType("bigint"); + b.Property("DeliveryPrice") + .HasColumnType("double precision"); b.Property("DiscountCode") .IsRequired() @@ -448,8 +432,8 @@ namespace NetinaShop.Repository.Migrations b.Property("DiscountId") .HasColumnType("uuid"); - b.Property("DiscountPrice") - .HasColumnType("bigint"); + b.Property("DiscountPrice") + .HasColumnType("double precision"); b.Property("DoneAt") .HasColumnType("timestamp without time zone"); @@ -464,7 +448,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderAt") @@ -473,8 +456,14 @@ namespace NetinaShop.Repository.Migrations b.Property("OrderStatus") .HasColumnType("integer"); - b.Property("PackingPrice") - .HasColumnType("bigint"); + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); b.Property("PreparingMinute") .HasColumnType("integer"); @@ -483,25 +472,29 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); - b.Property("ServicePrice") - .HasColumnType("bigint"); + b.Property("ServicePrice") + .HasColumnType("double precision"); - b.Property("TaxesPrice") - .HasColumnType("bigint"); + b.Property("TaxesPrice") + .HasColumnType("double precision"); - b.Property("TotalPrice") - .HasColumnType("bigint"); + b.Property("TotalPrice") + .HasColumnType("double precision"); - b.Property("TotalProductsPrice") - .HasColumnType("bigint"); + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex("DiscountId"); + b.HasIndex("UserId"); + b.ToTable("Orders", "public"); }); @@ -519,9 +512,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); + b.Property("DeliveryCost") + .HasColumnType("double precision"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -529,7 +524,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -551,13 +545,17 @@ namespace NetinaShop.Repository.Migrations .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"); }); @@ -574,7 +572,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -584,7 +581,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -593,11 +589,20 @@ namespace NetinaShop.Repository.Migrations b.Property("OrderProductStatus") .HasColumnType("integer"); - b.Property("ProductCost") - .HasColumnType("real"); + b.Property("PackingCost") + .HasColumnType("double precision"); - b.Property("ProductFee") - .HasColumnType("real"); + 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"); @@ -606,7 +611,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -624,14 +628,22 @@ namespace NetinaShop.Repository.Migrations .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") @@ -642,6 +654,9 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("IsEnable") + .HasColumnType("boolean"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -649,9 +664,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); + b.Property("PackingCost") + .HasColumnType("double precision"); + b.Property("PersianName") .IsRequired() .HasColumnType("text"); @@ -660,7 +677,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Summery") @@ -679,52 +695,9 @@ namespace NetinaShop.Repository.Migrations b.HasIndex("BrandId"); - b.ToTable("Products", "public"); - }); - - modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CategoryId") - .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.HasKey("Id"); - b.HasIndex("CategoryId"); - b.HasIndex("ProductId"); - - b.ToTable("ProductCategories", "public"); + b.ToTable("Products", "public"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => @@ -741,7 +714,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsBuyer") @@ -754,7 +726,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -767,7 +738,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Title") @@ -796,7 +766,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Detail") @@ -813,7 +782,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ParentId") @@ -826,13 +794,16 @@ namespace NetinaShop.Repository.Migrations .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"); @@ -842,58 +813,6 @@ namespace NetinaShop.Repository.Migrations b.ToTable("Specifications", "public"); }); - modelBuilder.Entity("NetinaShop.Domain.Entities.Sellers.Shipping", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsFastShipping") - .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.StorageFiles.StorageFile", b => { b.Property("Id") @@ -904,7 +823,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -936,7 +854,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -947,7 +864,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -1098,7 +1014,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -1114,7 +1029,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PostalCode") @@ -1133,7 +1047,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1156,7 +1069,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -1166,7 +1078,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -1176,7 +1087,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1191,6 +1101,58 @@ namespace NetinaShop.Repository.Migrations 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("IsFastShipping") + .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"); @@ -1341,17 +1303,33 @@ namespace NetinaShop.Repository.Migrations 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() + .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 => @@ -1381,26 +1359,15 @@ namespace NetinaShop.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("Brand"); - }); - - modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b => - { b.HasOne("NetinaShop.Domain.Entities.Categories.Category", "Category") .WithMany("Products") .HasForeignKey("CategoryId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") - .WithMany("Categories") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); + b.Navigation("Brand"); b.Navigation("Category"); - - b.Navigation("Product"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => @@ -1570,13 +1537,13 @@ namespace NetinaShop.Repository.Migrations modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => { + b.Navigation("OrderDeliveries"); + b.Navigation("OrderProducts"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => { - b.Navigation("Categories"); - b.Navigation("Files"); b.Navigation("OrderProducts"); diff --git a/NetinaShop.Repository/Migrations/20231211073413_init.cs b/NetinaShop.Repository/Migrations/20231231111356_Init.cs similarity index 92% rename from NetinaShop.Repository/Migrations/20231211073413_init.cs rename to NetinaShop.Repository/Migrations/20231231111356_Init.cs index ae94041..200b322 100644 --- a/NetinaShop.Repository/Migrations/20231211073413_init.cs +++ b/NetinaShop.Repository/Migrations/20231231111356_Init.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace NetinaShop.Repository.Migrations { /// - public partial class init : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -25,11 +25,11 @@ namespace NetinaShop.Repository.Migrations Description = table.Column(type: "text", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -48,11 +48,11 @@ namespace NetinaShop.Repository.Migrations PageUrl = table.Column(type: "text", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -70,11 +70,11 @@ namespace NetinaShop.Repository.Migrations ParentId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -117,13 +117,14 @@ namespace NetinaShop.Repository.Migrations IsFastShipping = table.Column(type: "boolean", nullable: false), IsShipBySeller = table.Column(type: "boolean", nullable: false), IsOriginalWarehouse = table.Column(type: "boolean", nullable: false), + DeliveryCost = table.Column(type: "double precision", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -177,11 +178,11 @@ namespace NetinaShop.Repository.Migrations CategoryId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -207,14 +208,19 @@ namespace NetinaShop.Repository.Migrations ExpertCheck = table.Column(type: "text", nullable: false), Tags = table.Column(type: "text", nullable: false), Warranty = table.Column(type: "text", nullable: false), + Cost = table.Column(type: "double precision", nullable: false), + IsEnable = table.Column(type: "boolean", nullable: false), + BeDisplayed = table.Column(type: "boolean", nullable: false), + PackingCost = table.Column(type: "double precision", nullable: false), BrandId = table.Column(type: "uuid", nullable: false), + CategoryId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -226,6 +232,13 @@ namespace NetinaShop.Repository.Migrations principalTable: "Brands", principalColumn: "Id", onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Products_Categories_CategoryId", + column: x => x.CategoryId, + principalSchema: "public", + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -333,11 +346,11 @@ namespace NetinaShop.Repository.Migrations UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -405,11 +418,11 @@ namespace NetinaShop.Repository.Migrations ProductId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -430,41 +443,6 @@ namespace NetinaShop.Repository.Migrations onDelete: ReferentialAction.Restrict); }); - migrationBuilder.CreateTable( - name: "ProductCategories", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - CategoryId = table.Column(type: "uuid", nullable: false), - ProductId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ProductCategories", x => x.Id); - table.ForeignKey( - name: "FK_ProductCategories_Categories_CategoryId", - column: x => x.CategoryId, - principalSchema: "public", - principalTable: "Categories", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ProductCategories_Products_ProductId", - column: x => x.ProductId, - principalSchema: "public", - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - migrationBuilder.CreateTable( name: "Reviews", schema: "public", @@ -479,11 +457,11 @@ namespace NetinaShop.Repository.Migrations UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -512,16 +490,17 @@ namespace NetinaShop.Repository.Migrations Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "text", nullable: false), Detail = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: false), IsFeature = table.Column(type: "boolean", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), ParentId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -561,11 +540,11 @@ namespace NetinaShop.Repository.Migrations ProductId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -610,11 +589,11 @@ namespace NetinaShop.Repository.Migrations UserId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -641,27 +620,30 @@ namespace NetinaShop.Repository.Migrations columns: table => new { Id = table.Column(type: "uuid", nullable: false), - TotalPrice = table.Column(type: "bigint", nullable: false), - DeliveryPrice = table.Column(type: "bigint", nullable: false), - TaxesPrice = table.Column(type: "bigint", nullable: false), - ServicePrice = table.Column(type: "bigint", nullable: false), - PackingPrice = table.Column(type: "bigint", nullable: false), - TotalProductsPrice = table.Column(type: "bigint", nullable: false), - DiscountPrice = table.Column(type: "bigint", nullable: false), + TotalProductsPrice = table.Column(type: "double precision", nullable: false), + PackingPrice = table.Column(type: "double precision", nullable: false), + ServicePrice = table.Column(type: "double precision", nullable: false), + DeliveryPrice = table.Column(type: "double precision", nullable: false), + DiscountPrice = table.Column(type: "double precision", nullable: false), + TaxesPrice = table.Column(type: "double precision", nullable: false), + TotalPrice = table.Column(type: "double precision", nullable: false), IsPayed = table.Column(type: "boolean", nullable: false), + PayedAt = table.Column(type: "timestamp without time zone", nullable: false), + PaymentMethod = table.Column(type: "integer", nullable: false), OrderStatus = table.Column(type: "integer", nullable: false), DoneAt = table.Column(type: "timestamp without time zone", nullable: false), OrderAt = table.Column(type: "timestamp without time zone", nullable: false), PreparingMinute = table.Column(type: "integer", nullable: false), DiscountCode = table.Column(type: "text", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), DiscountId = table.Column(type: "uuid", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -672,6 +654,13 @@ namespace NetinaShop.Repository.Migrations principalSchema: "public", principalTable: "Discounts", principalColumn: "Id"); + table.ForeignKey( + name: "FK_Orders_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -684,14 +673,16 @@ namespace NetinaShop.Repository.Migrations PostalCode = table.Column(type: "text", nullable: false), ReceiverPhoneNumber = table.Column(type: "text", nullable: false), ReceiverFullName = table.Column(type: "text", nullable: false), + DeliveryCost = table.Column(type: "double precision", nullable: false), + ShippingId = table.Column(type: "uuid", nullable: false), OrderId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -703,6 +694,13 @@ namespace NetinaShop.Repository.Migrations principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_OrderDeliveries_Shippings_ShippingId", + column: x => x.ShippingId, + principalSchema: "public", + principalTable: "Shippings", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -712,18 +710,21 @@ namespace NetinaShop.Repository.Migrations { Id = table.Column(type: "uuid", nullable: false), Count = table.Column(type: "integer", nullable: false), - ProductFee = table.Column(type: "real", nullable: false), - ProductCost = table.Column(type: "real", nullable: false), + ProductFee = table.Column(type: "double precision", nullable: false), + ProductCost = table.Column(type: "double precision", nullable: false), + PackingFee = table.Column(type: "double precision", nullable: false), + PackingCost = table.Column(type: "double precision", nullable: false), OrderProductStatus = table.Column(type: "integer", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), + ProductCategoryId = table.Column(type: "uuid", nullable: false), OrderId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), + CreatedBy = table.Column(type: "text", nullable: true), IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), + RemovedBy = table.Column(type: "text", nullable: true), ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + ModifiedBy = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -786,6 +787,12 @@ namespace NetinaShop.Repository.Migrations table: "OrderDeliveries", column: "OrderId"); + migrationBuilder.CreateIndex( + name: "IX_OrderDeliveries_ShippingId", + schema: "public", + table: "OrderDeliveries", + column: "ShippingId"); + migrationBuilder.CreateIndex( name: "IX_OrderProducts_OrderId", schema: "public", @@ -805,16 +812,10 @@ namespace NetinaShop.Repository.Migrations column: "DiscountId"); migrationBuilder.CreateIndex( - name: "IX_ProductCategories_CategoryId", + name: "IX_Orders_UserId", schema: "public", - table: "ProductCategories", - column: "CategoryId"); - - migrationBuilder.CreateIndex( - name: "IX_ProductCategories_ProductId", - schema: "public", - table: "ProductCategories", - column: "ProductId"); + table: "Orders", + column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Products_BrandId", @@ -822,6 +823,12 @@ namespace NetinaShop.Repository.Migrations table: "Products", column: "BrandId"); + migrationBuilder.CreateIndex( + name: "IX_Products_CategoryId", + schema: "public", + table: "Products", + column: "CategoryId"); + migrationBuilder.CreateIndex( name: "IX_Reviews_ProductId", schema: "public", @@ -940,10 +947,6 @@ namespace NetinaShop.Repository.Migrations name: "OrderProducts", schema: "public"); - migrationBuilder.DropTable( - name: "ProductCategories", - schema: "public"); - migrationBuilder.DropTable( name: "Reviews", schema: "public"); @@ -952,10 +955,6 @@ namespace NetinaShop.Repository.Migrations name: "RoleClaims", schema: "public"); - migrationBuilder.DropTable( - name: "Shippings", - schema: "public"); - migrationBuilder.DropTable( name: "Specifications", schema: "public"); @@ -980,6 +979,10 @@ namespace NetinaShop.Repository.Migrations name: "UserRoles", schema: "public"); + migrationBuilder.DropTable( + name: "Shippings", + schema: "public"); + migrationBuilder.DropTable( name: "Orders", schema: "public"); @@ -992,20 +995,16 @@ namespace NetinaShop.Repository.Migrations name: "Roles", schema: "public"); - migrationBuilder.DropTable( - name: "Users", - schema: "public"); - migrationBuilder.DropTable( name: "Discounts", schema: "public"); migrationBuilder.DropTable( - name: "BlogCategories", + name: "Users", schema: "public"); migrationBuilder.DropTable( - name: "Categories", + name: "BlogCategories", schema: "public"); migrationBuilder.DropTable( @@ -1015,6 +1014,10 @@ namespace NetinaShop.Repository.Migrations migrationBuilder.DropTable( name: "Brands", schema: "public"); + + migrationBuilder.DropTable( + name: "Categories", + schema: "public"); } } } diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index c0d69d5..dee1753 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -143,7 +143,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -156,7 +155,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ReadingTime") @@ -166,7 +164,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Summery") @@ -198,7 +195,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -212,7 +208,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -223,7 +218,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -241,7 +235,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -258,7 +251,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -273,7 +265,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -291,7 +282,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Description") @@ -305,7 +295,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -319,7 +308,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -349,7 +337,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("DiscountAmount") @@ -388,7 +375,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PriceCeiling") @@ -401,7 +387,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("StartDate") @@ -432,11 +417,10 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); - b.Property("DeliveryPrice") - .HasColumnType("bigint"); + b.Property("DeliveryPrice") + .HasColumnType("double precision"); b.Property("DiscountCode") .IsRequired() @@ -445,8 +429,8 @@ namespace NetinaShop.Repository.Migrations b.Property("DiscountId") .HasColumnType("uuid"); - b.Property("DiscountPrice") - .HasColumnType("bigint"); + b.Property("DiscountPrice") + .HasColumnType("double precision"); b.Property("DoneAt") .HasColumnType("timestamp without time zone"); @@ -461,7 +445,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderAt") @@ -470,8 +453,14 @@ namespace NetinaShop.Repository.Migrations b.Property("OrderStatus") .HasColumnType("integer"); - b.Property("PackingPrice") - .HasColumnType("bigint"); + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); b.Property("PreparingMinute") .HasColumnType("integer"); @@ -480,25 +469,29 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); - b.Property("ServicePrice") - .HasColumnType("bigint"); + b.Property("ServicePrice") + .HasColumnType("double precision"); - b.Property("TaxesPrice") - .HasColumnType("bigint"); + b.Property("TaxesPrice") + .HasColumnType("double precision"); - b.Property("TotalPrice") - .HasColumnType("bigint"); + b.Property("TotalPrice") + .HasColumnType("double precision"); - b.Property("TotalProductsPrice") - .HasColumnType("bigint"); + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); b.HasKey("Id"); b.HasIndex("DiscountId"); + b.HasIndex("UserId"); + b.ToTable("Orders", "public"); }); @@ -516,9 +509,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); + b.Property("DeliveryCost") + .HasColumnType("double precision"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -526,7 +521,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -548,13 +542,17 @@ namespace NetinaShop.Repository.Migrations .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"); }); @@ -571,7 +569,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -581,7 +578,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("OrderId") @@ -590,11 +586,20 @@ namespace NetinaShop.Repository.Migrations b.Property("OrderProductStatus") .HasColumnType("integer"); - b.Property("ProductCost") - .HasColumnType("real"); + b.Property("PackingCost") + .HasColumnType("double precision"); - b.Property("ProductFee") - .HasColumnType("real"); + 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"); @@ -603,7 +608,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -621,14 +625,22 @@ namespace NetinaShop.Repository.Migrations .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") @@ -639,6 +651,9 @@ namespace NetinaShop.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("IsEnable") + .HasColumnType("boolean"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -646,9 +661,11 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); + b.Property("PackingCost") + .HasColumnType("double precision"); + b.Property("PersianName") .IsRequired() .HasColumnType("text"); @@ -657,7 +674,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Summery") @@ -676,52 +692,9 @@ namespace NetinaShop.Repository.Migrations b.HasIndex("BrandId"); - b.ToTable("Products", "public"); - }); - - modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CategoryId") - .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.HasKey("Id"); - b.HasIndex("CategoryId"); - b.HasIndex("ProductId"); - - b.ToTable("ProductCategories", "public"); + b.ToTable("Products", "public"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => @@ -738,7 +711,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsBuyer") @@ -751,7 +723,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -764,7 +735,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("Title") @@ -793,7 +763,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Detail") @@ -810,7 +779,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ParentId") @@ -823,13 +791,16 @@ namespace NetinaShop.Repository.Migrations .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"); @@ -839,58 +810,6 @@ namespace NetinaShop.Repository.Migrations b.ToTable("Specifications", "public"); }); - modelBuilder.Entity("NetinaShop.Domain.Entities.Sellers.Shipping", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsFastShipping") - .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.StorageFiles.StorageFile", b => { b.Property("Id") @@ -901,7 +820,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -933,7 +851,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -944,7 +861,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -1095,7 +1011,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -1111,7 +1026,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("PostalCode") @@ -1130,7 +1044,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1153,7 +1066,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("CreatedBy") - .IsRequired() .HasColumnType("text"); b.Property("IsRemoved") @@ -1163,7 +1075,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("ModifiedBy") - .IsRequired() .HasColumnType("text"); b.Property("ProductId") @@ -1173,7 +1084,6 @@ namespace NetinaShop.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("RemovedBy") - .IsRequired() .HasColumnType("text"); b.Property("UserId") @@ -1188,6 +1098,58 @@ namespace NetinaShop.Repository.Migrations 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("IsFastShipping") + .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"); @@ -1338,17 +1300,33 @@ namespace NetinaShop.Repository.Migrations 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() + .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 => @@ -1378,26 +1356,15 @@ namespace NetinaShop.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("Brand"); - }); - - modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductCategory", b => - { b.HasOne("NetinaShop.Domain.Entities.Categories.Category", "Category") .WithMany("Products") .HasForeignKey("CategoryId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") - .WithMany("Categories") - .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); + b.Navigation("Brand"); b.Navigation("Category"); - - b.Navigation("Product"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => @@ -1567,13 +1534,13 @@ namespace NetinaShop.Repository.Migrations modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => { + b.Navigation("OrderDeliveries"); + b.Navigation("OrderProducts"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => { - b.Navigation("Categories"); - b.Navigation("Files"); b.Navigation("OrderProducts"); diff --git a/NetinaShop.Repository/NetinaShop.Repository.csproj b/NetinaShop.Repository/NetinaShop.Repository.csproj index ac86000..9d1dab7 100644 --- a/NetinaShop.Repository/NetinaShop.Repository.csproj +++ b/NetinaShop.Repository/NetinaShop.Repository.csproj @@ -60,6 +60,7 @@ + diff --git a/NetinaShop.Repository/Repositories/Base/ReadRepository.cs b/NetinaShop.Repository/Repositories/Base/ReadRepository.cs index b4cc690..d9e716d 100644 --- a/NetinaShop.Repository/Repositories/Base/ReadRepository.cs +++ b/NetinaShop.Repository/Repositories/Base/ReadRepository.cs @@ -7,7 +7,7 @@ { } - public void Dispose() + public new void Dispose() { DbContext?.Dispose(); } @@ -16,6 +16,8 @@ public virtual T GetById(params object[] ids) { var ent = Entities.Find(ids); + if (ent == null) + throw new AppException("Ent not found"); Detach(ent); return ent; } @@ -29,8 +31,7 @@ { AssertExtensions.NotNull(entity, nameof(entity)); var entry = DbContext.Entry(entity); - if (entry != null) - entry.State = EntityState.Detached; + entry.State = EntityState.Detached; } public virtual void Attach(T entity) diff --git a/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs b/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs index 44b275d..f06e62d 100644 --- a/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs +++ b/NetinaShop.Repository/Repositories/Entity/DiscountRepository.cs @@ -1,7 +1,4 @@ -using NetinaShop.Repository.Repositories.Base; -using System.Threading; - -namespace NetinaShop.Repository.Repositories.Entity; +namespace NetinaShop.Repository.Repositories.Entity; public class DiscountRepository : BaseRepository, IDiscountRepository { diff --git a/NetinaShop.sln b/NetinaShop.sln index 58e05c2..7a55285 100644 --- a/NetinaShop.sln +++ b/NetinaShop.sln @@ -5,15 +5,20 @@ VisualStudioVersion = 17.8.34316.72 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Api", "NetinaShop.Api\NetinaShop.Api.csproj", "{12DD0CD6-93AF-4990-8121-E12A05AA75AD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Common", "NetinaShop.Common\NetinaShop.Common.csproj", "{53171FE6-AE59-4696-9A8B-FF7CCBF921CB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Common", "NetinaShop.Common\NetinaShop.Common.csproj", "{53171FE6-AE59-4696-9A8B-FF7CCBF921CB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Domain", "NetinaShop.Domain\NetinaShop.Domain.csproj", "{A6890803-432B-4045-AF5A-DC5C0B9F8D0D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Domain", "NetinaShop.Domain\NetinaShop.Domain.csproj", "{A6890803-432B-4045-AF5A-DC5C0B9F8D0D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Infrastructure", "NetinaShop.Infrastructure\NetinaShop.Infrastructure.csproj", "{A3AB0DD7-5472-4A1C-9CF4-D0F97B926CF8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Infrastructure", "NetinaShop.Infrastructure\NetinaShop.Infrastructure.csproj", "{A3AB0DD7-5472-4A1C-9CF4-D0F97B926CF8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Core", "NetinaShop.Core\NetinaShop.Core.csproj", "{D422399C-A65D-479B-975C-40202E9C16C3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Core", "NetinaShop.Core\NetinaShop.Core.csproj", "{D422399C-A65D-479B-975C-40202E9C16C3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetinaShop.Repository", "NetinaShop.Repository\NetinaShop.Repository.csproj", "{4A25936E-275C-41EA-9ADC-4375E8AC5207}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetinaShop.Repository", "NetinaShop.Repository\NetinaShop.Repository.csproj", "{4A25936E-275C-41EA-9ADC-4375E8AC5207}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConfigFiles", "ConfigFiles", "{673BF026-7A2C-4695-9103-79099AACDF73}" + ProjectSection(SolutionItems) = preProject + .version = .version + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution