fix : fix submit delivery and discount step , feat ver 0.5.6.14

release
Amir Hossein Khademi 2024-02-13 12:22:58 +03:30
parent 24ca6e859c
commit 4100e2f8fa
17 changed files with 2150 additions and 451 deletions

View File

@ -1 +1 @@
0.5.4.13 0.5.6.14

View File

@ -13,7 +13,7 @@ public static class LoggerConfig
o.MinimumEventLevel = LogEventLevel.Error; o.MinimumEventLevel = LogEventLevel.Error;
o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7"; o.Dsn = "https://592b7fbb29464442a8e996247abe857f@watcher.igarson.app/7";
}) })
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Information) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
.CreateLogger(); .CreateLogger();
} }
} }

View File

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Mvc.RazorPages; using System.Reflection;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc.RazorPages;
using NetinaShop.Domain;
using NetinaShop.Domain.Entities.Pages; using NetinaShop.Domain.Entities.Pages;
using NetinaShop.Repository.Repositories.Entity.Abstracts; using NetinaShop.Repository.Repositories.Entity.Abstracts;
@ -26,9 +29,9 @@ public class PageService : IPageService
if (page == null) if (page == null)
throw new AppException("Page not found", ApiResultStatusCode.NotFound); throw new AppException("Page not found", ApiResultStatusCode.NotFound);
var entityType = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(page.Type);
var dto = new BasePageEntitySDto var dto = new BasePageEntitySDto
{ {
Content = page.Content, Content = page.Content,
Description = page.Description, Description = page.Description,
Id = page.Id, Id = page.Id,
@ -36,7 +39,7 @@ public class PageService : IPageService
IsHtmlBasePage = page.IsHtmlBasePage, IsHtmlBasePage = page.IsHtmlBasePage,
Name = page.Name, Name = page.Name,
Slug = page.Slug, Slug = page.Slug,
Data = JsonConvert.DeserializeObject(page.Data) Data = page.Data
}; };
return dto; return dto;
@ -48,9 +51,10 @@ public class PageService : IPageService
var pages = await _martenRepository.GetEntitiesAsync<BasePageEntity>(cancellationToken); var pages = await _martenRepository.GetEntitiesAsync<BasePageEntity>(cancellationToken);
foreach (var page in pages) foreach (var page in pages)
{ {
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(page.Type);
var dto = new BasePageEntitySDto var dto = new BasePageEntitySDto
{ {
Content = page.Content, Content = page.Content,
Description = page.Description, Description = page.Description,
Id = page.Id, Id = page.Id,
@ -58,7 +62,7 @@ public class PageService : IPageService
IsHtmlBasePage = page.IsHtmlBasePage, IsHtmlBasePage = page.IsHtmlBasePage,
Name = page.Name, Name = page.Name,
Slug = page.Slug, Slug = page.Slug,
Data = JsonConvert.DeserializeObject(page.Data) Data = page.Data
}; };
sDtos.Add(dto); sDtos.Add(dto);
} }
@ -77,8 +81,9 @@ public class PageService : IPageService
Name = entity.Name, Name = entity.Name,
Type = entity.Type, Type = entity.Type,
Slug = entity.Slug, Slug = entity.Slug,
Data = JsonConvert.SerializeObject(entity.Data)
}; };
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(entity.Type);
basePage.Data = JsonConvert.SerializeObject(((JsonElement)entity.Data).Deserialize(type));
await _martenRepository.AddOrUpdateEntityAsync(basePage, cancellationToken); await _martenRepository.AddOrUpdateEntityAsync(basePage, cancellationToken);
return true; return true;
} }

View File

@ -18,7 +18,7 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken); .FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
if (discount == null) if (discount == null)
throw new AppException("Discount not found", ApiResultStatusCode.NotFound); throw new AppException("تخفیف وجود منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
double discountPrice = 0; double discountPrice = 0;

View File

@ -21,7 +21,7 @@ public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountComman
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken); .FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
if (discount == null || discount.IsExpired()) if (discount == null || discount.IsExpired())
throw new AppException("Discount is expired or not found", ApiResultStatusCode.NotFound); throw new AppException("تخفیف منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
order.SetDiscount(request.DiscountCode); order.SetDiscount(request.DiscountCode);
_repositoryWrapper.SetRepository<Order>().Update(order); _repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);

View File

@ -1,4 +1,5 @@
using NetinaShop.Domain.Entities.Warehouses; using NetinaShop.Domain.Entities.Orders;
using NetinaShop.Domain.Entities.Warehouses;
namespace NetinaShop.Core.EntityServices.OrderBagHandlers; namespace NetinaShop.Core.EntityServices.OrderBagHandlers;
@ -14,32 +15,32 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeli
} }
public async Task<OrderSDto> Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken) public async Task<OrderSDto> Handle(SubmitOrderDeliveryCommand request, CancellationToken cancellationToken)
{ {
var order = await _mediator.Send(new GetOrderQuery(request.OrderId), cancellationToken); var order = await _repositoryWrapper.SetRepository<Order>()
.TableNoTracking
.FirstOrDefaultAsync(o => o.Id == request.OrderId, cancellationToken);
if (order == null)
throw new AppException("Order not found", ApiResultStatusCode.NotFound);
var orderDelivery = await _repositoryWrapper.SetRepository<OrderDelivery>()
.TableNoTracking
.FirstOrDefaultAsync(od => od.OrderId == request.OrderId, cancellationToken);
if (orderDelivery != null)
{
order.AddOrderDelivery(orderDelivery.AddressId, orderDelivery.DeliveryCost, orderDelivery.ShippingId, orderDelivery.OrderId, orderDelivery.Id);
}
var shipping = await _repositoryWrapper.SetRepository<Shipping>() var shipping = await _repositoryWrapper.SetRepository<Shipping>()
.TableNoTracking .TableNoTracking
.FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken); .FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken);
if (shipping == null) if (shipping == null)
throw new AppException("Shipping not found", ApiResultStatusCode.NotFound); throw new AppException("Shipping not found", ApiResultStatusCode.NotFound);
if (order.OrderDeliveries.Count > 0)
{
foreach (var orderDelivery in order.OrderDeliveries)
{
var newEnt = OrderDelivery.Create(request.AddressId, shipping.DeliveryCost, request.ShippingId,
request.OrderId);
newEnt.CreatedAt = orderDelivery.CreatedAt;
newEnt.CreatedBy = orderDelivery.CreatedBy;
newEnt.Id = orderDelivery.Id;
_repositoryWrapper.SetRepository<OrderDelivery>()
.Update(newEnt);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
order.OrderDeliveries.Clear();
}
else
order.AddOrderDelivery(request.AddressId, shipping.DeliveryCost, request.ShippingId, request.OrderId); order.AddOrderDelivery(request.AddressId, shipping.DeliveryCost, request.ShippingId, request.OrderId);
_repositoryWrapper.SetRepository<Order>().Update(order); _repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
var calculatedOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken); var calculatedOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
return calculatedOrder.AdaptToSDto(); return calculatedOrder.AdaptToSDto();
} }

View File

@ -24,7 +24,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
// ? (totalProductPrice / 100) * _shopSettings.ServiceFee // ? (totalProductPrice / 100) * _shopSettings.ServiceFee
// : _shopSettings.ServiceFee; // : _shopSettings.ServiceFee;
var servicePrice = 0; var servicePrice = 0;
var deliveryPrice = order.OrderDeliveries.Sum(op => op.DeliveryCost); var deliveryPrice = order.OrderDelivery?.DeliveryCost ?? 0;
double discountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count); double discountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
if (!order.DiscountCode.IsNullOrEmpty()) if (!order.DiscountCode.IsNullOrEmpty())
{ {
@ -36,7 +36,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice); order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
order.OrderProducts.Clear(); order.OrderProducts.Clear();
order.OrderDeliveries.Clear(); order.OrderDelivery = null;
_repositoryWrapper.SetRepository<Order>().Update(order); _repositoryWrapper.SetRepository<Order>().Update(order);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return order; return order;

View File

@ -22,18 +22,9 @@ public class OrderLDto : BaseDto<OrderLDto,Order>
public List<OrderProductSDto> OrderProducts { get; set; } = new(); public List<OrderProductSDto> OrderProducts { get; set; } = new();
public List<OrderDeliverySDto> OrderDeliveries { get; set; } = new();
public List<PaymentSDto> Payments { get; set; } = new(); public List<PaymentSDto> Payments { get; set; } = new();
public OrderDeliverySDto OrderDelivery
{ public OrderDeliverySDto? OrderDelivery { get; internal set; }
get
{
if (OrderDeliveries.Count > 0)
return OrderDeliveries.FirstOrDefault() ?? new OrderDeliverySDto();
return new OrderDeliverySDto();
}
}
} }

View File

@ -1,4 +1,5 @@
using NetinaShop.Domain.Entities.Pages; using NetinaShop.Domain.Entities.Pages;
using Newtonsoft.Json;
namespace NetinaShop.Domain.Dtos.SmallDtos; namespace NetinaShop.Domain.Dtos.SmallDtos;
@ -10,5 +11,7 @@ public class BasePageEntitySDto : BaseDto<BasePageEntitySDto,BasePageEntity>
public bool IsCustomPage { get; set; } public bool IsCustomPage { get; set; }
public bool IsHtmlBasePage { get; set; } public bool IsHtmlBasePage { get; set; }
public string Slug { get; set; } = string.Empty; public string Slug { get; set; } = string.Empty;
public object? Data { get; set; } public string Data { get; set; } = string.Empty;
public T GetData<T>() => JsonConvert.DeserializeObject<T>(Data);
} }

View File

@ -75,9 +75,17 @@ public partial class Order
public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId) public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId)
{ {
var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId); var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId);
OrderDeliveries.Add(orderDelivery); if (OrderDelivery != null)
orderDelivery.Id = OrderDelivery.Id;
OrderDelivery = orderDelivery;
} }
public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid orderId,Guid orderDeliveryId)
{
var orderDelivery = OrderDelivery.Create(addressId, deliveryCost, shippingId, orderId);
orderDelivery.Id = orderDeliveryId;
OrderDelivery = orderDelivery;
}
public void SetTotalPrice(double totalProductPrice, public void SetTotalPrice(double totalProductPrice,
double packingPrice, double packingPrice,
double servicePrice, double servicePrice,

View File

@ -69,9 +69,10 @@ public partial class Order : ApiEntity
public Guid UserId { get; internal set; } public Guid UserId { get; internal set; }
public ApplicationUser? User { get; internal set; } public ApplicationUser? User { get; internal set; }
public OrderDelivery? OrderDelivery { get; set; }
public List<OrderProduct> OrderProducts { get; internal set; } = new(); public List<OrderProduct> OrderProducts { get; internal set; } = new();
public List<OrderDelivery> OrderDeliveries { get; internal set; } = new();
public List<Payment> Payments { get; internal set; } = new(); public List<Payment> Payments { get; internal set; } = new();
} }

View File

@ -1,4 +1,6 @@
namespace NetinaShop.Domain.Entities.Pages; using System.Text.Json;
namespace NetinaShop.Domain.Entities.Pages;
public class BasePageEntity public class BasePageEntity
{ {

View File

@ -34,219 +34,233 @@ namespace NetinaShop.Domain.Mappers
PreparingMinute = p1.PreparingMinute, PreparingMinute = p1.PreparingMinute,
DiscountCode = p1.DiscountCode, DiscountCode = p1.DiscountCode,
User = new ApplicationUser() {PhoneNumber = p1.UserPhoneNumber}, User = new ApplicationUser() {PhoneNumber = p1.UserPhoneNumber},
OrderDelivery = p1.OrderDelivery == null ? null : new OrderDelivery()
{
AddressId = p1.OrderDelivery.AddressId,
Address = p1.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p1.OrderDelivery.Address, typeof(UserAddress)),
DeliveryCost = p1.OrderDelivery.DeliveryCost,
ShippingId = p1.OrderDelivery.ShippingId,
Shipping = new Shipping() {Id = p1.OrderDelivery.ShippingId},
OrderId = p1.OrderDelivery.OrderId,
Order = new Order() {Id = p1.OrderDelivery.OrderId},
Id = p1.OrderDelivery.Id,
CreatedAt = p1.OrderDelivery.CreatedAt
},
OrderProducts = funcMain1(p1.OrderProducts), OrderProducts = funcMain1(p1.OrderProducts),
OrderDeliveries = funcMain2(p1.OrderDeliveries), Payments = funcMain2(p1.Payments),
Payments = funcMain3(p1.Payments),
Id = p1.Id, Id = p1.Id,
CreatedAt = p1.CreatedAt CreatedAt = p1.CreatedAt
}; };
} }
public static Order AdaptTo(this OrderLDto p5, Order p6) public static Order AdaptTo(this OrderLDto p4, Order p5)
{ {
if (p5 == null) if (p4 == null)
{ {
return null; return null;
} }
Order result = p6 ?? new Order(); Order result = p5 ?? new Order();
result.FactorCode = p5.FactorCode; result.FactorCode = p4.FactorCode;
result.TotalProductsPrice = (double)p5.TotalProductsPrice; result.TotalProductsPrice = (double)p4.TotalProductsPrice;
result.PackingPrice = (double)p5.PackingPrice; result.PackingPrice = (double)p4.PackingPrice;
result.ServicePrice = (double)p5.ServicePrice; result.ServicePrice = (double)p4.ServicePrice;
result.DeliveryPrice = (double)p5.DeliveryPrice; result.DeliveryPrice = (double)p4.DeliveryPrice;
result.DiscountPrice = (double)p5.DiscountPrice; result.DiscountPrice = (double)p4.DiscountPrice;
result.TaxesPrice = (double)p5.TaxesPrice; result.TaxesPrice = (double)p4.TaxesPrice;
result.TotalPrice = (double)p5.TotalPrice; result.TotalPrice = (double)p4.TotalPrice;
result.IsPayed = p5.IsPayed; result.IsPayed = p4.IsPayed;
result.OrderStatus = p5.OrderStatus; result.OrderStatus = p4.OrderStatus;
result.DoneAt = p5.DoneAt; result.DoneAt = p4.DoneAt;
result.OrderAt = p5.OrderAt; result.OrderAt = p4.OrderAt;
result.PreparingMinute = p5.PreparingMinute; result.PreparingMinute = p4.PreparingMinute;
result.DiscountCode = p5.DiscountCode; result.DiscountCode = p4.DiscountCode;
result.User = funcMain4(new Never(), result.User, p5); result.User = funcMain3(new Never(), result.User, p4);
result.OrderProducts = funcMain5(p5.OrderProducts, result.OrderProducts); result.OrderDelivery = funcMain4(p4.OrderDelivery, result.OrderDelivery);
result.OrderDeliveries = funcMain6(p5.OrderDeliveries, result.OrderDeliveries); result.OrderProducts = funcMain7(p4.OrderProducts, result.OrderProducts);
result.Payments = funcMain7(p5.Payments, result.Payments); result.Payments = funcMain8(p4.Payments, result.Payments);
result.Id = p5.Id; result.Id = p4.Id;
result.CreatedAt = p5.CreatedAt; result.CreatedAt = p4.CreatedAt;
return result; return result;
} }
public static Expression<Func<OrderLDto, Order>> ProjectToOrder => p15 => new Order() public static Expression<Func<OrderLDto, Order>> ProjectToOrder => p18 => new Order()
{ {
FactorCode = p15.FactorCode, FactorCode = p18.FactorCode,
TotalProductsPrice = (double)p15.TotalProductsPrice, TotalProductsPrice = (double)p18.TotalProductsPrice,
PackingPrice = (double)p15.PackingPrice, PackingPrice = (double)p18.PackingPrice,
ServicePrice = (double)p15.ServicePrice, ServicePrice = (double)p18.ServicePrice,
DeliveryPrice = (double)p15.DeliveryPrice, DeliveryPrice = (double)p18.DeliveryPrice,
DiscountPrice = (double)p15.DiscountPrice, DiscountPrice = (double)p18.DiscountPrice,
TaxesPrice = (double)p15.TaxesPrice, TaxesPrice = (double)p18.TaxesPrice,
TotalPrice = (double)p15.TotalPrice, TotalPrice = (double)p18.TotalPrice,
IsPayed = p15.IsPayed, IsPayed = p18.IsPayed,
OrderStatus = p15.OrderStatus, OrderStatus = p18.OrderStatus,
DoneAt = p15.DoneAt, DoneAt = p18.DoneAt,
OrderAt = p15.OrderAt, OrderAt = p18.OrderAt,
PreparingMinute = p15.PreparingMinute, PreparingMinute = p18.PreparingMinute,
DiscountCode = p15.DiscountCode, DiscountCode = p18.DiscountCode,
User = new ApplicationUser() {PhoneNumber = p15.UserPhoneNumber}, User = new ApplicationUser() {PhoneNumber = p18.UserPhoneNumber},
OrderProducts = p15.OrderProducts.Select<OrderProductSDto, OrderProduct>(p16 => new OrderProduct() OrderDelivery = p18.OrderDelivery == null ? null : new OrderDelivery()
{ {
Count = p16.Count, AddressId = p18.OrderDelivery.AddressId,
ProductFee = p16.ProductFee, Address = p18.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p18.OrderDelivery.Address, typeof(UserAddress)),
ProductFeeWithDiscount = p16.ProductFeeWithDiscount, DeliveryCost = p18.OrderDelivery.DeliveryCost,
HasDiscount = p16.HasDiscount, ShippingId = p18.OrderDelivery.ShippingId,
ProductCost = p16.ProductCost, Shipping = new Shipping() {Id = p18.OrderDelivery.ShippingId},
PackingFee = p16.PackingFee, OrderId = p18.OrderDelivery.OrderId,
PackingCost = p16.PackingCost, Order = new Order() {Id = p18.OrderDelivery.OrderId},
OrderProductStatus = p16.OrderProductStatus, Id = p18.OrderDelivery.Id,
ProductId = p16.ProductId, CreatedAt = p18.OrderDelivery.CreatedAt
},
OrderProducts = p18.OrderProducts.Select<OrderProductSDto, OrderProduct>(p19 => new OrderProduct()
{
Count = p19.Count,
ProductFee = p19.ProductFee,
ProductFeeWithDiscount = p19.ProductFeeWithDiscount,
HasDiscount = p19.HasDiscount,
ProductCost = p19.ProductCost,
PackingFee = p19.PackingFee,
PackingCost = p19.PackingCost,
OrderProductStatus = p19.OrderProductStatus,
ProductId = p19.ProductId,
Product = new Product() Product = new Product()
{ {
Cost = p16.ProductCost, Cost = p19.ProductCost,
Id = p16.ProductId Id = p19.ProductId
}, },
OrderId = p16.OrderId, OrderId = p19.OrderId,
Order = new Order() {Id = p16.OrderId}, Order = new Order() {Id = p19.OrderId},
Id = p16.Id,
CreatedAt = p16.CreatedAt
}).ToList<OrderProduct>(),
OrderDeliveries = p15.OrderDeliveries.Select<OrderDeliverySDto, OrderDelivery>(p17 => new OrderDelivery()
{
Address = p17.Address == null ? null : (UserAddress)Convert.ChangeType((object)p17.Address, typeof(UserAddress)),
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<OrderDelivery>(),
Payments = p15.Payments.Select<PaymentSDto, Payment>(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<Payment>(),
Id = p15.Id,
CreatedAt = p15.CreatedAt
};
public static OrderLDto AdaptToLDto(this Order p19)
{
return p19 == null ? null : new OrderLDto()
{
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, Id = p19.Id,
CreatedAt = p19.CreatedAt CreatedAt = p19.CreatedAt
}).ToList<OrderProduct>(),
Payments = p18.Payments.Select<PaymentSDto, Payment>(p20 => new Payment()
{
FactorNumber = p20.FactorNumber,
Amount = p20.Amount,
Description = p20.Description,
TransactionCode = p20.TransactionCode,
CardPan = p20.CardPan,
Authority = p20.Authority,
Type = p20.Type,
Status = p20.Status,
OrderId = p20.OrderId,
Order = new Order() {Id = p20.OrderId},
UserId = p20.UserId,
User = new ApplicationUser()
{
Id = p20.UserId,
PhoneNumber = p20.UserPhoneNumber
},
Id = p20.Id,
CreatedAt = p20.CreatedAt
}).ToList<Payment>(),
Id = p18.Id,
CreatedAt = p18.CreatedAt
};
public static OrderLDto AdaptToLDto(this Order p21)
{
return p21 == null ? null : new OrderLDto()
{
FactorCode = p21.FactorCode,
TotalPrice = (long)p21.TotalPrice,
DeliveryPrice = (long)p21.DeliveryPrice,
TaxesPrice = (long)p21.TaxesPrice,
ServicePrice = (long)p21.ServicePrice,
PackingPrice = (long)p21.PackingPrice,
TotalProductsPrice = (long)p21.TotalProductsPrice,
DiscountPrice = (long)p21.DiscountPrice,
IsPayed = p21.IsPayed,
OrderStatus = p21.OrderStatus,
DoneAt = p21.DoneAt,
OrderAt = p21.OrderAt,
PreparingMinute = p21.PreparingMinute,
DiscountCode = p21.DiscountCode,
UserFullName = p21.User != null ? p21.User.FirstName + " " + p21.User.LastName : string.Empty,
UserPhoneNumber = p21.User != null ? p21.User.PhoneNumber : string.Empty,
OrderProducts = funcMain9(p21.OrderProducts),
Payments = funcMain10(p21.Payments),
OrderDelivery = p21.OrderDelivery == null ? null : new OrderDeliverySDto()
{
Address = p21.OrderDelivery.Address == null ? null : p21.OrderDelivery.Address.ToString(),
ShippingMethod = p21.OrderDelivery.Shipping != null ? p21.OrderDelivery.Shipping.Name : string.Empty,
DeliveryCost = p21.OrderDelivery.DeliveryCost,
AddressId = p21.OrderDelivery.AddressId,
OrderId = p21.OrderDelivery.OrderId,
ShippingId = p21.OrderDelivery.ShippingId,
Id = p21.OrderDelivery.Id,
CreatedAt = p21.OrderDelivery.CreatedAt
},
Id = p21.Id,
CreatedAt = p21.CreatedAt
}; };
} }
public static OrderLDto AdaptTo(this Order p23, OrderLDto p24) public static OrderLDto AdaptTo(this Order p24, OrderLDto p25)
{ {
if (p23 == null) if (p24 == null)
{ {
return null; return null;
} }
OrderLDto result = p24 ?? new OrderLDto(); OrderLDto result = p25 ?? new OrderLDto();
result.FactorCode = p23.FactorCode; result.FactorCode = p24.FactorCode;
result.TotalPrice = (long)p23.TotalPrice; result.TotalPrice = (long)p24.TotalPrice;
result.DeliveryPrice = (long)p23.DeliveryPrice; result.DeliveryPrice = (long)p24.DeliveryPrice;
result.TaxesPrice = (long)p23.TaxesPrice; result.TaxesPrice = (long)p24.TaxesPrice;
result.ServicePrice = (long)p23.ServicePrice; result.ServicePrice = (long)p24.ServicePrice;
result.PackingPrice = (long)p23.PackingPrice; result.PackingPrice = (long)p24.PackingPrice;
result.TotalProductsPrice = (long)p23.TotalProductsPrice; result.TotalProductsPrice = (long)p24.TotalProductsPrice;
result.DiscountPrice = (long)p23.DiscountPrice; result.DiscountPrice = (long)p24.DiscountPrice;
result.IsPayed = p23.IsPayed; result.IsPayed = p24.IsPayed;
result.OrderStatus = p23.OrderStatus; result.OrderStatus = p24.OrderStatus;
result.DoneAt = p23.DoneAt; result.DoneAt = p24.DoneAt;
result.OrderAt = p23.OrderAt; result.OrderAt = p24.OrderAt;
result.PreparingMinute = p23.PreparingMinute; result.PreparingMinute = p24.PreparingMinute;
result.DiscountCode = p23.DiscountCode; result.DiscountCode = p24.DiscountCode;
result.UserFullName = p23.User != null ? p23.User.FirstName + " " + p23.User.LastName : string.Empty; result.UserFullName = p24.User != null ? p24.User.FirstName + " " + p24.User.LastName : string.Empty;
result.UserPhoneNumber = p23.User != null ? p23.User.PhoneNumber : string.Empty; result.UserPhoneNumber = p24.User != null ? p24.User.PhoneNumber : string.Empty;
result.OrderProducts = funcMain11(p23.OrderProducts, result.OrderProducts); result.OrderProducts = funcMain11(p24.OrderProducts, result.OrderProducts);
result.OrderDeliveries = funcMain12(p23.OrderDeliveries, result.OrderDeliveries); result.Payments = funcMain12(p24.Payments, result.Payments);
result.Payments = funcMain13(p23.Payments, result.Payments); result.OrderDelivery = funcMain13(p24.OrderDelivery, result.OrderDelivery);
result.Id = p23.Id; result.Id = p24.Id;
result.CreatedAt = p23.CreatedAt; result.CreatedAt = p24.CreatedAt;
return result; return result;
} }
public static Expression<Func<Order, OrderLDto>> ProjectToLDto => p31 => new OrderLDto() public static Expression<Func<Order, OrderLDto>> ProjectToLDto => p32 => new OrderLDto()
{ {
FactorCode = p31.FactorCode, FactorCode = p32.FactorCode,
TotalPrice = (long)p31.TotalPrice, TotalPrice = (long)p32.TotalPrice,
DeliveryPrice = (long)p31.DeliveryPrice, DeliveryPrice = (long)p32.DeliveryPrice,
TaxesPrice = (long)p31.TaxesPrice, TaxesPrice = (long)p32.TaxesPrice,
ServicePrice = (long)p31.ServicePrice, ServicePrice = (long)p32.ServicePrice,
PackingPrice = (long)p31.PackingPrice, PackingPrice = (long)p32.PackingPrice,
TotalProductsPrice = (long)p31.TotalProductsPrice, TotalProductsPrice = (long)p32.TotalProductsPrice,
DiscountPrice = (long)p31.DiscountPrice, DiscountPrice = (long)p32.DiscountPrice,
IsPayed = p31.IsPayed, IsPayed = p32.IsPayed,
OrderStatus = p31.OrderStatus, OrderStatus = p32.OrderStatus,
DoneAt = p31.DoneAt, DoneAt = p32.DoneAt,
OrderAt = p31.OrderAt, OrderAt = p32.OrderAt,
PreparingMinute = p31.PreparingMinute, PreparingMinute = p32.PreparingMinute,
DiscountCode = p31.DiscountCode, DiscountCode = p32.DiscountCode,
UserFullName = p31.User != null ? p31.User.FirstName + " " + p31.User.LastName : string.Empty, UserFullName = p32.User != null ? p32.User.FirstName + " " + p32.User.LastName : string.Empty,
UserPhoneNumber = p31.User != null ? p31.User.PhoneNumber : string.Empty, UserPhoneNumber = p32.User != null ? p32.User.PhoneNumber : string.Empty,
OrderProducts = p31.OrderProducts.Select<OrderProduct, OrderProductSDto>(p32 => new OrderProductSDto() OrderProducts = p32.OrderProducts.Select<OrderProduct, OrderProductSDto>(p33 => new OrderProductSDto()
{ {
Count = p32.Count, Count = p33.Count,
ProductFee = p32.ProductFee, ProductFee = p33.ProductFee,
ProductFeeWithDiscount = p32.ProductFeeWithDiscount, ProductFeeWithDiscount = p33.ProductFeeWithDiscount,
HasDiscount = p32.HasDiscount, HasDiscount = p33.HasDiscount,
ProductCost = p32.ProductCost, ProductCost = p33.ProductCost,
PackingFee = p32.PackingFee, PackingFee = p33.PackingFee,
PackingCost = p32.PackingCost, PackingCost = p33.PackingCost,
OrderProductStatus = p32.OrderProductStatus, OrderProductStatus = p33.OrderProductStatus,
ProductId = p32.ProductId, ProductId = p33.ProductId,
ProductName = p32.Product != null ? p32.Product.PersianName : string.Empty, ProductName = p33.Product != null ? p33.Product.PersianName : string.Empty,
OrderId = p32.OrderId,
Id = p32.Id,
CreatedAt = p32.CreatedAt
}).ToList<OrderProductSDto>(),
OrderDeliveries = p31.OrderDeliveries.Select<OrderDelivery, OrderDeliverySDto>(p33 => new OrderDeliverySDto()
{
Address = p33.Address == null ? null : p33.Address.ToString(),
ShippingMethod = p33.Shipping != null ? p33.Shipping.Name : string.Empty,
OrderId = p33.OrderId, OrderId = p33.OrderId,
ShippingId = p33.ShippingId,
Id = p33.Id, Id = p33.Id,
CreatedAt = p33.CreatedAt CreatedAt = p33.CreatedAt
}).ToList<OrderDeliverySDto>(), }).ToList<OrderProductSDto>(),
Payments = p31.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto() Payments = p32.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto()
{ {
FactorNumber = p34.FactorNumber, FactorNumber = p34.FactorNumber,
Amount = p34.Amount, Amount = p34.Amount,
@ -263,8 +277,19 @@ namespace NetinaShop.Domain.Mappers
Id = p34.Id, Id = p34.Id,
CreatedAt = p34.CreatedAt CreatedAt = p34.CreatedAt
}).ToList<PaymentSDto>(), }).ToList<PaymentSDto>(),
Id = p31.Id, OrderDelivery = p32.OrderDelivery == null ? null : new OrderDeliverySDto()
CreatedAt = p31.CreatedAt {
Address = p32.OrderDelivery.Address == null ? null : p32.OrderDelivery.Address.ToString(),
ShippingMethod = p32.OrderDelivery.Shipping != null ? p32.OrderDelivery.Shipping.Name : string.Empty,
DeliveryCost = p32.OrderDelivery.DeliveryCost,
AddressId = p32.OrderDelivery.AddressId,
OrderId = p32.OrderDelivery.OrderId,
ShippingId = p32.OrderDelivery.ShippingId,
Id = p32.OrderDelivery.Id,
CreatedAt = p32.OrderDelivery.CreatedAt
},
Id = p32.Id,
CreatedAt = p32.CreatedAt
}; };
public static Order AdaptToOrder(this OrderSDto p35) public static Order AdaptToOrder(this OrderSDto p35)
{ {
@ -447,50 +472,20 @@ namespace NetinaShop.Domain.Mappers
} }
private static List<OrderDelivery> funcMain2(List<OrderDeliverySDto> p3) private static List<Payment> funcMain2(List<PaymentSDto> p3)
{ {
if (p3 == null) if (p3 == null)
{ {
return null; return null;
} }
List<OrderDelivery> result = new List<OrderDelivery>(p3.Count); List<Payment> result = new List<Payment>(p3.Count);
int i = 0; int i = 0;
int len = p3.Count; int len = p3.Count;
while (i < len) while (i < len)
{ {
OrderDeliverySDto item = p3[i]; PaymentSDto item = p3[i];
result.Add(item == null ? null : new OrderDelivery()
{
Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)),
ShippingId = item.ShippingId,
Shipping = new Shipping() {Id = item.ShippingId},
OrderId = item.OrderId,
Order = new Order() {Id = item.OrderId},
Id = item.Id,
CreatedAt = item.CreatedAt
});
i++;
}
return result;
}
private static List<Payment> funcMain3(List<PaymentSDto> p4)
{
if (p4 == null)
{
return null;
}
List<Payment> result = new List<Payment>(p4.Count);
int i = 0;
int len = p4.Count;
while (i < len)
{
PaymentSDto item = p4[i];
result.Add(item == null ? null : new Payment() result.Add(item == null ? null : new Payment()
{ {
FactorNumber = item.FactorNumber, FactorNumber = item.FactorNumber,
@ -518,29 +513,50 @@ namespace NetinaShop.Domain.Mappers
} }
private static ApplicationUser funcMain4(Never p7, ApplicationUser p8, OrderLDto p5) private static ApplicationUser funcMain3(Never p6, ApplicationUser p7, OrderLDto p4)
{ {
ApplicationUser result = p8 ?? new ApplicationUser(); ApplicationUser result = p7 ?? new ApplicationUser();
result.PhoneNumber = p5.UserPhoneNumber; result.PhoneNumber = p4.UserPhoneNumber;
return result; return result;
} }
private static List<OrderProduct> funcMain5(List<OrderProductSDto> p9, List<OrderProduct> p10) private static OrderDelivery funcMain4(OrderDeliverySDto p8, OrderDelivery p9)
{ {
if (p9 == null) if (p8 == null)
{ {
return null; return null;
} }
List<OrderProduct> result = new List<OrderProduct>(p9.Count); OrderDelivery result = p9 ?? new OrderDelivery();
result.AddressId = p8.AddressId;
result.Address = p8.Address == null ? null : (UserAddress)Convert.ChangeType((object)p8.Address, typeof(UserAddress));
result.DeliveryCost = p8.DeliveryCost;
result.ShippingId = p8.ShippingId;
result.Shipping = funcMain5(new Never(), result.Shipping, p8);
result.OrderId = p8.OrderId;
result.Order = funcMain6(new Never(), result.Order, p8);
result.Id = p8.Id;
result.CreatedAt = p8.CreatedAt;
return result;
}
private static List<OrderProduct> funcMain7(List<OrderProductSDto> p14, List<OrderProduct> p15)
{
if (p14 == null)
{
return null;
}
List<OrderProduct> result = new List<OrderProduct>(p14.Count);
int i = 0; int i = 0;
int len = p9.Count; int len = p14.Count;
while (i < len) while (i < len)
{ {
OrderProductSDto item = p9[i]; OrderProductSDto item = p14[i];
result.Add(item == null ? null : new OrderProduct() result.Add(item == null ? null : new OrderProduct()
{ {
Count = item.Count, Count = item.Count,
@ -568,50 +584,20 @@ namespace NetinaShop.Domain.Mappers
} }
private static List<OrderDelivery> funcMain6(List<OrderDeliverySDto> p11, List<OrderDelivery> p12) private static List<Payment> funcMain8(List<PaymentSDto> p16, List<Payment> p17)
{ {
if (p11 == null) if (p16 == null)
{ {
return null; return null;
} }
List<OrderDelivery> result = new List<OrderDelivery>(p11.Count); List<Payment> result = new List<Payment>(p16.Count);
int i = 0; int i = 0;
int len = p11.Count; int len = p16.Count;
while (i < len) while (i < len)
{ {
OrderDeliverySDto item = p11[i]; PaymentSDto item = p16[i];
result.Add(item == null ? null : new OrderDelivery()
{
Address = item.Address == null ? null : (UserAddress)Convert.ChangeType((object)item.Address, typeof(UserAddress)),
ShippingId = item.ShippingId,
Shipping = new Shipping() {Id = item.ShippingId},
OrderId = item.OrderId,
Order = new Order() {Id = item.OrderId},
Id = item.Id,
CreatedAt = item.CreatedAt
});
i++;
}
return result;
}
private static List<Payment> funcMain7(List<PaymentSDto> p13, List<Payment> p14)
{
if (p13 == null)
{
return null;
}
List<Payment> result = new List<Payment>(p13.Count);
int i = 0;
int len = p13.Count;
while (i < len)
{
PaymentSDto item = p13[i];
result.Add(item == null ? null : new Payment() result.Add(item == null ? null : new Payment()
{ {
FactorNumber = item.FactorNumber, FactorNumber = item.FactorNumber,
@ -639,122 +625,20 @@ namespace NetinaShop.Domain.Mappers
} }
private static List<OrderProductSDto> funcMain8(List<OrderProduct> p20) private static List<OrderProductSDto> funcMain9(List<OrderProduct> p22)
{
if (p20 == null)
{
return null;
}
List<OrderProductSDto> result = new List<OrderProductSDto>(p20.Count);
int i = 0;
int len = p20.Count;
while (i < len)
{
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<OrderDeliverySDto> funcMain9(List<OrderDelivery> p21)
{
if (p21 == null)
{
return null;
}
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(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 == null ? null : item.Address.ToString(),
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<PaymentSDto> funcMain10(List<Payment> p22)
{ {
if (p22 == null) if (p22 == null)
{ {
return null; return null;
} }
List<PaymentSDto> result = new List<PaymentSDto>(p22.Count); List<OrderProductSDto> result = new List<OrderProductSDto>(p22.Count);
int i = 0; int i = 0;
int len = p22.Count; int len = p22.Count;
while (i < len) while (i < len)
{ {
Payment item = p22[i]; OrderProduct 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<OrderProductSDto> funcMain11(List<OrderProduct> p25, List<OrderProductSDto> p26)
{
if (p25 == null)
{
return null;
}
List<OrderProductSDto> result = new List<OrderProductSDto>(p25.Count);
int i = 0;
int len = p25.Count;
while (i < len)
{
OrderProduct item = p25[i];
result.Add(item == null ? null : new OrderProductSDto() result.Add(item == null ? null : new OrderProductSDto()
{ {
Count = item.Count, Count = item.Count,
@ -777,49 +661,20 @@ namespace NetinaShop.Domain.Mappers
} }
private static List<OrderDeliverySDto> funcMain12(List<OrderDelivery> p27, List<OrderDeliverySDto> p28) private static List<PaymentSDto> funcMain10(List<Payment> p23)
{ {
if (p27 == null) if (p23 == null)
{ {
return null; return null;
} }
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p27.Count); List<PaymentSDto> result = new List<PaymentSDto>(p23.Count);
int i = 0; int i = 0;
int len = p27.Count; int len = p23.Count;
while (i < len) while (i < len)
{ {
OrderDelivery item = p27[i]; Payment item = p23[i];
result.Add(item == null ? null : new OrderDeliverySDto()
{
Address = item.Address == null ? null : item.Address.ToString(),
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<PaymentSDto> funcMain13(List<Payment> p29, List<PaymentSDto> p30)
{
if (p29 == null)
{
return null;
}
List<PaymentSDto> result = new List<PaymentSDto>(p29.Count);
int i = 0;
int len = p29.Count;
while (i < len)
{
Payment item = p29[i];
result.Add(item == null ? null : new PaymentSDto() result.Add(item == null ? null : new PaymentSDto()
{ {
FactorNumber = item.FactorNumber, FactorNumber = item.FactorNumber,
@ -843,6 +698,99 @@ namespace NetinaShop.Domain.Mappers
} }
private static List<OrderProductSDto> funcMain11(List<OrderProduct> p26, List<OrderProductSDto> p27)
{
if (p26 == null)
{
return null;
}
List<OrderProductSDto> result = new List<OrderProductSDto>(p26.Count);
int i = 0;
int len = p26.Count;
while (i < len)
{
OrderProduct item = p26[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<PaymentSDto> funcMain12(List<Payment> p28, List<PaymentSDto> p29)
{
if (p28 == null)
{
return null;
}
List<PaymentSDto> result = new List<PaymentSDto>(p28.Count);
int i = 0;
int len = p28.Count;
while (i < len)
{
Payment item = p28[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 OrderDeliverySDto funcMain13(OrderDelivery p30, OrderDeliverySDto p31)
{
if (p30 == null)
{
return null;
}
OrderDeliverySDto result = p31 ?? new OrderDeliverySDto();
result.Address = p30.Address == null ? null : p30.Address.ToString();
result.ShippingMethod = p30.Shipping != null ? p30.Shipping.Name : string.Empty;
result.DeliveryCost = p30.DeliveryCost;
result.AddressId = p30.AddressId;
result.OrderId = p30.OrderId;
result.ShippingId = p30.ShippingId;
result.Id = p30.Id;
result.CreatedAt = p30.CreatedAt;
return result;
}
private static ApplicationUser funcMain14(Never p38, ApplicationUser p39, OrderSDto p36) private static ApplicationUser funcMain14(Never p38, ApplicationUser p39, OrderSDto p36)
{ {
ApplicationUser result = p39 ?? new ApplicationUser(); ApplicationUser result = p39 ?? new ApplicationUser();
@ -852,5 +800,23 @@ namespace NetinaShop.Domain.Mappers
return result; return result;
} }
private static Shipping funcMain5(Never p10, Shipping p11, OrderDeliverySDto p8)
{
Shipping result = p11 ?? new Shipping();
result.Id = p8.ShippingId;
return result;
}
private static Order funcMain6(Never p12, Order p13, OrderDeliverySDto p8)
{
Order result = p13 ?? new Order();
result.Id = p8.OrderId;
return result;
}
} }
} }

View File

@ -27,12 +27,13 @@ public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, Order>
orderProducts.ForEach(op => order.AddOrderProduct(op)); orderProducts.ForEach(op => order.AddOrderProduct(op));
var orderDeliveries = await _repositoryWrapper.SetRepository<OrderDelivery>() var orderDelivery= await _repositoryWrapper.SetRepository<OrderDelivery>()
.TableNoTracking .TableNoTracking
.Where(od => od.OrderId == request.Id) .FirstOrDefaultAsync(od => od.OrderId == request.Id, cancellationToken);
.ToListAsync(cancellationToken); if (orderDelivery != null)
{
orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.AddressId,od.DeliveryCost,od.ShippingId,od.OrderId)); order.AddOrderDelivery(orderDelivery.AddressId, orderDelivery.DeliveryCost, orderDelivery.ShippingId, orderDelivery.OrderId, orderDelivery.Id);
}
return order; return order;
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class EditOrderDelivey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_OrderDeliveries_OrderId",
schema: "public",
table: "OrderDeliveries");
migrationBuilder.CreateIndex(
name: "IX_OrderDeliveries_OrderId",
schema: "public",
table: "OrderDeliveries",
column: "OrderId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_OrderDeliveries_OrderId",
schema: "public",
table: "OrderDeliveries");
migrationBuilder.CreateIndex(
name: "IX_OrderDeliveries_OrderId",
schema: "public",
table: "OrderDeliveries",
column: "OrderId");
}
}
}

View File

@ -571,7 +571,8 @@ namespace NetinaShop.Repository.Migrations
b.HasIndex("AddressId"); b.HasIndex("AddressId");
b.HasIndex("OrderId"); b.HasIndex("OrderId")
.IsUnique();
b.HasIndex("ShippingId"); b.HasIndex("ShippingId");
@ -1432,8 +1433,8 @@ namespace NetinaShop.Repository.Migrations
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order") b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
.WithMany("OrderDeliveries") .WithOne("OrderDelivery")
.HasForeignKey("OrderId") .HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId")
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping") b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
@ -1635,7 +1636,7 @@ namespace NetinaShop.Repository.Migrations
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b => modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b =>
{ {
b.Navigation("OrderDeliveries"); b.Navigation("OrderDelivery");
b.Navigation("OrderProducts"); b.Navigation("OrderProducts");