fix : fix submit delivery and discount step , feat ver 0.5.6.14
parent
24ca6e859c
commit
4100e2f8fa
|
@ -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.Information)
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", Serilog.Events.LogEventLevel.Error)
|
||||
.CreateLogger();
|
||||
}
|
||||
}
|
|
@ -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.Repository.Repositories.Entity.Abstracts;
|
||||
|
||||
|
@ -24,11 +27,11 @@ public class PageService : IPageService
|
|||
else if (type != null)
|
||||
page = await _martenRepository.GetEntityAsync<BasePageEntity>(entity => entity.Type == type, cancellationToken);
|
||||
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
|
||||
{
|
||||
|
||||
Content = page.Content,
|
||||
Description = page.Description,
|
||||
Id = page.Id,
|
||||
|
@ -36,7 +39,7 @@ public class PageService : IPageService
|
|||
IsHtmlBasePage = page.IsHtmlBasePage,
|
||||
Name = page.Name,
|
||||
Slug = page.Slug,
|
||||
Data = JsonConvert.DeserializeObject(page.Data)
|
||||
Data = page.Data
|
||||
};
|
||||
|
||||
return dto;
|
||||
|
@ -48,9 +51,10 @@ public class PageService : IPageService
|
|||
var pages = await _martenRepository.GetEntitiesAsync<BasePageEntity>(cancellationToken);
|
||||
foreach (var page in pages)
|
||||
{
|
||||
|
||||
var type = Assembly.GetAssembly(typeof(DomainConfig))?.GetType(page.Type);
|
||||
var dto = new BasePageEntitySDto
|
||||
{
|
||||
|
||||
Content = page.Content,
|
||||
Description = page.Description,
|
||||
Id = page.Id,
|
||||
|
@ -58,7 +62,7 @@ public class PageService : IPageService
|
|||
IsHtmlBasePage = page.IsHtmlBasePage,
|
||||
Name = page.Name,
|
||||
Slug = page.Slug,
|
||||
Data = JsonConvert.DeserializeObject(page.Data)
|
||||
Data = page.Data
|
||||
};
|
||||
sDtos.Add(dto);
|
||||
}
|
||||
|
@ -77,8 +81,9 @@ public class PageService : IPageService
|
|||
Name = entity.Name,
|
||||
Type = entity.Type,
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||
|
||||
if (discount == null)
|
||||
throw new AppException("Discount not found", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("تخفیف وجود منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
|
||||
|
||||
double discountPrice = 0;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class SubmitDiscountCommandHandler : IRequestHandler<SubmitDiscountComman
|
|||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||
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);
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
using NetinaShop.Domain.Entities.Orders;
|
||||
using NetinaShop.Domain.Entities.Warehouses;
|
||||
|
||||
namespace NetinaShop.Core.EntityServices.OrderBagHandlers;
|
||||
|
||||
|
@ -14,32 +15,32 @@ public class SubmitOrderDeliveryCommandHandler : IRequestHandler<SubmitOrderDeli
|
|||
}
|
||||
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>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.ShippingId, cancellationToken);
|
||||
if (shipping == null)
|
||||
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);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
var calculatedOrder = await _mediator.Send(new CalculateOrderCommand(order.Id), cancellationToken);
|
||||
return calculatedOrder.AdaptToSDto();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
// ? (totalProductPrice / 100) * _shopSettings.ServiceFee
|
||||
// : _shopSettings.ServiceFee;
|
||||
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);
|
||||
if (!order.DiscountCode.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
|
||||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
|
||||
order.OrderProducts.Clear();
|
||||
order.OrderDeliveries.Clear();
|
||||
order.OrderDelivery = null;
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return order;
|
||||
|
|
|
@ -22,18 +22,9 @@ public class OrderLDto : BaseDto<OrderLDto,Order>
|
|||
|
||||
public List<OrderProductSDto> OrderProducts { get; set; } = new();
|
||||
|
||||
public List<OrderDeliverySDto> OrderDeliveries { get; set; } = new();
|
||||
|
||||
public List<PaymentSDto> Payments { get; set; } = new();
|
||||
|
||||
public OrderDeliverySDto OrderDelivery
|
||||
{
|
||||
get
|
||||
{
|
||||
if (OrderDeliveries.Count > 0)
|
||||
return OrderDeliveries.FirstOrDefault() ?? new OrderDeliverySDto();
|
||||
return new OrderDeliverySDto();
|
||||
}
|
||||
}
|
||||
|
||||
public OrderDeliverySDto? OrderDelivery { get; internal set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using NetinaShop.Domain.Entities.Pages;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NetinaShop.Domain.Dtos.SmallDtos;
|
||||
|
||||
|
@ -10,5 +11,7 @@ public class BasePageEntitySDto : BaseDto<BasePageEntitySDto,BasePageEntity>
|
|||
public bool IsCustomPage { get; set; }
|
||||
public bool IsHtmlBasePage { get; set; }
|
||||
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);
|
||||
}
|
|
@ -75,9 +75,17 @@ public partial class Order
|
|||
public void AddOrderDelivery(Guid addressId, double deliveryCost, Guid shippingId, Guid 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,
|
||||
double packingPrice,
|
||||
double servicePrice,
|
||||
|
|
|
@ -69,9 +69,10 @@ public partial class Order : ApiEntity
|
|||
public Guid UserId { get; internal set; }
|
||||
public ApplicationUser? User { get; internal set; }
|
||||
|
||||
public OrderDelivery? OrderDelivery { get; set; }
|
||||
|
||||
public List<OrderProduct> OrderProducts { get; internal set; } = new();
|
||||
|
||||
public List<OrderDelivery> OrderDeliveries { get; internal set; } = new();
|
||||
|
||||
public List<Payment> Payments { get; internal set; } = new();
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
namespace NetinaShop.Domain.Entities.Pages;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace NetinaShop.Domain.Entities.Pages;
|
||||
|
||||
public class BasePageEntity
|
||||
{
|
||||
|
|
|
@ -34,219 +34,233 @@ namespace NetinaShop.Domain.Mappers
|
|||
PreparingMinute = p1.PreparingMinute,
|
||||
DiscountCode = p1.DiscountCode,
|
||||
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),
|
||||
OrderDeliveries = funcMain2(p1.OrderDeliveries),
|
||||
Payments = funcMain3(p1.Payments),
|
||||
Payments = funcMain2(p1.Payments),
|
||||
Id = p1.Id,
|
||||
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;
|
||||
}
|
||||
Order result = p6 ?? new Order();
|
||||
Order result = p5 ?? new Order();
|
||||
|
||||
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;
|
||||
result.FactorCode = p4.FactorCode;
|
||||
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.User = funcMain3(new Never(), result.User, p4);
|
||||
result.OrderDelivery = funcMain4(p4.OrderDelivery, result.OrderDelivery);
|
||||
result.OrderProducts = funcMain7(p4.OrderProducts, result.OrderProducts);
|
||||
result.Payments = funcMain8(p4.Payments, result.Payments);
|
||||
result.Id = p4.Id;
|
||||
result.CreatedAt = p4.CreatedAt;
|
||||
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,
|
||||
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<OrderProductSDto, OrderProduct>(p16 => new OrderProduct()
|
||||
FactorCode = p18.FactorCode,
|
||||
TotalProductsPrice = (double)p18.TotalProductsPrice,
|
||||
PackingPrice = (double)p18.PackingPrice,
|
||||
ServicePrice = (double)p18.ServicePrice,
|
||||
DeliveryPrice = (double)p18.DeliveryPrice,
|
||||
DiscountPrice = (double)p18.DiscountPrice,
|
||||
TaxesPrice = (double)p18.TaxesPrice,
|
||||
TotalPrice = (double)p18.TotalPrice,
|
||||
IsPayed = p18.IsPayed,
|
||||
OrderStatus = p18.OrderStatus,
|
||||
DoneAt = p18.DoneAt,
|
||||
OrderAt = p18.OrderAt,
|
||||
PreparingMinute = p18.PreparingMinute,
|
||||
DiscountCode = p18.DiscountCode,
|
||||
User = new ApplicationUser() {PhoneNumber = p18.UserPhoneNumber},
|
||||
OrderDelivery = p18.OrderDelivery == null ? null : new OrderDelivery()
|
||||
{
|
||||
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,
|
||||
AddressId = p18.OrderDelivery.AddressId,
|
||||
Address = p18.OrderDelivery.Address == null ? null : (UserAddress)Convert.ChangeType((object)p18.OrderDelivery.Address, typeof(UserAddress)),
|
||||
DeliveryCost = p18.OrderDelivery.DeliveryCost,
|
||||
ShippingId = p18.OrderDelivery.ShippingId,
|
||||
Shipping = new Shipping() {Id = p18.OrderDelivery.ShippingId},
|
||||
OrderId = p18.OrderDelivery.OrderId,
|
||||
Order = new Order() {Id = p18.OrderDelivery.OrderId},
|
||||
Id = p18.OrderDelivery.Id,
|
||||
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()
|
||||
{
|
||||
Cost = p16.ProductCost,
|
||||
Id = p16.ProductId
|
||||
Cost = p19.ProductCost,
|
||||
Id = p19.ProductId
|
||||
},
|
||||
OrderId = p16.OrderId,
|
||||
Order = new Order() {Id = p16.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),
|
||||
OrderId = p19.OrderId,
|
||||
Order = new Order() {Id = p19.OrderId},
|
||||
Id = p19.Id,
|
||||
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;
|
||||
}
|
||||
OrderLDto result = p24 ?? new OrderLDto();
|
||||
OrderLDto result = p25 ?? new OrderLDto();
|
||||
|
||||
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;
|
||||
result.FactorCode = p24.FactorCode;
|
||||
result.TotalPrice = (long)p24.TotalPrice;
|
||||
result.DeliveryPrice = (long)p24.DeliveryPrice;
|
||||
result.TaxesPrice = (long)p24.TaxesPrice;
|
||||
result.ServicePrice = (long)p24.ServicePrice;
|
||||
result.PackingPrice = (long)p24.PackingPrice;
|
||||
result.TotalProductsPrice = (long)p24.TotalProductsPrice;
|
||||
result.DiscountPrice = (long)p24.DiscountPrice;
|
||||
result.IsPayed = p24.IsPayed;
|
||||
result.OrderStatus = p24.OrderStatus;
|
||||
result.DoneAt = p24.DoneAt;
|
||||
result.OrderAt = p24.OrderAt;
|
||||
result.PreparingMinute = p24.PreparingMinute;
|
||||
result.DiscountCode = p24.DiscountCode;
|
||||
result.UserFullName = p24.User != null ? p24.User.FirstName + " " + p24.User.LastName : string.Empty;
|
||||
result.UserPhoneNumber = p24.User != null ? p24.User.PhoneNumber : string.Empty;
|
||||
result.OrderProducts = funcMain11(p24.OrderProducts, result.OrderProducts);
|
||||
result.Payments = funcMain12(p24.Payments, result.Payments);
|
||||
result.OrderDelivery = funcMain13(p24.OrderDelivery, result.OrderDelivery);
|
||||
result.Id = p24.Id;
|
||||
result.CreatedAt = p24.CreatedAt;
|
||||
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,
|
||||
TotalPrice = (long)p31.TotalPrice,
|
||||
DeliveryPrice = (long)p31.DeliveryPrice,
|
||||
TaxesPrice = (long)p31.TaxesPrice,
|
||||
ServicePrice = (long)p31.ServicePrice,
|
||||
PackingPrice = (long)p31.PackingPrice,
|
||||
TotalProductsPrice = (long)p31.TotalProductsPrice,
|
||||
DiscountPrice = (long)p31.DiscountPrice,
|
||||
IsPayed = p31.IsPayed,
|
||||
OrderStatus = p31.OrderStatus,
|
||||
DoneAt = p31.DoneAt,
|
||||
OrderAt = p31.OrderAt,
|
||||
PreparingMinute = p31.PreparingMinute,
|
||||
DiscountCode = p31.DiscountCode,
|
||||
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<OrderProduct, OrderProductSDto>(p32 => new OrderProductSDto()
|
||||
FactorCode = p32.FactorCode,
|
||||
TotalPrice = (long)p32.TotalPrice,
|
||||
DeliveryPrice = (long)p32.DeliveryPrice,
|
||||
TaxesPrice = (long)p32.TaxesPrice,
|
||||
ServicePrice = (long)p32.ServicePrice,
|
||||
PackingPrice = (long)p32.PackingPrice,
|
||||
TotalProductsPrice = (long)p32.TotalProductsPrice,
|
||||
DiscountPrice = (long)p32.DiscountPrice,
|
||||
IsPayed = p32.IsPayed,
|
||||
OrderStatus = p32.OrderStatus,
|
||||
DoneAt = p32.DoneAt,
|
||||
OrderAt = p32.OrderAt,
|
||||
PreparingMinute = p32.PreparingMinute,
|
||||
DiscountCode = p32.DiscountCode,
|
||||
UserFullName = p32.User != null ? p32.User.FirstName + " " + p32.User.LastName : string.Empty,
|
||||
UserPhoneNumber = p32.User != null ? p32.User.PhoneNumber : string.Empty,
|
||||
OrderProducts = p32.OrderProducts.Select<OrderProduct, OrderProductSDto>(p33 => 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<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,
|
||||
Count = p33.Count,
|
||||
ProductFee = p33.ProductFee,
|
||||
ProductFeeWithDiscount = p33.ProductFeeWithDiscount,
|
||||
HasDiscount = p33.HasDiscount,
|
||||
ProductCost = p33.ProductCost,
|
||||
PackingFee = p33.PackingFee,
|
||||
PackingCost = p33.PackingCost,
|
||||
OrderProductStatus = p33.OrderProductStatus,
|
||||
ProductId = p33.ProductId,
|
||||
ProductName = p33.Product != null ? p33.Product.PersianName : string.Empty,
|
||||
OrderId = p33.OrderId,
|
||||
ShippingId = p33.ShippingId,
|
||||
Id = p33.Id,
|
||||
CreatedAt = p33.CreatedAt
|
||||
}).ToList<OrderDeliverySDto>(),
|
||||
Payments = p31.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto()
|
||||
}).ToList<OrderProductSDto>(),
|
||||
Payments = p32.Payments.Select<Payment, PaymentSDto>(p34 => new PaymentSDto()
|
||||
{
|
||||
FactorNumber = p34.FactorNumber,
|
||||
Amount = p34.Amount,
|
||||
|
@ -263,8 +277,19 @@ namespace NetinaShop.Domain.Mappers
|
|||
Id = p34.Id,
|
||||
CreatedAt = p34.CreatedAt
|
||||
}).ToList<PaymentSDto>(),
|
||||
Id = p31.Id,
|
||||
CreatedAt = p31.CreatedAt
|
||||
OrderDelivery = p32.OrderDelivery == null ? null : new OrderDeliverySDto()
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<OrderDelivery> result = new List<OrderDelivery>(p3.Count);
|
||||
List<Payment> result = new List<Payment>(p3.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p3.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDeliverySDto item = p3[i];
|
||||
result.Add(item == null ? null : new OrderDelivery()
|
||||
{
|
||||
Address = item.Address == 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];
|
||||
PaymentSDto item = p3[i];
|
||||
result.Add(item == null ? null : new Payment()
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 len = p9.Count;
|
||||
int len = p14.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderProductSDto item = p9[i];
|
||||
OrderProductSDto item = p14[i];
|
||||
result.Add(item == null ? null : new OrderProduct()
|
||||
{
|
||||
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;
|
||||
}
|
||||
List<OrderDelivery> result = new List<OrderDelivery>(p11.Count);
|
||||
List<Payment> result = new List<Payment>(p16.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p11.Count;
|
||||
int len = p16.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDeliverySDto item = p11[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];
|
||||
PaymentSDto item = p16[i];
|
||||
result.Add(item == null ? null : new Payment()
|
||||
{
|
||||
FactorNumber = item.FactorNumber,
|
||||
|
@ -639,122 +625,20 @@ namespace NetinaShop.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<OrderProductSDto> funcMain8(List<OrderProduct> p20)
|
||||
{
|
||||
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)
|
||||
private static List<OrderProductSDto> funcMain9(List<OrderProduct> p22)
|
||||
{
|
||||
if (p22 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p22.Count);
|
||||
List<OrderProductSDto> result = new List<OrderProductSDto>(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<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];
|
||||
OrderProduct item = p22[i];
|
||||
result.Add(item == null ? null : new OrderProductSDto()
|
||||
{
|
||||
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;
|
||||
}
|
||||
List<OrderDeliverySDto> result = new List<OrderDeliverySDto>(p27.Count);
|
||||
List<PaymentSDto> result = new List<PaymentSDto>(p23.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p27.Count;
|
||||
int len = p23.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
OrderDelivery item = p27[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];
|
||||
Payment item = p23[i];
|
||||
result.Add(item == null ? null : new PaymentSDto()
|
||||
{
|
||||
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)
|
||||
{
|
||||
ApplicationUser result = p39 ?? new ApplicationUser();
|
||||
|
@ -852,5 +800,23 @@ namespace NetinaShop.Domain.Mappers
|
|||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,12 +27,13 @@ public class GetOrderQueryHandler : IRequestHandler<GetOrderQuery, Order>
|
|||
|
||||
orderProducts.ForEach(op => order.AddOrderProduct(op));
|
||||
|
||||
var orderDeliveries = await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
var orderDelivery= await _repositoryWrapper.SetRepository<OrderDelivery>()
|
||||
.TableNoTracking
|
||||
.Where(od => od.OrderId == request.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
orderDeliveries.ForEach(od=>order.AddOrderDelivery(od.AddressId,od.DeliveryCost,od.ShippingId,od.OrderId));
|
||||
.FirstOrDefaultAsync(od => od.OrderId == request.Id, cancellationToken);
|
||||
if (orderDelivery != null)
|
||||
{
|
||||
order.AddOrderDelivery(orderDelivery.AddressId, orderDelivery.DeliveryCost, orderDelivery.ShippingId, orderDelivery.OrderId, orderDelivery.Id);
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -571,7 +571,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
b.HasIndex("OrderId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ShippingId");
|
||||
|
||||
|
@ -1432,8 +1433,8 @@ namespace NetinaShop.Repository.Migrations
|
|||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("NetinaShop.Domain.Entities.Orders.Order", "Order")
|
||||
.WithMany("OrderDeliveries")
|
||||
.HasForeignKey("OrderId")
|
||||
.WithOne("OrderDelivery")
|
||||
.HasForeignKey("NetinaShop.Domain.Entities.Orders.OrderDelivery", "OrderId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
b.HasOne("NetinaShop.Domain.Entities.Warehouses.Shipping", "Shipping")
|
||||
|
@ -1635,7 +1636,7 @@ namespace NetinaShop.Repository.Migrations
|
|||
|
||||
modelBuilder.Entity("NetinaShop.Domain.Entities.Orders.Order", b =>
|
||||
{
|
||||
b.Navigation("OrderDeliveries");
|
||||
b.Navigation("OrderDelivery");
|
||||
|
||||
b.Navigation("OrderProducts");
|
||||
|
||||
|
|
Loading…
Reference in New Issue