diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..de2db2d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/NetinaShop.Api/bin/Debug/net8.0/NetinaShop.Api.dll", + "args": [], + "cwd": "${workspaceFolder}/NetinaShop.Api", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..fe318fc --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/NetinaShop.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/NetinaShop.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/NetinaShop.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/NetinaShop.Api/Controller/OrderBagController.cs b/NetinaShop.Api/Controller/OrderBagController.cs index 27b354a..e150d2a 100644 --- a/NetinaShop.Api/Controller/OrderBagController.cs +++ b/NetinaShop.Api/Controller/OrderBagController.cs @@ -51,8 +51,7 @@ public class OrderBagController : ICarterModule => 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, + => 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) diff --git a/NetinaShop.Api/Controller/OrderController.cs b/NetinaShop.Api/Controller/OrderController.cs index 735a548..cde97b4 100644 --- a/NetinaShop.Api/Controller/OrderController.cs +++ b/NetinaShop.Api/Controller/OrderController.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Api.Controller; +using NetinaShop.Domain.Enums; + +namespace NetinaShop.Api.Controller; public class OrderController : ICarterModule { public void AddRoutes(IEndpointRouteBuilder app) @@ -21,11 +23,14 @@ public class OrderController : ICarterModule } - 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 GetAllAsync(IMediator mediator, [FromQuery]long? selectedDate, [FromQuery] OrderStatus? orderStatus, [FromQuery] OrderQueryDateFilter? dateFilter, [FromQuery] int page = 0, CancellationToken cancellationToken = default) + => TypedResults.Ok(await mediator.Send(new GetOrdersQuery(Page:page, SelectedDate: selectedDate, OrderStatus:orderStatus, DateFilter:dateFilter), cancellationToken)); - public async Task GetAsync(IMediator mediator,Guid id, CancellationToken cancellationToken = default) - => TypedResults.Ok(await mediator.Send(new GetOrderLDtoQuery(id), cancellationToken)); + public async Task GetAsync(IMediator mediator, Guid id, CancellationToken cancellationToken = default) + { + var order = await mediator.Send(new GetOrderLDtoQuery(id), cancellationToken); + return TypedResults.Ok(order); + } 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/PaymentController.cs b/NetinaShop.Api/Controller/PaymentController.cs new file mode 100644 index 0000000..f8c2d00 --- /dev/null +++ b/NetinaShop.Api/Controller/PaymentController.cs @@ -0,0 +1,57 @@ +using TypedResults = Microsoft.AspNetCore.Http.TypedResults; + +namespace NetinaShop.Api.Controller; + +public class PaymentController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("AccountingPayment") + .MapGroup($"api/accounting/pay"); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetPayments") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .HasApiVersion(1.0); + + //group.MapGet("{id}", GetAsync) + // .WithDisplayName("GetShipping") + // .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + // .HasApiVersion(1.0); + + group.MapGet("verify", VerifyPaymentAsync) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync([FromQuery] int page, IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetPaymentsQuery(page), cancellationToken)); + + // GET:Get An Entity By Id + 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 VerifyPaymentAsync([FromQuery] string Authority, [FromQuery] string Status, IPaymentService paymentService,ILogger logger, CancellationToken cancellationToken) + { + try + { + if (Status == "OK") + { + var result = await paymentService.VerifyPaymentAsync(authority: Authority, cancellationToken); + return TypedResults.Redirect(""); + } + else + { + return TypedResults.Redirect(""); + } + } + catch (Exception e) + { + logger.LogError(e.Message); + return TypedResults.Redirect(""); + } + } + +} \ No newline at end of file diff --git a/NetinaShop.Api/WebFramework/Configurations/LoggerConfig.cs b/NetinaShop.Api/WebFramework/Configurations/LoggerConfig.cs index b899f0e..b33d772 100644 --- a/NetinaShop.Api/WebFramework/Configurations/LoggerConfig.cs +++ b/NetinaShop.Api/WebFramework/Configurations/LoggerConfig.cs @@ -13,7 +13,7 @@ public static class LoggerConfig o.MinimumEventLevel = LogEventLevel.Error; o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7"; }) - .MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error) + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Information) .CreateLogger(); } } \ No newline at end of file diff --git a/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs b/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs index 135617c..01e1bad 100644 --- a/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs +++ b/NetinaShop.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs @@ -1,5 +1,7 @@ -using System.Security.Cryptography; +using System; +using System.Security.Cryptography; using NetinaShop.Repository.Migrations; +using Refit; namespace NetinaShop.Api.WebFramework.MiddleWares; @@ -73,7 +75,8 @@ public class ExceptionHandlerMiddleware { message = exception.Message; } - if(exception.AdditionalData==null) + + if (exception.AdditionalData == null) await WriteToResponseAsync(); else await WriteToResponseWithObjectAsync(exception.AdditionalData); @@ -90,7 +93,17 @@ public class ExceptionHandlerMiddleware SetUnAuthorizeResponse(exception); await WriteToResponseAsync(); } + catch (ApiException apiException) + { + _logger.LogError(apiException, apiException.Message); + httpStatusCode = HttpStatusCode.InternalServerError; + apiStatusCode = ApiResultStatusCode.RefitError; + + message = apiException.Message; + + await WriteToResponseAsync(); + } catch (Exception exception) { _logger.LogError(exception, exception.Message); diff --git a/NetinaShop.Core/Abstracts/IPaymentService.cs b/NetinaShop.Core/Abstracts/IPaymentService.cs new file mode 100644 index 0000000..10d067c --- /dev/null +++ b/NetinaShop.Core/Abstracts/IPaymentService.cs @@ -0,0 +1,7 @@ +namespace NetinaShop.Core.Abstracts; + +public interface IPaymentService : IScopedDependency +{ + Task GetPaymentLinkAsync(double amount, string factorNumber, Guid orderId, Guid userId, string phoneNumber, string fullName, CancellationToken cancellationToken = default); + Task VerifyPaymentAsync(string authority, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs index 2fcfc47..d9178da 100644 --- a/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs +++ b/NetinaShop.Core/EntityServices/OrderBagHandlers/SubmitOrderPaymentCommandHandler.cs @@ -14,26 +14,45 @@ public class SubmitOrderPaymentCommandHandler : IRequestHandler Handle(SubmitOrderPaymentCommand request, CancellationToken cancellationToken) { - var order = await _repositoryWrapper.SetRepository() - .TableNoTracking - .FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken); + await _mediator.Send(new CalculateOrderCommand(request.OrderId, true), cancellationToken); - if (order == null) + var orderSDto = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(o => o.Id == request.OrderId) + .Select(OrderMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + if (orderSDto == null) throw new AppException("Order not found", ApiResultStatusCode.NotFound); + var order = orderSDto.AdaptToOrder(); + var response = new SubmitOrderPaymentResponseDto(); if (request.PaymentMethod == OrderPaymentMethod.OnlinePayment) { - response.NeedToPayOnline = true; - response.PaymentUrl = await _paymentService.GetPaymentLinkAsync(order.Id, order.TotalPrice, $"پرداخت سفارش {order.Id}"); + if (request.HasPaid) + { + response.NeedToPayOnline = false; + order.SetSubmitOrder(request.PaymentMethod); + } + else + { + response.NeedToPayOnline = true; + response.PaymentUrl = await _paymentService.GetPaymentLinkAsync(orderSDto.TotalPrice, orderSDto.FactorCode, orderSDto.Id, orderSDto.UserId, orderSDto.UserPhoneNumber, orderSDto.UserFullName, cancellationToken); + } } - else if (request.PaymentMethod == OrderPaymentMethod.Cash) + else if (request.PaymentMethod == OrderPaymentMethod.PayOnDoor) { response.NeedToPayOnline = false; order.SetSubmitOrder(request.PaymentMethod); _repositoryWrapper.SetRepository().Update(order); await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + await _mediator.Send(new CreatePaymentCommand(order.FactorCode, order.TotalPrice, + $"پرداخت نقدی سفارش {order.FactorCode}", string.Empty, string.Empty, string.Empty, + PaymentType.PayOnDoor, PaymentStatus.Paid, order.Id + , order.UserId), cancellationToken); } else if (request.PaymentMethod == OrderPaymentMethod.CardTransfer) { @@ -41,6 +60,11 @@ public class SubmitOrderPaymentCommandHandler : IRequestHandler().Update(order); await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + await _mediator.Send(new CreatePaymentCommand(order.FactorCode, order.TotalPrice, + $"پرداخت نقدی سفارش {order.FactorCode}", string.Empty, string.Empty, string.Empty, + PaymentType.CardTransfer, PaymentStatus.Paid, order.Id + , order.UserId), cancellationToken); } return response; diff --git a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs index 27af618..09d1e03 100644 --- a/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs +++ b/NetinaShop.Domain/CommandQueries/Commands/OrderBagCommands.cs @@ -10,5 +10,5 @@ public sealed record RemoveFromOrderBagCommand(List RequestD 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; +public sealed record SubmitOrderPaymentCommand(Guid OrderId, OrderPaymentMethod PaymentMethod , bool HasPaid = false) : IRequest; diff --git a/NetinaShop.Domain/CommandQueries/Commands/PaymentCommands.cs b/NetinaShop.Domain/CommandQueries/Commands/PaymentCommands.cs new file mode 100644 index 0000000..9aba654 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Commands/PaymentCommands.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Commands; + +public sealed record CreatePaymentCommand(string FactorNumber, double Amount, string Description, string TransactionCode, string CardPan, string Authority, PaymentType Type, PaymentStatus Status, Guid OrderId, Guid UserId) : IRequest; +public sealed record UpdatePaymentCommand(Guid Id,string FactorNumber, double Amount, string Description, string TransactionCode, string CardPan, string Authority, PaymentType Type, PaymentStatus Status, Guid OrderId, Guid UserId) : IRequest; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs index 443d48e..ab14aa9 100644 --- a/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs +++ b/NetinaShop.Domain/CommandQueries/Queries/OrderQueries.cs @@ -3,4 +3,4 @@ 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 +public sealed record GetOrdersQuery(OrderQueryDateFilter? DateFilter, OrderStatus? OrderStatus,long? SelectedDate, int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/CommandQueries/Queries/PaymentQueries.cs b/NetinaShop.Domain/CommandQueries/Queries/PaymentQueries.cs new file mode 100644 index 0000000..d9020d5 --- /dev/null +++ b/NetinaShop.Domain/CommandQueries/Queries/PaymentQueries.cs @@ -0,0 +1,4 @@ +namespace NetinaShop.Domain.CommandQueries.Queries; + +public sealed record GetPaymentQuery(Guid Id = default , string? Authority = null) : IRequest; +public sealed record GetPaymentsQuery(int Page = 0) : IRequest>; \ No newline at end of file diff --git a/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs index b21a9e6..783c45b 100644 --- a/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs +++ b/NetinaShop.Domain/Dtos/LargDtos/OrderLDto.cs @@ -1,6 +1,7 @@ namespace NetinaShop.Domain.Dtos.LargDtos; public class OrderLDto : BaseDto { + public string FactorCode { get; set; } = string.Empty; public long TotalPrice { get; set; } public long DeliveryPrice { get; set; } public long TaxesPrice { get; set; } @@ -14,9 +15,25 @@ public class OrderLDto : BaseDto public DateTime OrderAt { get; set; } public int PreparingMinute { get; set; } public string DiscountCode { get; set; } = string.Empty; + public long TotalPriceWithoutDiscount => TotalPrice + DiscountPrice; - public List OrderProducts { get; internal set; } = new(); + public string UserFullName { get; set; } = string.Empty; + public string UserPhoneNumber { get; set; } = string.Empty; - public List OrderDeliveries { get; internal set; } = new(); + public List OrderProducts { get; set; } = new(); + + public List OrderDeliveries { get; set; } = new(); + + public List Payments { get; set; } = new(); + + public OrderDeliverySDto OrderDelivery + { + get + { + if (OrderDeliveries.Count > 0) + return OrderDeliveries.FirstOrDefault() ?? new OrderDeliverySDto(); + return new OrderDeliverySDto(); + } + } } diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs index ddc72cc..9d97b88 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderDeliverySDto.cs @@ -6,6 +6,7 @@ public class OrderDeliverySDto : BaseDto public string PostalCode { get; set; } = string.Empty; public string ReceiverPhoneNumber { get; set; } = string.Empty; public string ReceiverFullName { get; set; } = string.Empty; + public string ShippingMethod { 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 index d34fdff..a7b733f 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderProductSDto.cs @@ -2,13 +2,17 @@ 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 int Count { get; set; } + public double ProductFee { get; set; } + public double ProductFeeWithDiscount { get; set; } + public bool HasDiscount { get; set; } + public double ProductCost { get; set; } + public double PackingFee { get; set; } + public double PackingCost { get; set; } + public OrderStatus OrderProductStatus { get; set; } - public Guid ProductId { get; internal set; } - - public Guid OrderId { get; internal set; } + public Guid ProductId { get; set; } + public string ProductName { get; set; } = string.Empty; + public Guid OrderId { get; set; } } diff --git a/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs index d37cf1c..3d9465b 100644 --- a/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs +++ b/NetinaShop.Domain/Dtos/SmallDtos/OrderSDto.cs @@ -1,17 +1,22 @@ 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 double TotalPrice { get; set; } + public string FactorCode { get; set; } = string.Empty; + public double DeliveryPrice { get; set; } + public double TaxesPrice { get; set; } + public double ServicePrice { get; set; } + public double PackingPrice { get; set; } + public double TotalProductsPrice { get; set; } + public double DiscountPrice { get; set; } public bool IsPayed { get; set; } public OrderStatus OrderStatus { get; set; } + public DateTime PayedAt { 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 string UserFullName { get; set; } = string.Empty; + public string UserPhoneNumber { get; set; } = string.Empty; + public Guid UserId { get; internal set; } } diff --git a/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs b/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs new file mode 100644 index 0000000..d8b8522 --- /dev/null +++ b/NetinaShop.Domain/Dtos/SmallDtos/PaymentSDto.cs @@ -0,0 +1,20 @@ +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Domain.Dtos.SmallDtos; + +public class PaymentSDto : BaseDto +{ + public string FactorNumber { get; set; } = string.Empty; + public double Amount { get; set; } + public string Description { get; set; } = string.Empty; + public string TransactionCode { get; set; } = string.Empty; + public string CardPan { get; set; } = string.Empty; + public string Authority { get; set; } = string.Empty; + public PaymentType Type { get; set; } + public PaymentStatus Status { get; set; } + + public Guid OrderId { get; set; } + public Guid UserId { get; set; } + public string UserFullName { get; set; } = string.Empty; + public string UserPhoneNumber { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Accounting/Accounting.Aggregate.cs b/NetinaShop.Domain/Entities/Accounting/Accounting.Aggregate.cs new file mode 100644 index 0000000..c7dd130 --- /dev/null +++ b/NetinaShop.Domain/Entities/Accounting/Accounting.Aggregate.cs @@ -0,0 +1,16 @@ +namespace NetinaShop.Domain.Entities.Accounting; + +public partial class Payment +{ + public static Payment Create(string factorNumber, double amount, string description, string transactionCode, string cardPan, string authority, PaymentType type, PaymentStatus status, Guid orderId, Guid userId) + { + return new Payment(factorNumber, amount, description, transactionCode, cardPan, authority, type, status, orderId, userId); + } + + public void ChangeStatus(PaymentStatus status, string? cardPan = null) + { + this.Status = status; + if (status != PaymentStatus.Paid && cardPan != null) + CardPan = cardPan; + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Accounting/Payment.cs b/NetinaShop.Domain/Entities/Accounting/Payment.cs new file mode 100644 index 0000000..4eb733d --- /dev/null +++ b/NetinaShop.Domain/Entities/Accounting/Payment.cs @@ -0,0 +1,41 @@ +namespace NetinaShop.Domain.Entities.Accounting; + +[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 Payment : ApiEntity +{ + public Payment() + { + + } + public Payment(string factorNumber, double amount, string description, string transactionCode, string cardPan, string authority, PaymentType type, PaymentStatus status, Guid orderId, Guid userId) + { + FactorNumber = factorNumber; + Amount = amount; + Description = description; + TransactionCode = transactionCode; + CardPan = cardPan; + Authority = authority; + Type = type; + Status = status; + OrderId = orderId; + UserId = userId; + } + + public string FactorNumber { get; internal set; } = string.Empty; + public double Amount { get; internal set; } + public string Description { get; internal set; } = string.Empty; + public string TransactionCode { get; internal set; } = string.Empty; + public string CardPan { get; internal set; } = string.Empty; + public string Authority { get; internal set; } = string.Empty; + public PaymentType Type { get; internal set; } + public PaymentStatus Status { get; internal set; } + + public Guid OrderId { get; internal set; } + public Order? Order { get; internal set; } + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs index d6c156d..3579af2 100644 --- a/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs +++ b/NetinaShop.Domain/Entities/Orders/Order.Aggregate.cs @@ -4,7 +4,8 @@ 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); + var factorNumber = StringExtensions.GetId(10).ToUpper(); + return new Order(factorNumber, 0, 0, 0, 0, 0, 0, 0, false, OrderStatus.OrderBag, DateTime.MinValue, DateTime.Now, 0, string.Empty, userId, OrderPaymentMethod.OnlinePayment); } @@ -62,7 +63,7 @@ public partial class Order OrderAt = DateTime.Now; PaymentMethod = paymentMethod; break; - case OrderPaymentMethod.Cash: + case OrderPaymentMethod.PayOnDoor: OrderStatus = OrderStatus.Submitted; IsPayed = false; OrderAt = DateTime.Now; diff --git a/NetinaShop.Domain/Entities/Orders/Order.cs b/NetinaShop.Domain/Entities/Orders/Order.cs index a7e411f..b09973d 100644 --- a/NetinaShop.Domain/Entities/Orders/Order.cs +++ b/NetinaShop.Domain/Entities/Orders/Order.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Domain.Entities.Orders; [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)] @@ -12,6 +14,7 @@ public partial class Order : ApiEntity } public Order( + string factorCode, double totalPrice, double deliveryPrice, double taxesPrice, @@ -19,8 +22,16 @@ public partial class Order : ApiEntity double packingPrice, double totalProductsPrice, double discountPrice, - bool isPayed, OrderStatus orderStatus, DateTime doneAt, DateTime orderAt, int preparingMinute, string discountCode, Guid userId, OrderPaymentMethod paymentMethod) + bool isPayed, + OrderStatus orderStatus, + DateTime doneAt, + DateTime orderAt, + int preparingMinute, + string discountCode, + Guid userId, + OrderPaymentMethod paymentMethod) { + FactorCode = factorCode; TotalPrice = totalPrice; DeliveryPrice = deliveryPrice; TaxesPrice = taxesPrice; @@ -38,6 +49,7 @@ public partial class Order : ApiEntity PaymentMethod = paymentMethod; } + public string FactorCode { get; internal set; } = string.Empty; public double TotalProductsPrice { get; internal set; } public double PackingPrice { get; internal set; } public double ServicePrice { get; internal set; } @@ -60,4 +72,6 @@ public partial class Order : ApiEntity public List OrderProducts { get; internal set; } = new(); public List OrderDeliveries { get; internal set; } = new(); + + public List Payments { get; internal set; } = new(); } \ No newline at end of file diff --git a/NetinaShop.Domain/Entities/Orders/OrderProduct.cs b/NetinaShop.Domain/Entities/Orders/OrderProduct.cs index 896ffec..693e291 100644 --- a/NetinaShop.Domain/Entities/Orders/OrderProduct.cs +++ b/NetinaShop.Domain/Entities/Orders/OrderProduct.cs @@ -1,5 +1,8 @@ namespace NetinaShop.Domain.Entities.Orders; +[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 OrderProduct : ApiEntity { public OrderProduct() @@ -32,8 +35,8 @@ public partial class OrderProduct : ApiEntity } public int Count { get; internal set; } public double ProductFee { get; internal set; } - public double ProductFeeWithDiscount { get; set; } - public bool HasDiscount { get; set; } + public double ProductFeeWithDiscount { get; internal set; } + public bool HasDiscount { get; internal set; } public double ProductCost { get; internal set; } public double PackingFee { get; internal set; } public double PackingCost { get; internal set; } diff --git a/NetinaShop.Domain/Enums/OrderPaymentMethod.cs b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs index 462ea8e..9e8f652 100644 --- a/NetinaShop.Domain/Enums/OrderPaymentMethod.cs +++ b/NetinaShop.Domain/Enums/OrderPaymentMethod.cs @@ -3,7 +3,7 @@ public enum OrderPaymentMethod { [Display(Name = "پرداخت درب محل")] - Cash, + PayOnDoor, [Display(Name = "پرداخت انلاین")] OnlinePayment, [Display(Name = "پرداخت کارت به کارت")] diff --git a/NetinaShop.Domain/Enums/OrderQueryDateFilter.cs b/NetinaShop.Domain/Enums/OrderQueryDateFilter.cs new file mode 100644 index 0000000..ba34376 --- /dev/null +++ b/NetinaShop.Domain/Enums/OrderQueryDateFilter.cs @@ -0,0 +1,13 @@ +namespace NetinaShop.Domain.Enums; + +public enum OrderQueryDateFilter +{ + [Display(Name = "امروز")] + Today = 0, + [Display(Name = "هفته اخیر")] + ThisWeek = 1, + [Display(Name = "یک ماه اخیر")] + ThisMonth = 2, + [Display(Name = "تاریخ خاص")] + CustomDate = 3, +} \ No newline at end of file diff --git a/NetinaShop.Domain/Enums/PaymentStatus.cs b/NetinaShop.Domain/Enums/PaymentStatus.cs new file mode 100644 index 0000000..c9258c2 --- /dev/null +++ b/NetinaShop.Domain/Enums/PaymentStatus.cs @@ -0,0 +1,13 @@ +namespace NetinaShop.Domain.Enums; + +public enum PaymentStatus +{ + [Display(Name = "در انتظار پرداخت درگاه")] + InPaymentGateway = 0, + [Display(Name = "در انتظار پرداخت")] + NotPaidYet = 1, + [Display(Name = "پرداخت شده")] + Paid = 200, + [Display(Name = "کنسل شده")] + Cancel = 500 +} \ No newline at end of file diff --git a/NetinaShop.Domain/Enums/PaymentType.cs b/NetinaShop.Domain/Enums/PaymentType.cs new file mode 100644 index 0000000..109fc2b --- /dev/null +++ b/NetinaShop.Domain/Enums/PaymentType.cs @@ -0,0 +1,13 @@ +namespace NetinaShop.Domain.Enums; + +public enum PaymentType +{ + [Display(Name = "نقدی")] + Cash, + [Display(Name = "کارت به کارت")] + CardTransfer, + [Display(Name = "آنلاین")] + Online, + [Display(Name = "در محل")] + PayOnDoor +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/OrderMapper.g.cs b/NetinaShop.Domain/Mappers/OrderMapper.g.cs index 0a29a0a..4f1b862 100644 --- a/NetinaShop.Domain/Mappers/OrderMapper.g.cs +++ b/NetinaShop.Domain/Mappers/OrderMapper.g.cs @@ -2,9 +2,14 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using Mapster.Models; using NetinaShop.Domain.Dtos.LargDtos; using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Accounting; using NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Entities.Products; +using NetinaShop.Domain.Entities.Users; +using NetinaShop.Domain.Entities.Warehouses; namespace NetinaShop.Domain.Mappers { @@ -14,6 +19,7 @@ namespace NetinaShop.Domain.Mappers { return p1 == null ? null : new Order() { + FactorCode = p1.FactorCode, TotalProductsPrice = (double)p1.TotalProductsPrice, PackingPrice = (double)p1.PackingPrice, ServicePrice = (double)p1.ServicePrice, @@ -27,267 +33,182 @@ namespace NetinaShop.Domain.Mappers OrderAt = p1.OrderAt, PreparingMinute = p1.PreparingMinute, DiscountCode = p1.DiscountCode, + User = new ApplicationUser() {PhoneNumber = p1.UserPhoneNumber}, OrderProducts = funcMain1(p1.OrderProducts), OrderDeliveries = funcMain2(p1.OrderDeliveries), + Payments = funcMain3(p1.Payments), Id = p1.Id, CreatedAt = p1.CreatedAt }; } - public static Order AdaptTo(this OrderLDto p4, Order p5) + public static Order AdaptTo(this OrderLDto p5, Order p6) { - if (p4 == null) + if (p5 == null) { return null; } - Order result = p5 ?? new Order(); + Order result = p6 ?? 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; - result.CreatedAt = p4.CreatedAt; + result.FactorCode = p5.FactorCode; + result.TotalProductsPrice = (double)p5.TotalProductsPrice; + result.PackingPrice = (double)p5.PackingPrice; + result.ServicePrice = (double)p5.ServicePrice; + result.DeliveryPrice = (double)p5.DeliveryPrice; + result.DiscountPrice = (double)p5.DiscountPrice; + result.TaxesPrice = (double)p5.TaxesPrice; + result.TotalPrice = (double)p5.TotalPrice; + result.IsPayed = p5.IsPayed; + result.OrderStatus = p5.OrderStatus; + result.DoneAt = p5.DoneAt; + result.OrderAt = p5.OrderAt; + result.PreparingMinute = p5.PreparingMinute; + result.DiscountCode = p5.DiscountCode; + result.User = funcMain4(new Never(), result.User, p5); + result.OrderProducts = funcMain5(p5.OrderProducts, result.OrderProducts); + result.OrderDeliveries = funcMain6(p5.OrderDeliveries, result.OrderDeliveries); + result.Payments = funcMain7(p5.Payments, result.Payments); + result.Id = p5.Id; + result.CreatedAt = p5.CreatedAt; return result; } - public static Expression> ProjectToOrder => p10 => new Order() + public static Expression> ProjectToOrder => p15 => 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() + FactorCode = p15.FactorCode, + TotalProductsPrice = (double)p15.TotalProductsPrice, + PackingPrice = (double)p15.PackingPrice, + ServicePrice = (double)p15.ServicePrice, + DeliveryPrice = (double)p15.DeliveryPrice, + DiscountPrice = (double)p15.DiscountPrice, + TaxesPrice = (double)p15.TaxesPrice, + TotalPrice = (double)p15.TotalPrice, + IsPayed = p15.IsPayed, + OrderStatus = p15.OrderStatus, + DoneAt = p15.DoneAt, + OrderAt = p15.OrderAt, + PreparingMinute = p15.PreparingMinute, + DiscountCode = p15.DiscountCode, + User = new ApplicationUser() {PhoneNumber = p15.UserPhoneNumber}, + OrderProducts = p15.OrderProducts.Select(p16 => 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, - CreatedAt = p11.CreatedAt + Count = p16.Count, + ProductFee = p16.ProductFee, + ProductFeeWithDiscount = p16.ProductFeeWithDiscount, + HasDiscount = p16.HasDiscount, + ProductCost = p16.ProductCost, + PackingFee = p16.PackingFee, + PackingCost = p16.PackingCost, + OrderProductStatus = p16.OrderProductStatus, + ProductId = p16.ProductId, + Product = new Product() + { + Cost = p16.ProductCost, + Id = p16.ProductId + }, + OrderId = p16.OrderId, + Order = new Order() {Id = p16.OrderId}, + Id = p16.Id, + CreatedAt = p16.CreatedAt }).ToList(), - OrderDeliveries = p10.OrderDeliveries.Select(p12 => new OrderDelivery() + OrderDeliveries = p15.OrderDeliveries.Select(p17 => new OrderDelivery() { - Address = p12.Address, - PostalCode = p12.PostalCode, - ReceiverPhoneNumber = p12.ReceiverPhoneNumber, - ReceiverFullName = p12.ReceiverFullName, - ShippingId = p12.ShippingId, - OrderId = p12.OrderId, - Id = p12.Id, - CreatedAt = p12.CreatedAt + Address = p17.Address, + PostalCode = p17.PostalCode, + ReceiverPhoneNumber = p17.ReceiverPhoneNumber, + ReceiverFullName = p17.ReceiverFullName, + ShippingId = p17.ShippingId, + Shipping = new Shipping() {Id = p17.ShippingId}, + OrderId = p17.OrderId, + Order = new Order() {Id = p17.OrderId}, + Id = p17.Id, + CreatedAt = p17.CreatedAt }).ToList(), - Id = p10.Id, - CreatedAt = p10.CreatedAt + Payments = p15.Payments.Select(p18 => new Payment() + { + FactorNumber = p18.FactorNumber, + Amount = p18.Amount, + Description = p18.Description, + TransactionCode = p18.TransactionCode, + CardPan = p18.CardPan, + Authority = p18.Authority, + Type = p18.Type, + Status = p18.Status, + OrderId = p18.OrderId, + Order = new Order() {Id = p18.OrderId}, + UserId = p18.UserId, + User = new ApplicationUser() + { + Id = p18.UserId, + PhoneNumber = p18.UserPhoneNumber + }, + Id = p18.Id, + CreatedAt = p18.CreatedAt + }).ToList(), + Id = p15.Id, + CreatedAt = p15.CreatedAt }; - public static OrderLDto AdaptToLDto(this Order p13) + public static OrderLDto AdaptToLDto(this Order p19) { - return p13 == null ? null : new OrderLDto() + return p19 == 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, - CreatedAt = p13.CreatedAt + FactorCode = p19.FactorCode, + TotalPrice = (long)p19.TotalPrice, + DeliveryPrice = (long)p19.DeliveryPrice, + TaxesPrice = (long)p19.TaxesPrice, + ServicePrice = (long)p19.ServicePrice, + PackingPrice = (long)p19.PackingPrice, + TotalProductsPrice = (long)p19.TotalProductsPrice, + DiscountPrice = (long)p19.DiscountPrice, + IsPayed = p19.IsPayed, + OrderStatus = p19.OrderStatus, + DoneAt = p19.DoneAt, + OrderAt = p19.OrderAt, + PreparingMinute = p19.PreparingMinute, + DiscountCode = p19.DiscountCode, + UserFullName = p19.User != null ? p19.User.FirstName + " " + p19.User.LastName : string.Empty, + UserPhoneNumber = p19.User != null ? p19.User.PhoneNumber : string.Empty, + OrderProducts = funcMain8(p19.OrderProducts), + OrderDeliveries = funcMain9(p19.OrderDeliveries), + Payments = funcMain10(p19.Payments), + Id = p19.Id, + CreatedAt = p19.CreatedAt }; } - public static OrderLDto AdaptTo(this Order p16, OrderLDto p17) + public static OrderLDto AdaptTo(this Order p23, OrderLDto p24) { - if (p16 == null) + if (p23 == null) { return null; } - OrderLDto result = p17 ?? new OrderLDto(); + OrderLDto result = p24 ?? 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; - result.CreatedAt = p16.CreatedAt; + result.FactorCode = p23.FactorCode; + result.TotalPrice = (long)p23.TotalPrice; + result.DeliveryPrice = (long)p23.DeliveryPrice; + result.TaxesPrice = (long)p23.TaxesPrice; + result.ServicePrice = (long)p23.ServicePrice; + result.PackingPrice = (long)p23.PackingPrice; + result.TotalProductsPrice = (long)p23.TotalProductsPrice; + result.DiscountPrice = (long)p23.DiscountPrice; + result.IsPayed = p23.IsPayed; + result.OrderStatus = p23.OrderStatus; + result.DoneAt = p23.DoneAt; + result.OrderAt = p23.OrderAt; + result.PreparingMinute = p23.PreparingMinute; + result.DiscountCode = p23.DiscountCode; + result.UserFullName = p23.User != null ? p23.User.FirstName + " " + p23.User.LastName : string.Empty; + result.UserPhoneNumber = p23.User != null ? p23.User.PhoneNumber : string.Empty; + result.OrderProducts = funcMain11(p23.OrderProducts, result.OrderProducts); + result.OrderDeliveries = funcMain12(p23.OrderDeliveries, result.OrderDeliveries); + result.Payments = funcMain13(p23.Payments, result.Payments); + result.Id = p23.Id; + result.CreatedAt = p23.CreatedAt; 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, - CreatedAt = p23.CreatedAt - }).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, - CreatedAt = p24.CreatedAt - }).ToList(), - Id = p22.Id, - CreatedAt = p22.CreatedAt - }; - 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, - CreatedAt = p25.CreatedAt - }; - } - 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; - result.CreatedAt = p26.CreatedAt; - 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, - CreatedAt = p28.CreatedAt - }; - } - 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; - result.CreatedAt = p29.CreatedAt; - return result; - - } - public static Expression> ProjectToSDto => p31 => new OrderSDto() + public static Expression> ProjectToLDto => p31 => new OrderLDto() { + FactorCode = p31.FactorCode, TotalPrice = (long)p31.TotalPrice, DeliveryPrice = (long)p31.DeliveryPrice, TaxesPrice = (long)p31.TaxesPrice, @@ -301,9 +222,195 @@ namespace NetinaShop.Domain.Mappers OrderAt = p31.OrderAt, PreparingMinute = p31.PreparingMinute, DiscountCode = p31.DiscountCode, + UserFullName = p31.User != null ? p31.User.FirstName + " " + p31.User.LastName : string.Empty, + UserPhoneNumber = p31.User != null ? p31.User.PhoneNumber : string.Empty, + OrderProducts = p31.OrderProducts.Select(p32 => new OrderProductSDto() + { + Count = p32.Count, + ProductFee = p32.ProductFee, + ProductFeeWithDiscount = p32.ProductFeeWithDiscount, + HasDiscount = p32.HasDiscount, + ProductCost = p32.ProductCost, + PackingFee = p32.PackingFee, + PackingCost = p32.PackingCost, + OrderProductStatus = p32.OrderProductStatus, + ProductId = p32.ProductId, + ProductName = p32.Product != null ? p32.Product.PersianName : string.Empty, + OrderId = p32.OrderId, + Id = p32.Id, + CreatedAt = p32.CreatedAt + }).ToList(), + OrderDeliveries = p31.OrderDeliveries.Select(p33 => new OrderDeliverySDto() + { + Address = p33.Address, + PostalCode = p33.PostalCode, + ReceiverPhoneNumber = p33.ReceiverPhoneNumber, + ReceiverFullName = p33.ReceiverFullName, + ShippingMethod = p33.Shipping != null ? p33.Shipping.Name : string.Empty, + OrderId = p33.OrderId, + ShippingId = p33.ShippingId, + Id = p33.Id, + CreatedAt = p33.CreatedAt + }).ToList(), + Payments = p31.Payments.Select(p34 => new PaymentSDto() + { + FactorNumber = p34.FactorNumber, + Amount = p34.Amount, + Description = p34.Description, + TransactionCode = p34.TransactionCode, + CardPan = p34.CardPan, + Authority = p34.Authority, + Type = p34.Type, + Status = p34.Status, + OrderId = p34.OrderId, + UserId = p34.UserId, + UserFullName = p34.User != null ? p34.User.FirstName + " " + p34.User.LastName : string.Empty, + UserPhoneNumber = p34.User != null ? p34.User.PhoneNumber : string.Empty, + Id = p34.Id, + CreatedAt = p34.CreatedAt + }).ToList(), Id = p31.Id, CreatedAt = p31.CreatedAt }; + public static Order AdaptToOrder(this OrderSDto p35) + { + return p35 == null ? null : new Order() + { + FactorCode = p35.FactorCode, + TotalProductsPrice = p35.TotalProductsPrice, + PackingPrice = p35.PackingPrice, + ServicePrice = p35.ServicePrice, + DeliveryPrice = p35.DeliveryPrice, + DiscountPrice = p35.DiscountPrice, + TaxesPrice = p35.TaxesPrice, + TotalPrice = p35.TotalPrice, + IsPayed = p35.IsPayed, + PayedAt = p35.PayedAt, + OrderStatus = p35.OrderStatus, + DoneAt = p35.DoneAt, + OrderAt = p35.OrderAt, + PreparingMinute = p35.PreparingMinute, + DiscountCode = p35.DiscountCode, + UserId = p35.UserId, + User = new ApplicationUser() + { + Id = p35.UserId, + PhoneNumber = p35.UserPhoneNumber + }, + Id = p35.Id, + CreatedAt = p35.CreatedAt + }; + } + public static Order AdaptTo(this OrderSDto p36, Order p37) + { + if (p36 == null) + { + return null; + } + Order result = p37 ?? new Order(); + + result.FactorCode = p36.FactorCode; + result.TotalProductsPrice = p36.TotalProductsPrice; + result.PackingPrice = p36.PackingPrice; + result.ServicePrice = p36.ServicePrice; + result.DeliveryPrice = p36.DeliveryPrice; + result.DiscountPrice = p36.DiscountPrice; + result.TaxesPrice = p36.TaxesPrice; + result.TotalPrice = p36.TotalPrice; + result.IsPayed = p36.IsPayed; + result.PayedAt = p36.PayedAt; + result.OrderStatus = p36.OrderStatus; + result.DoneAt = p36.DoneAt; + result.OrderAt = p36.OrderAt; + result.PreparingMinute = p36.PreparingMinute; + result.DiscountCode = p36.DiscountCode; + result.UserId = p36.UserId; + result.User = funcMain14(new Never(), result.User, p36); + result.Id = p36.Id; + result.CreatedAt = p36.CreatedAt; + return result; + + } + public static OrderSDto AdaptToSDto(this Order p40) + { + return p40 == null ? null : new OrderSDto() + { + TotalPrice = p40.TotalPrice, + FactorCode = p40.FactorCode, + DeliveryPrice = p40.DeliveryPrice, + TaxesPrice = p40.TaxesPrice, + ServicePrice = p40.ServicePrice, + PackingPrice = p40.PackingPrice, + TotalProductsPrice = p40.TotalProductsPrice, + DiscountPrice = p40.DiscountPrice, + IsPayed = p40.IsPayed, + OrderStatus = p40.OrderStatus, + PayedAt = p40.PayedAt, + DoneAt = p40.DoneAt, + OrderAt = p40.OrderAt, + PreparingMinute = p40.PreparingMinute, + DiscountCode = p40.DiscountCode, + UserFullName = p40.User != null ? p40.User.FirstName + " " + p40.User.LastName : string.Empty, + UserPhoneNumber = p40.User != null ? p40.User.PhoneNumber : string.Empty, + UserId = p40.UserId, + Id = p40.Id, + CreatedAt = p40.CreatedAt + }; + } + public static OrderSDto AdaptTo(this Order p41, OrderSDto p42) + { + if (p41 == null) + { + return null; + } + OrderSDto result = p42 ?? new OrderSDto(); + + result.TotalPrice = p41.TotalPrice; + result.FactorCode = p41.FactorCode; + result.DeliveryPrice = p41.DeliveryPrice; + result.TaxesPrice = p41.TaxesPrice; + result.ServicePrice = p41.ServicePrice; + result.PackingPrice = p41.PackingPrice; + result.TotalProductsPrice = p41.TotalProductsPrice; + result.DiscountPrice = p41.DiscountPrice; + result.IsPayed = p41.IsPayed; + result.OrderStatus = p41.OrderStatus; + result.PayedAt = p41.PayedAt; + result.DoneAt = p41.DoneAt; + result.OrderAt = p41.OrderAt; + result.PreparingMinute = p41.PreparingMinute; + result.DiscountCode = p41.DiscountCode; + result.UserFullName = p41.User != null ? p41.User.FirstName + " " + p41.User.LastName : string.Empty; + result.UserPhoneNumber = p41.User != null ? p41.User.PhoneNumber : string.Empty; + result.UserId = p41.UserId; + result.Id = p41.Id; + result.CreatedAt = p41.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p43 => new OrderSDto() + { + TotalPrice = p43.TotalPrice, + FactorCode = p43.FactorCode, + DeliveryPrice = p43.DeliveryPrice, + TaxesPrice = p43.TaxesPrice, + ServicePrice = p43.ServicePrice, + PackingPrice = p43.PackingPrice, + TotalProductsPrice = p43.TotalProductsPrice, + DiscountPrice = p43.DiscountPrice, + IsPayed = p43.IsPayed, + OrderStatus = p43.OrderStatus, + PayedAt = p43.PayedAt, + DoneAt = p43.DoneAt, + OrderAt = p43.OrderAt, + PreparingMinute = p43.PreparingMinute, + DiscountCode = p43.DiscountCode, + UserFullName = p43.User != null ? p43.User.FirstName + " " + p43.User.LastName : string.Empty, + UserPhoneNumber = p43.User != null ? p43.User.PhoneNumber : string.Empty, + UserId = p43.UserId, + Id = p43.Id, + CreatedAt = p43.CreatedAt + }; private static List funcMain1(List p2) { @@ -322,11 +429,21 @@ namespace NetinaShop.Domain.Mappers result.Add(item == null ? null : new OrderProduct() { Count = item.Count, - ProductFee = (double)item.ProductFee, - ProductCost = (double)item.ProductCost, + ProductFee = item.ProductFee, + ProductFeeWithDiscount = item.ProductFeeWithDiscount, + HasDiscount = item.HasDiscount, + ProductCost = item.ProductCost, + PackingFee = item.PackingFee, + PackingCost = item.PackingCost, OrderProductStatus = item.OrderProductStatus, ProductId = item.ProductId, + Product = new Product() + { + Cost = item.ProductCost, + Id = item.ProductId + }, OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -357,7 +474,9 @@ namespace NetinaShop.Domain.Mappers ReceiverPhoneNumber = item.ReceiverPhoneNumber, ReceiverFullName = item.ReceiverFullName, ShippingId = item.ShippingId, + Shipping = new Shipping() {Id = item.ShippingId}, OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -367,28 +486,88 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain3(List p6, List p7) + private static List funcMain3(List p4) { - if (p6 == null) + if (p4 == null) { return null; } - List result = new List(p6.Count); + List result = new List(p4.Count); int i = 0; - int len = p6.Count; + int len = p4.Count; while (i < len) { - OrderProductSDto item = p6[i]; + PaymentSDto item = p4[i]; + result.Add(item == null ? null : new Payment() + { + FactorNumber = item.FactorNumber, + Amount = item.Amount, + Description = item.Description, + TransactionCode = item.TransactionCode, + CardPan = item.CardPan, + Authority = item.Authority, + Type = item.Type, + Status = item.Status, + OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, + UserId = item.UserId, + User = new ApplicationUser() + { + Id = item.UserId, + PhoneNumber = item.UserPhoneNumber + }, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static ApplicationUser funcMain4(Never p7, ApplicationUser p8, OrderLDto p5) + { + ApplicationUser result = p8 ?? new ApplicationUser(); + + result.PhoneNumber = p5.UserPhoneNumber; + return result; + + } + + private static List funcMain5(List p9, List p10) + { + if (p9 == null) + { + return null; + } + List result = new List(p9.Count); + + int i = 0; + int len = p9.Count; + + while (i < len) + { + OrderProductSDto item = p9[i]; result.Add(item == null ? null : new OrderProduct() { Count = item.Count, - ProductFee = (double)item.ProductFee, - ProductCost = (double)item.ProductCost, + ProductFee = item.ProductFee, + ProductFeeWithDiscount = item.ProductFeeWithDiscount, + HasDiscount = item.HasDiscount, + ProductCost = item.ProductCost, + PackingFee = item.PackingFee, + PackingCost = item.PackingCost, OrderProductStatus = item.OrderProductStatus, ProductId = item.ProductId, + Product = new Product() + { + Cost = item.ProductCost, + Id = item.ProductId + }, OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -398,20 +577,20 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain4(List p8, List p9) + private static List funcMain6(List p11, List p12) { - if (p8 == null) + if (p11 == null) { return null; } - List result = new List(p8.Count); + List result = new List(p11.Count); int i = 0; - int len = p8.Count; + int len = p11.Count; while (i < len) { - OrderDeliverySDto item = p8[i]; + OrderDeliverySDto item = p11[i]; result.Add(item == null ? null : new OrderDelivery() { Address = item.Address, @@ -419,7 +598,9 @@ namespace NetinaShop.Domain.Mappers ReceiverPhoneNumber = item.ReceiverPhoneNumber, ReceiverFullName = item.ReceiverFullName, ShippingId = item.ShippingId, + Shipping = new Shipping() {Id = item.ShippingId}, OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -429,28 +610,38 @@ namespace NetinaShop.Domain.Mappers } - private static List funcMain5(List p14) + private static List funcMain7(List p13, List p14) { - if (p14 == null) + if (p13 == null) { return null; } - List result = new List(p14.Count); + List result = new List(p13.Count); int i = 0; - int len = p14.Count; + int len = p13.Count; while (i < len) { - OrderProduct item = p14[i]; - result.Add(item == null ? null : new OrderProductSDto() + PaymentSDto item = p13[i]; + result.Add(item == null ? null : new Payment() { - Count = item.Count, - ProductFee = (float)item.ProductFee, - ProductCost = (float)item.ProductCost, - OrderProductStatus = item.OrderProductStatus, - ProductId = item.ProductId, + FactorNumber = item.FactorNumber, + Amount = item.Amount, + Description = item.Description, + TransactionCode = item.TransactionCode, + CardPan = item.CardPan, + Authority = item.Authority, + Type = item.Type, + Status = item.Status, OrderId = item.OrderId, + Order = new Order() {Id = item.OrderId}, + UserId = item.UserId, + User = new ApplicationUser() + { + Id = item.UserId, + PhoneNumber = item.UserPhoneNumber + }, Id = item.Id, CreatedAt = item.CreatedAt }); @@ -460,88 +651,63 @@ namespace NetinaShop.Domain.Mappers } - 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, - CreatedAt = item.CreatedAt - }); - 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, - CreatedAt = item.CreatedAt - }); - i++; - } - return result; - - } - - private static List funcMain8(List p20, List p21) + private static List funcMain8(List p20) { if (p20 == null) { return null; } - List result = new List(p20.Count); + List result = new List(p20.Count); int i = 0; int len = p20.Count; while (i < len) { - OrderDelivery item = p20[i]; + OrderProduct item = p20[i]; + result.Add(item == null ? null : new OrderProductSDto() + { + Count = item.Count, + ProductFee = item.ProductFee, + ProductFeeWithDiscount = item.ProductFeeWithDiscount, + HasDiscount = item.HasDiscount, + ProductCost = item.ProductCost, + PackingFee = item.PackingFee, + PackingCost = item.PackingCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + ProductName = item.Product != null ? item.Product.PersianName : string.Empty, + OrderId = item.OrderId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain9(List p21) + { + if (p21 == null) + { + return null; + } + List result = new List(p21.Count); + + int i = 0; + int len = p21.Count; + + while (i < len) + { + OrderDelivery item = p21[i]; result.Add(item == null ? null : new OrderDeliverySDto() { Address = item.Address, PostalCode = item.PostalCode, ReceiverPhoneNumber = item.ReceiverPhoneNumber, ReceiverFullName = item.ReceiverFullName, + ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty, OrderId = item.OrderId, ShippingId = item.ShippingId, Id = item.Id, @@ -552,5 +718,157 @@ namespace NetinaShop.Domain.Mappers return result; } + + private static List funcMain10(List p22) + { + if (p22 == null) + { + return null; + } + List result = new List(p22.Count); + + int i = 0; + int len = p22.Count; + + while (i < len) + { + Payment item = p22[i]; + result.Add(item == null ? null : new PaymentSDto() + { + FactorNumber = item.FactorNumber, + Amount = item.Amount, + Description = item.Description, + TransactionCode = item.TransactionCode, + CardPan = item.CardPan, + Authority = item.Authority, + Type = item.Type, + Status = item.Status, + OrderId = item.OrderId, + UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, + UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain11(List p25, List p26) + { + if (p25 == null) + { + return null; + } + List result = new List(p25.Count); + + int i = 0; + int len = p25.Count; + + while (i < len) + { + OrderProduct item = p25[i]; + result.Add(item == null ? null : new OrderProductSDto() + { + Count = item.Count, + ProductFee = item.ProductFee, + ProductFeeWithDiscount = item.ProductFeeWithDiscount, + HasDiscount = item.HasDiscount, + ProductCost = item.ProductCost, + PackingFee = item.PackingFee, + PackingCost = item.PackingCost, + OrderProductStatus = item.OrderProductStatus, + ProductId = item.ProductId, + ProductName = item.Product != null ? item.Product.PersianName : string.Empty, + OrderId = item.OrderId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain12(List p27, List p28) + { + if (p27 == null) + { + return null; + } + List result = new List(p27.Count); + + int i = 0; + int len = p27.Count; + + while (i < len) + { + OrderDelivery item = p27[i]; + result.Add(item == null ? null : new OrderDeliverySDto() + { + Address = item.Address, + PostalCode = item.PostalCode, + ReceiverPhoneNumber = item.ReceiverPhoneNumber, + ReceiverFullName = item.ReceiverFullName, + ShippingMethod = item.Shipping != null ? item.Shipping.Name : string.Empty, + OrderId = item.OrderId, + ShippingId = item.ShippingId, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static List funcMain13(List p29, List p30) + { + if (p29 == null) + { + return null; + } + List result = new List(p29.Count); + + int i = 0; + int len = p29.Count; + + while (i < len) + { + Payment item = p29[i]; + result.Add(item == null ? null : new PaymentSDto() + { + FactorNumber = item.FactorNumber, + Amount = item.Amount, + Description = item.Description, + TransactionCode = item.TransactionCode, + CardPan = item.CardPan, + Authority = item.Authority, + Type = item.Type, + Status = item.Status, + OrderId = item.OrderId, + UserId = item.UserId, + UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty, + UserPhoneNumber = item.User != null ? item.User.PhoneNumber : string.Empty, + Id = item.Id, + CreatedAt = item.CreatedAt + }); + i++; + } + return result; + + } + + private static ApplicationUser funcMain14(Never p38, ApplicationUser p39, OrderSDto p36) + { + ApplicationUser result = p39 ?? new ApplicationUser(); + + result.Id = p36.UserId; + result.PhoneNumber = p36.UserPhoneNumber; + return result; + + } } } \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/OrderProductMapper.g.cs b/NetinaShop.Domain/Mappers/OrderProductMapper.g.cs new file mode 100644 index 0000000..a8057a7 --- /dev/null +++ b/NetinaShop.Domain/Mappers/OrderProductMapper.g.cs @@ -0,0 +1,140 @@ +using System; +using System.Linq.Expressions; +using Mapster.Models; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Entities.Products; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class OrderProductMapper + { + public static OrderProduct AdaptToOrderProduct(this OrderProductSDto p1) + { + return p1 == null ? null : new OrderProduct() + { + Count = p1.Count, + ProductFee = p1.ProductFee, + ProductFeeWithDiscount = p1.ProductFeeWithDiscount, + HasDiscount = p1.HasDiscount, + ProductCost = p1.ProductCost, + PackingFee = p1.PackingFee, + PackingCost = p1.PackingCost, + OrderProductStatus = p1.OrderProductStatus, + ProductId = p1.ProductId, + Product = new Product() + { + Cost = p1.ProductCost, + Id = p1.ProductId + }, + OrderId = p1.OrderId, + Order = new Order() {Id = p1.OrderId}, + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static OrderProduct AdaptTo(this OrderProductSDto p2, OrderProduct p3) + { + if (p2 == null) + { + return null; + } + OrderProduct result = p3 ?? new OrderProduct(); + + result.Count = p2.Count; + result.ProductFee = p2.ProductFee; + result.ProductFeeWithDiscount = p2.ProductFeeWithDiscount; + result.HasDiscount = p2.HasDiscount; + result.ProductCost = p2.ProductCost; + result.PackingFee = p2.PackingFee; + result.PackingCost = p2.PackingCost; + result.OrderProductStatus = p2.OrderProductStatus; + result.ProductId = p2.ProductId; + result.Product = funcMain1(new Never(), result.Product, p2); + result.OrderId = p2.OrderId; + result.Order = funcMain2(new Never(), result.Order, p2); + result.Id = p2.Id; + result.CreatedAt = p2.CreatedAt; + return result; + + } + public static OrderProductSDto AdaptToSDto(this OrderProduct p8) + { + return p8 == null ? null : new OrderProductSDto() + { + Count = p8.Count, + ProductFee = p8.ProductFee, + ProductFeeWithDiscount = p8.ProductFeeWithDiscount, + HasDiscount = p8.HasDiscount, + ProductCost = p8.ProductCost, + PackingFee = p8.PackingFee, + PackingCost = p8.PackingCost, + OrderProductStatus = p8.OrderProductStatus, + ProductId = p8.ProductId, + ProductName = p8.Product != null ? p8.Product.PersianName : string.Empty, + OrderId = p8.OrderId, + Id = p8.Id, + CreatedAt = p8.CreatedAt + }; + } + public static OrderProductSDto AdaptTo(this OrderProduct p9, OrderProductSDto p10) + { + if (p9 == null) + { + return null; + } + OrderProductSDto result = p10 ?? new OrderProductSDto(); + + result.Count = p9.Count; + result.ProductFee = p9.ProductFee; + result.ProductFeeWithDiscount = p9.ProductFeeWithDiscount; + result.HasDiscount = p9.HasDiscount; + result.ProductCost = p9.ProductCost; + result.PackingFee = p9.PackingFee; + result.PackingCost = p9.PackingCost; + result.OrderProductStatus = p9.OrderProductStatus; + result.ProductId = p9.ProductId; + result.ProductName = p9.Product != null ? p9.Product.PersianName : string.Empty; + result.OrderId = p9.OrderId; + result.Id = p9.Id; + result.CreatedAt = p9.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p11 => new OrderProductSDto() + { + Count = p11.Count, + ProductFee = p11.ProductFee, + ProductFeeWithDiscount = p11.ProductFeeWithDiscount, + HasDiscount = p11.HasDiscount, + ProductCost = p11.ProductCost, + PackingFee = p11.PackingFee, + PackingCost = p11.PackingCost, + OrderProductStatus = p11.OrderProductStatus, + ProductId = p11.ProductId, + ProductName = p11.Product != null ? p11.Product.PersianName : string.Empty, + OrderId = p11.OrderId, + Id = p11.Id, + CreatedAt = p11.CreatedAt + }; + + private static Product funcMain1(Never p4, Product p5, OrderProductSDto p2) + { + Product result = p5 ?? new Product(); + + result.Cost = p2.ProductCost; + result.Id = p2.ProductId; + return result; + + } + + private static Order funcMain2(Never p6, Order p7, OrderProductSDto p2) + { + Order result = p7 ?? new Order(); + + result.Id = p2.OrderId; + return result; + + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/Mappers/PaymentMapper.g.cs b/NetinaShop.Domain/Mappers/PaymentMapper.g.cs new file mode 100644 index 0000000..f79b9a9 --- /dev/null +++ b/NetinaShop.Domain/Mappers/PaymentMapper.g.cs @@ -0,0 +1,144 @@ +using System; +using System.Linq.Expressions; +using Mapster.Models; +using NetinaShop.Domain.Dtos.SmallDtos; +using NetinaShop.Domain.Entities.Accounting; +using NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Entities.Users; + +namespace NetinaShop.Domain.Mappers +{ + public static partial class PaymentMapper + { + public static Payment AdaptToPayment(this PaymentSDto p1) + { + return p1 == null ? null : new Payment() + { + FactorNumber = p1.FactorNumber, + Amount = p1.Amount, + Description = p1.Description, + TransactionCode = p1.TransactionCode, + CardPan = p1.CardPan, + Authority = p1.Authority, + Type = p1.Type, + Status = p1.Status, + OrderId = p1.OrderId, + Order = new Order() {Id = p1.OrderId}, + UserId = p1.UserId, + User = new ApplicationUser() + { + Id = p1.UserId, + PhoneNumber = p1.UserPhoneNumber + }, + Id = p1.Id, + CreatedAt = p1.CreatedAt + }; + } + public static Payment AdaptTo(this PaymentSDto p2, Payment p3) + { + if (p2 == null) + { + return null; + } + Payment result = p3 ?? new Payment(); + + result.FactorNumber = p2.FactorNumber; + result.Amount = p2.Amount; + result.Description = p2.Description; + result.TransactionCode = p2.TransactionCode; + result.CardPan = p2.CardPan; + result.Authority = p2.Authority; + result.Type = p2.Type; + result.Status = p2.Status; + result.OrderId = p2.OrderId; + result.Order = funcMain1(new Never(), result.Order, p2); + result.UserId = p2.UserId; + result.User = funcMain2(new Never(), result.User, p2); + result.Id = p2.Id; + result.CreatedAt = p2.CreatedAt; + return result; + + } + public static PaymentSDto AdaptToSDto(this Payment p8) + { + return p8 == null ? null : new PaymentSDto() + { + FactorNumber = p8.FactorNumber, + Amount = p8.Amount, + Description = p8.Description, + TransactionCode = p8.TransactionCode, + CardPan = p8.CardPan, + Authority = p8.Authority, + Type = p8.Type, + Status = p8.Status, + OrderId = p8.OrderId, + UserId = p8.UserId, + UserFullName = p8.User != null ? p8.User.FirstName + " " + p8.User.LastName : string.Empty, + UserPhoneNumber = p8.User != null ? p8.User.PhoneNumber : string.Empty, + Id = p8.Id, + CreatedAt = p8.CreatedAt + }; + } + public static PaymentSDto AdaptTo(this Payment p9, PaymentSDto p10) + { + if (p9 == null) + { + return null; + } + PaymentSDto result = p10 ?? new PaymentSDto(); + + result.FactorNumber = p9.FactorNumber; + result.Amount = p9.Amount; + result.Description = p9.Description; + result.TransactionCode = p9.TransactionCode; + result.CardPan = p9.CardPan; + result.Authority = p9.Authority; + result.Type = p9.Type; + result.Status = p9.Status; + result.OrderId = p9.OrderId; + result.UserId = p9.UserId; + result.UserFullName = p9.User != null ? p9.User.FirstName + " " + p9.User.LastName : string.Empty; + result.UserPhoneNumber = p9.User != null ? p9.User.PhoneNumber : string.Empty; + result.Id = p9.Id; + result.CreatedAt = p9.CreatedAt; + return result; + + } + public static Expression> ProjectToSDto => p11 => new PaymentSDto() + { + FactorNumber = p11.FactorNumber, + Amount = p11.Amount, + Description = p11.Description, + TransactionCode = p11.TransactionCode, + CardPan = p11.CardPan, + Authority = p11.Authority, + Type = p11.Type, + Status = p11.Status, + OrderId = p11.OrderId, + UserId = p11.UserId, + UserFullName = p11.User != null ? p11.User.FirstName + " " + p11.User.LastName : string.Empty, + UserPhoneNumber = p11.User != null ? p11.User.PhoneNumber : string.Empty, + Id = p11.Id, + CreatedAt = p11.CreatedAt + }; + + private static Order funcMain1(Never p4, Order p5, PaymentSDto p2) + { + Order result = p5 ?? new Order(); + + result.Id = p2.OrderId; + return result; + + } + + private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, PaymentSDto p2) + { + ApplicationUser result = p7 ?? new ApplicationUser(); + + result.Id = p2.UserId; + result.PhoneNumber = p2.UserPhoneNumber; + return result; + + } + } +} \ No newline at end of file diff --git a/NetinaShop.Domain/MapsterRegister.cs b/NetinaShop.Domain/MapsterRegister.cs index dcc68a9..aa377da 100644 --- a/NetinaShop.Domain/MapsterRegister.cs +++ b/NetinaShop.Domain/MapsterRegister.cs @@ -1,4 +1,6 @@ -namespace NetinaShop.Domain; +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Domain; public class MapsterRegister : IRegister { @@ -12,6 +14,10 @@ public class MapsterRegister : IRegister .Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f => f.IsHeader) ? o.Files.FirstOrDefault(f => f.IsHeader)!.FileName : string.Empty) .TwoWays(); + config.NewConfig() + .Map("ShippingMethod", o => o.Shipping != null ? o.Shipping.Name : string.Empty) + .TwoWays(); + config.NewConfig() .Map("ParentName", o => o.Parent != null ? o.Parent.Name : string.Empty) .TwoWays(); @@ -23,6 +29,31 @@ public class MapsterRegister : IRegister .IgnoreNullValues(false) .TwoWays(); + config.NewConfig() + .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) + .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .IgnoreNullValues(false) + .TwoWays(); + + config.NewConfig() + .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) + .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .IgnoreNullValues(false) + .TwoWays(); + + config.NewConfig() + .Map("ProductName", o => o.Product != null ? o.Product.PersianName : string.Empty) + .IgnoreNullValues(false) + .TwoWays(); + + config.NewConfig() + .Map("UserFullName", o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty) + .Map("UserPhoneNumber", o => o.User != null ? o.User.PhoneNumber : string.Empty) + .IgnoreNullValues(false) + .TwoWays(); + + + config.NewConfig() .Map("CategoryName", o => o.Category == null ? null : o.Category.Name) .Map("BrandName", o => o.Brand == null ? null : o.Brand.Name) diff --git a/NetinaShop.Infrastructure/Models/RestAddress.cs b/NetinaShop.Infrastructure/Models/RestAddress.cs index a742622..a6a1f24 100644 --- a/NetinaShop.Infrastructure/Models/RestAddress.cs +++ b/NetinaShop.Infrastructure/Models/RestAddress.cs @@ -2,5 +2,6 @@ public static class RestAddress { - public static string BaseKaveNegar { get => "https://api.kavenegar.com/v1/"; } + public static string BaseKaveNegar => "https://api.kavenegar.com/v1/"; + public static string BaseZarinpal => "https://api.zarinpal.com/pg"; } \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkRequest.cs b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkRequest.cs new file mode 100644 index 0000000..bde994c --- /dev/null +++ b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkRequest.cs @@ -0,0 +1,17 @@ +namespace NetinaShop.Infrastructure.Models.RestApi.Zarinpal; + +public class ZarinaplPaymentLinkRequest +{ + public string merchant_id { get; set; } = string.Empty; + public int amount { get; set; } + public string callback_url { get; set; } = string.Empty; + public string description { get; set; } = string.Empty; + public ZarinaplPaymentLinkRequestMetadata metadata { get; set; } = new(); + +} + +public class ZarinaplPaymentLinkRequestMetadata +{ + public string mobile { get; set; } = string.Empty; + public string email { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkResponse.cs b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkResponse.cs new file mode 100644 index 0000000..47d17d6 --- /dev/null +++ b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentLinkResponse.cs @@ -0,0 +1,16 @@ +namespace NetinaShop.Infrastructure.Models.RestApi.Zarinpal; + +public class ZarinaplPaymentLinkResponse +{ + public ZarinaplPaymentLinkResponseData data { get; set; } + public List errors { get; set; } +} + +public class ZarinaplPaymentLinkResponseData +{ + public int code { get; set; } + public string message { get; set; } = string.Empty; + public string authority { get; set; } = string.Empty; + public string fee_type { get; set; } = string.Empty; + public int fee { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentVerifyResponse.cs b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentVerifyResponse.cs new file mode 100644 index 0000000..925bf98 --- /dev/null +++ b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplPaymentVerifyResponse.cs @@ -0,0 +1,20 @@ +namespace NetinaShop.Infrastructure.Models.RestApi.Zarinpal; + +public class ZarinaplPaymentVerifyResponse +{ + + public ZarinaplPaymentVerifyResponseData data { get; set; } + public List errors { get; set; } + +} + +public class ZarinaplPaymentVerifyResponseData +{ + public int code { get; set; } + public string message { get; set; } = string.Empty; + public string card_hash { get; set; } = string.Empty; + public string card_pan { get; set; } = string.Empty; + public int ref_id { get; set; } + public string fee_type { get; set; } = string.Empty; + public int fee { get; set; } +} \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplVerifyPaymentRequest.cs b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplVerifyPaymentRequest.cs new file mode 100644 index 0000000..314b853 --- /dev/null +++ b/NetinaShop.Infrastructure/Models/RestApi/Zarinpal/ZarinaplVerifyPaymentRequest.cs @@ -0,0 +1,8 @@ +namespace NetinaShop.Infrastructure.Models.RestApi.Zarinpal; + +public class ZarinaplVerifyPaymentRequest +{ + public string merchant_id { get; set; } = string.Empty; + public int amount { get; set; } + public string authority { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/NetinaShop.Infrastructure/NetinaShop.Infrastructure.csproj b/NetinaShop.Infrastructure/NetinaShop.Infrastructure.csproj index f2b3a57..2a847a6 100644 --- a/NetinaShop.Infrastructure/NetinaShop.Infrastructure.csproj +++ b/NetinaShop.Infrastructure/NetinaShop.Infrastructure.csproj @@ -18,11 +18,6 @@ - - - - - diff --git a/NetinaShop.Infrastructure/RestServices/IRestApiWrapper.cs b/NetinaShop.Infrastructure/RestServices/IRestApiWrapper.cs index b913979..843831c 100644 --- a/NetinaShop.Infrastructure/RestServices/IRestApiWrapper.cs +++ b/NetinaShop.Infrastructure/RestServices/IRestApiWrapper.cs @@ -5,9 +5,11 @@ namespace NetinaShop.Infrastructure.RestServices; public interface IRestApiWrapper : IScopedDependency { IKaveNegarRestApi KaveNegarRestApi { get; } + IZarinpalRestApi ZarinpalRestApi { get; } } public class RestApiWrapper : IRestApiWrapper { public IKaveNegarRestApi KaveNegarRestApi => RestService.For(RestAddress.BaseKaveNegar); + public IZarinpalRestApi ZarinpalRestApi => RestService.For(RestAddress.BaseZarinpal); } \ No newline at end of file diff --git a/NetinaShop.Infrastructure/RestServices/IZarinpalRestApi.cs b/NetinaShop.Infrastructure/RestServices/IZarinpalRestApi.cs new file mode 100644 index 0000000..f25a939 --- /dev/null +++ b/NetinaShop.Infrastructure/RestServices/IZarinpalRestApi.cs @@ -0,0 +1,12 @@ +using NetinaShop.Infrastructure.Models.RestApi.Zarinpal; + +namespace NetinaShop.Infrastructure.RestServices; + +public interface IZarinpalRestApi +{ + + [Post("/v4/payment/request.json")] + Task GetPaymentLinkAsync([Body] ZarinaplPaymentLinkRequest request); + [Post("/v4/payment/verify.json")] + Task VerifyPaymentAsync([Body] ZarinaplVerifyPaymentRequest request); +} \ No newline at end of file diff --git a/NetinaShop.Infrastructure/Services/ZarinpalService.cs b/NetinaShop.Infrastructure/Services/ZarinpalService.cs new file mode 100644 index 0000000..25aea25 --- /dev/null +++ b/NetinaShop.Infrastructure/Services/ZarinpalService.cs @@ -0,0 +1,74 @@ +using Amazon.Runtime.Internal; +using MediatR; +using Microsoft.EntityFrameworkCore; +using NetinaShop.Domain.CommandQueries.Commands; +using NetinaShop.Domain.CommandQueries.Queries; +using NetinaShop.Domain.Entities.Accounting; +using NetinaShop.Domain.Entities.Orders; +using NetinaShop.Domain.Enums; +using NetinaShop.Infrastructure.Models.RestApi.Zarinpal; +using NetinaShop.Repository.Repositories.Base.Contracts; + +namespace NetinaShop.Infrastructure.Services; + +public class ZarinpalService : IPaymentService +{ + private readonly IRestApiWrapper _restApiWrapper; + private readonly IMediator _mediator; + private readonly SiteSettings _siteSettings; + public ZarinpalService(IRestApiWrapper restApiWrapper,IOptionsSnapshot snapshot,IMediator mediator) + { + _restApiWrapper = restApiWrapper; + _mediator = mediator; + _siteSettings = snapshot.Value; + } + public async Task GetPaymentLinkAsync(double amount,string factorNumber, Guid orderId, Guid userId, string phoneNumber , string fullName , CancellationToken cancellationToken = default) + { + var request = new ZarinaplPaymentLinkRequest + { + description = $"پرداخت {amount.ToString("N0")} ریال توسط {fullName} با شماره تماس {phoneNumber} برای سفارش با شماره {factorNumber}", + amount = (int)amount, + callback_url = Path.Combine("https://api.vesmook.com", "api", "accounting", "pay", "verify"), + merchant_id = "4292b845-b510-4d1d-8ee2-097499b198e5", + metadata = new ZarinaplPaymentLinkRequestMetadata { mobile = phoneNumber } + }; + var response = await _restApiWrapper.ZarinpalRestApi.GetPaymentLinkAsync(request); + if (response.data.code != 100) + throw new AppException($"Exception in get link from zarinpal | {response.data.message}"); + + + var createPaymentResult = await _mediator.Send(new CreatePaymentCommand(factorNumber, amount, + request.description, string.Empty, string.Empty, + response.data.authority, PaymentType.Online,PaymentStatus.InPaymentGateway, orderId, userId), cancellationToken); + + string link = $"https://www.zarinpal.com/pg/StartPay/{response.data.authority}"; + return link; + } + + public async Task VerifyPaymentAsync(string authority, CancellationToken cancellationToken = default) + { + var payment = await _mediator.Send(new GetPaymentQuery(Authority: authority), cancellationToken); + var request = new ZarinaplVerifyPaymentRequest + { + amount = (int)payment.Amount, + authority = payment.Authority, + merchant_id = "4292b845-b510-4d1d-8ee2-097499b198e5" + }; + var response = await _restApiWrapper.ZarinpalRestApi.VerifyPaymentAsync(request); + if (response.data.code != 100) + throw new AppException($"Exception in get link from zarinpal | {response.data.message}"); + + payment.Status = PaymentStatus.Paid; + payment.CardPan = response.data.card_pan; + payment.TransactionCode = response.data.ref_id.ToString(); + + await _mediator.Send( + new UpdatePaymentCommand(payment.Id, payment.FactorNumber, payment.Amount, payment.Description, + payment.TransactionCode, payment.CardPan, payment.Authority, payment.Type, payment.Status, + payment.OrderId, payment.UserId), cancellationToken); + + await _mediator.Send(new SubmitOrderPaymentCommand(payment.OrderId, OrderPaymentMethod.OnlinePayment, true),cancellationToken); + + return payment.TransactionCode; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Abstracts/IPaymentService.cs b/NetinaShop.Repository/Abstracts/IPaymentService.cs deleted file mode 100644 index e65036c..0000000 --- a/NetinaShop.Repository/Abstracts/IPaymentService.cs +++ /dev/null @@ -1,7 +0,0 @@ -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/Accounting/CreatePaymentCommandHandler.cs b/NetinaShop.Repository/Handlers/Accounting/CreatePaymentCommandHandler.cs new file mode 100644 index 0000000..011dbea --- /dev/null +++ b/NetinaShop.Repository/Handlers/Accounting/CreatePaymentCommandHandler.cs @@ -0,0 +1,26 @@ +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Repository.Handlers.Accounting; + +public class CreatePaymentCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public CreatePaymentCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreatePaymentCommand request, CancellationToken cancellationToken) + { + + var payment = Payment.Create(request.FactorNumber, request.Amount, request.Description, request.TransactionCode, + request.CardPan, request.Authority, request.Type,request.Status, request.OrderId, request.UserId); + + _repositoryWrapper.SetRepository() + .Add(payment); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs b/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs new file mode 100644 index 0000000..a84de88 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Accounting/GetPaymentQueryHandler.cs @@ -0,0 +1,41 @@ +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Repository.Handlers.Accounting; + +public class GetPaymentQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetPaymentQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetPaymentQuery request, CancellationToken cancellationToken) + { + PaymentSDto? payment = null; + if (request.Authority != null) + { + payment = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(p => p.Authority == request.Authority) + .Select(PaymentMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + } + else + { + if (request.Id == default) + throw new Exception("Id is null"); + + payment = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(p => p.Id == request.Id) + .Select(PaymentMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + } + + if (payment == null) + throw new AppException("Payment not found !", ApiResultStatusCode.NotFound); + + return payment; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs b/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs new file mode 100644 index 0000000..1fa3cac --- /dev/null +++ b/NetinaShop.Repository/Handlers/Accounting/GetPaymentsQueryHandler.cs @@ -0,0 +1,22 @@ +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Repository.Handlers.Accounting; + +public class GetPaymentsQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetPaymentsQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetPaymentsQuery request, CancellationToken cancellationToken) + { + return await _repositoryWrapper.SetRepository() + .TableNoTracking + .Skip(20 * request.Page) + .Take(20) + .Select(PaymentMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs b/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs new file mode 100644 index 0000000..1485d9c --- /dev/null +++ b/NetinaShop.Repository/Handlers/Accounting/UpdatePaymentCommandHandler.cs @@ -0,0 +1,31 @@ +using NetinaShop.Domain.Entities.Accounting; + +namespace NetinaShop.Repository.Handlers.Accounting; + +public class UpdatePaymentCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdatePaymentCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(UpdatePaymentCommand request, CancellationToken cancellationToken) + { + var ent = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(p => p.Id == request.Id, cancellationToken); + if (ent == null) + throw new AppException("Payment not found", ApiResultStatusCode.NotFound); + + var newEnt = Payment.Create(request.FactorNumber, request.Amount, request.Description, request.TransactionCode, + request.CardPan, request.Authority, request.Type, request.Status, request.OrderId, request.UserId); + newEnt.Id = ent.Id; + + _repositoryWrapper.SetRepository() + .Update(newEnt); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs new file mode 100644 index 0000000..f129a68 --- /dev/null +++ b/NetinaShop.Repository/Handlers/Orders/GetOrderLDtoQueryHandler.cs @@ -0,0 +1,26 @@ +using NetinaShop.Domain.Entities.Orders; + +namespace NetinaShop.Repository.Handlers.Orders; + +public class GetOrderLDtoQueryHandler: IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetOrderLDtoQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetOrderLDtoQuery request, CancellationToken cancellationToken) + { + if (request.Id == default) + throw new AppException("Order id is null"); + var order = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(o => o.Id == request.Id) + .Select(OrderMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (order == null) + throw new AppException("Order not found", ApiResultStatusCode.NotFound); + return order; + } +} \ No newline at end of file diff --git a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs index 658e8ae..0c62612 100644 --- a/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs +++ b/NetinaShop.Repository/Handlers/Orders/GetOrdersQueryHandler.cs @@ -10,10 +10,42 @@ public class GetOrdersQueryHandler : IRequestHandler> Handle(GetOrdersQuery request, CancellationToken cancellationToken) + public async Task> Handle(GetOrdersQuery request, CancellationToken cancellationToken) { - return _repositoryWrapper.SetRepository() - .TableNoTracking + + IQueryable orders = _repositoryWrapper.SetRepository() + .TableNoTracking; + + if (request.DateFilter != null) + { + switch (request.DateFilter) + { + case OrderQueryDateFilter.CustomDate: + if (request.SelectedDate != null) + orders = orders.Where(o => o.CreatedAt.Date == DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate.Value)); + else + throw new AppException("For custom date you have to send SelectedDate",ApiResultStatusCode.BadRequest); + break; + case OrderQueryDateFilter.ThisMonth: + orders = orders.Where(o => o.CreatedAt.Date >= new DateTime(DateTime.Today.Year,DateTime.Today.Month,1)); + break; + case OrderQueryDateFilter.ThisWeek: + orders = orders.Where(o => o.CreatedAt.Date >= DateTime.Today.AddDays(-7)); + break; + case OrderQueryDateFilter.Today: + orders = orders.Where(o => o.CreatedAt.Date == DateTime.Today.Date); + break; + default: + break; + + } + } + + if (request.OrderStatus != null) + orders = orders.Where(o => o.OrderStatus == request.OrderStatus.Value); + + return await orders + .OrderByDescending(o=>o.CreatedAt) .Skip(request.Page * 15) .Take(15) .Select(OrderMapper.ProjectToSDto) diff --git a/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.Designer.cs b/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.Designer.cs new file mode 100644 index 0000000..9001672 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.Designer.cs @@ -0,0 +1,1573 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetinaShop.Repository.Models; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20240210134749_EditOrderAddFactorCode")] + partial class EditOrderAddFactorCode + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("DiscountId"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("LocationLat") + .HasColumnType("real"); + + b.Property("LocationLong") + .HasColumnType("real"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderDeliveries") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany("Addresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDeliveries"); + + b.Navigation("OrderProducts"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.cs b/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.cs new file mode 100644 index 0000000..a1ae29b --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240210134749_EditOrderAddFactorCode.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class EditOrderAddFactorCode : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "FactorCode", + schema: "public", + table: "Orders", + type: "text", + nullable: false, + defaultValue: ""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "FactorCode", + schema: "public", + table: "Orders"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240211102121_AddPayment.Designer.cs b/NetinaShop.Repository/Migrations/20240211102121_AddPayment.Designer.cs new file mode 100644 index 0000000..2ed3b27 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240211102121_AddPayment.Designer.cs @@ -0,0 +1,1663 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NetinaShop.Repository.Models; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20240211102121_AddPayment")] + partial class AddPayment + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Claims", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("Logins", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "public"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("Tokens", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSuggested") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ReadingTime") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BlogCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasSpecialPage") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Brands", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DiscountAmount") + .HasColumnType("bigint"); + + b.Property("DiscountPercent") + .HasColumnType("integer"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("character varying(21)"); + + b.Property("ExpireDate") + .HasColumnType("timestamp without time zone"); + + b.Property("HasCode") + .HasColumnType("boolean"); + + b.Property("HasPriceCeiling") + .HasColumnType("boolean"); + + b.Property("HasPriceFloor") + .HasColumnType("boolean"); + + b.Property("IsForInvitation") + .HasColumnType("boolean"); + + b.Property("IsInfinity") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsSpecialOffer") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PriceCeiling") + .HasColumnType("bigint"); + + b.Property("PriceFloor") + .HasColumnType("bigint"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("StartDate") + .HasColumnType("timestamp without time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UseCount") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("Discounts", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Discount"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryPrice") + .HasColumnType("double precision"); + + b.Property("DiscountCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DiscountId") + .HasColumnType("uuid"); + + b.Property("DiscountPrice") + .HasColumnType("double precision"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsPayed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderAt") + .HasColumnType("timestamp without time zone"); + + b.Property("OrderStatus") + .HasColumnType("integer"); + + b.Property("PackingPrice") + .HasColumnType("double precision"); + + b.Property("PayedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("PaymentMethod") + .HasColumnType("integer"); + + b.Property("PreparingMinute") + .HasColumnType("integer"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ServicePrice") + .HasColumnType("double precision"); + + b.Property("TaxesPrice") + .HasColumnType("double precision"); + + b.Property("TotalPrice") + .HasColumnType("double precision"); + + b.Property("TotalProductsPrice") + .HasColumnType("double precision"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("DiscountId"); + + b.HasIndex("UserId"); + + b.ToTable("Orders", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ShippingId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ShippingId"); + + b.ToTable("OrderDeliveries", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("HasDiscount") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("OrderProductStatus") + .HasColumnType("integer"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PackingFee") + .HasColumnType("double precision"); + + b.Property("ProductCategoryId") + .HasColumnType("uuid"); + + b.Property("ProductCost") + .HasColumnType("double precision"); + + b.Property("ProductFee") + .HasColumnType("double precision"); + + b.Property("ProductFeeWithDiscount") + .HasColumnType("double precision"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMain") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.ToTable("ProductCategories", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BeDisplayed") + .HasColumnType("boolean"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("Cost") + .HasColumnType("double precision"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpertCheck") + .IsRequired() + .HasColumnType("text"); + + b.Property("HasExpressDelivery") + .HasColumnType("boolean"); + + b.Property("IsEnable") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("MaxOrderCount") + .HasColumnType("integer"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PackingCost") + .HasColumnType("double precision"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("ReviewCount") + .HasColumnType("integer"); + + b.Property("Stock") + .HasColumnType("integer"); + + b.Property("Summery") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tags") + .IsRequired() + .HasColumnType("text"); + + b.Property("Viewed") + .HasColumnType("integer"); + + b.Property("Warranty") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BrandId"); + + b.HasIndex("CategoryId"); + + b.ToTable("Products", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsBuyer") + .HasColumnType("boolean"); + + b.Property("IsConfirmed") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("Rate") + .HasColumnType("real"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("Reviews", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Detail") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsFeature") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ParentId"); + + b.HasIndex("ProductId"); + + b.ToTable("Specifications", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.StorageFiles.StorageFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(34) + .HasColumnType("character varying(34)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileType") + .HasColumnType("integer"); + + b.Property("IsHeader") + .HasColumnType("boolean"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("StorageFiles", "public"); + + b.HasDiscriminator("Discriminator").HasValue("StorageFile"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NationalId") + .IsRequired() + .HasColumnType("text"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("Users", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("LocationLat") + .HasColumnType("real"); + + b.Property("LocationLong") + .HasColumnType("real"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("PostalCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverFullName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReceiverPhoneNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserAddresses", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("UserId"); + + b.ToTable("UserFavoriteProducts", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Warehouses.Shipping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("DeliveryCost") + .HasColumnType("double precision"); + + b.Property("IsExpressShipping") + .HasColumnType("boolean"); + + b.Property("IsOriginalWarehouse") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsShipBySeller") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("WarehouseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Shippings", "public"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("CategoryDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.Discounts.Discount"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductDiscount"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BlogId") + .HasColumnType("uuid"); + + b.HasIndex("BlogId"); + + b.HasDiscriminator().HasValue("BlogStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("BrandId") + .HasColumnType("uuid"); + + b.HasIndex("BrandId"); + + b.HasDiscriminator().HasValue("BrandStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.HasIndex("CategoryId"); + + b.HasDiscriminator().HasValue("ProductCategoryStorageFile"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasBaseType("NetinaShop.Domain.Entities.StorageFiles.StorageFile"); + + b.Property("ProductId") + .HasColumnType("uuid"); + + b.HasIndex("ProductId"); + + b.HasDiscriminator().HasValue("ProductStorageFile"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") + .WithMany("Blogs") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.HasOne("NetinaShop.Domain.Entities.Discounts.Discount", null) + .WithMany("Orders") + .HasForeignKey("DiscountId"); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderDelivery", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderDeliveries") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") + .WithMany() + .HasForeignKey("ShippingId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Shipping"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.OrderProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("OrderProducts") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Products") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Products") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Review", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Reviews") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Specification", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId"); + + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Specifications") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserAddress", b => + { + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany("Addresses") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.UserFavoriteProduct", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.CategoryDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.ProductDiscount", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Blogs.Blog", "Blog") + .WithMany("Files") + .HasForeignKey("BlogId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Blog"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.BrandStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Brands.Brand", "Brand") + .WithMany("Files") + .HasForeignKey("BrandId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Brand"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategoryStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", "Category") + .WithMany("Files") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.ProductStorageFile", b => + { + b.HasOne("NetinaShop.Domain.Entities.Products.Product", "Product") + .WithMany("Files") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.BlogCategory", b => + { + b.Navigation("Blogs"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Brands.Brand", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Discounts.Discount", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => + { + b.Navigation("OrderDeliveries"); + + b.Navigation("OrderProducts"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b => + { + b.Navigation("Files"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Product", b => + { + b.Navigation("Files"); + + b.Navigation("OrderProducts"); + + b.Navigation("Reviews"); + + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Products.Specification", b => + { + b.Navigation("Children"); + }); + + modelBuilder.Entity("NetinaShop.Domain.Entities.Users.ApplicationUser", b => + { + b.Navigation("Addresses"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/NetinaShop.Repository/Migrations/20240211102121_AddPayment.cs b/NetinaShop.Repository/Migrations/20240211102121_AddPayment.cs new file mode 100644 index 0000000..97e0310 --- /dev/null +++ b/NetinaShop.Repository/Migrations/20240211102121_AddPayment.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace NetinaShop.Repository.Migrations +{ + /// + public partial class AddPayment : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Payments", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + FactorNumber = table.Column(type: "text", nullable: false), + Amount = table.Column(type: "double precision", nullable: false), + Description = table.Column(type: "text", nullable: false), + TransactionCode = table.Column(type: "text", nullable: false), + CardPan = table.Column(type: "text", nullable: false), + Authority = table.Column(type: "text", nullable: false), + Type = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + OrderId = table.Column(type: "uuid", nullable: false), + 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: true), + IsRemoved = table.Column(type: "boolean", 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: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalSchema: "public", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Payments_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + schema: "public", + table: "Payments", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_UserId", + schema: "public", + table: "Payments", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Payments", + schema: "public"); + } + } +} diff --git a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs index d315470..448b5f6 100644 --- a/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/NetinaShop.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -126,6 +126,77 @@ namespace NetinaShop.Repository.Migrations b.ToTable("Tokens", "public"); }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("double precision"); + + b.Property("Authority") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardPan") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("FactorNumber") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .HasColumnType("text"); + + b.Property("OrderId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TransactionCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("UserId"); + + b.ToTable("Payments", "public"); + }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => { b.Property("Id") @@ -393,6 +464,10 @@ namespace NetinaShop.Repository.Migrations b.Property("DoneAt") .HasColumnType("timestamp without time zone"); + b.Property("FactorCode") + .IsRequired() + .HasColumnType("text"); + b.Property("IsPayed") .HasColumnType("boolean"); @@ -1300,6 +1375,23 @@ namespace NetinaShop.Repository.Migrations .OnDelete(DeleteBehavior.Restrict); }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Accounting.Payment", b => + { + b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("NetinaShop.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Order"); + + b.Navigation("User"); + }); + modelBuilder.Entity("NetinaShop.Domain.Entities.Blogs.Blog", b => { b.HasOne("NetinaShop.Domain.Entities.Blogs.BlogCategory", "Category") @@ -1531,6 +1623,8 @@ namespace NetinaShop.Repository.Migrations b.Navigation("OrderDeliveries"); b.Navigation("OrderProducts"); + + b.Navigation("Payments"); }); modelBuilder.Entity("NetinaShop.Domain.Entities.ProductCategories.ProductCategory", b =>