144 lines
5.2 KiB
C#
144 lines
5.2 KiB
C#
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<Func<Payment, PaymentSDto>> 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;
|
|
|
|
}
|
|
}
|
|
} |