Api/Netina.Domain/Mappers/CustomerMapper.g.cs

83 lines
3.5 KiB
C#

using System;
using System.Linq.Expressions;
using Netina.Domain.Dtos.SmallDtos;
using Netina.Domain.Entities.Users;
using Netina.Domain.Enums;
namespace Netina.Domain.Mappers
{
public static partial class CustomerMapper
{
public static Customer AdaptToCustomer(this CustomerSDto p1)
{
return p1 == null ? null : new Customer()
{
Id = p1.Id,
CreatedAt = p1.CreatedAt
};
}
public static Customer AdaptTo(this CustomerSDto p2, Customer p3)
{
if (p2 == null)
{
return null;
}
Customer result = p3 ?? new Customer();
result.Id = p2.Id;
result.CreatedAt = p2.CreatedAt;
return result;
}
public static CustomerSDto AdaptToSDto(this Customer p4)
{
return p4 == null ? null : new CustomerSDto()
{
PhoneNumber = p4.User != null ? p4.User.PhoneNumber : string.Empty,
FirstName = p4.User != null ? p4.User.FirstName : string.Empty,
LastName = p4.User != null ? p4.User.LastName : string.Empty,
BirthDate = p4.User != null ? p4.User.BirthDate : DateTime.MinValue,
Gender = p4.User != null ? p4.User.Gender : Gender.Male,
SignUpStatus = p4.User != null ? p4.User.SignUpStatus : SignUpStatus.StartSignOn,
NationalId = p4.User != null ? p4.User.NationalId : string.Empty,
Email = p4.User != null ? p4.User.Email : string.Empty,
Id = p4.Id,
CreatedAt = p4.CreatedAt
};
}
public static CustomerSDto AdaptTo(this Customer p5, CustomerSDto p6)
{
if (p5 == null)
{
return null;
}
CustomerSDto result = p6 ?? new CustomerSDto();
result.PhoneNumber = p5.User != null ? p5.User.PhoneNumber : string.Empty;
result.FirstName = p5.User != null ? p5.User.FirstName : string.Empty;
result.LastName = p5.User != null ? p5.User.LastName : string.Empty;
result.BirthDate = p5.User != null ? p5.User.BirthDate : DateTime.MinValue;
result.Gender = p5.User != null ? p5.User.Gender : Gender.Male;
result.SignUpStatus = p5.User != null ? p5.User.SignUpStatus : SignUpStatus.StartSignOn;
result.NationalId = p5.User != null ? p5.User.NationalId : string.Empty;
result.Email = p5.User != null ? p5.User.Email : string.Empty;
result.Id = p5.Id;
result.CreatedAt = p5.CreatedAt;
return result;
}
public static Expression<Func<Customer, CustomerSDto>> ProjectToSDto => p7 => new CustomerSDto()
{
PhoneNumber = p7.User != null ? p7.User.PhoneNumber : string.Empty,
FirstName = p7.User != null ? p7.User.FirstName : string.Empty,
LastName = p7.User != null ? p7.User.LastName : string.Empty,
BirthDate = p7.User != null ? p7.User.BirthDate : DateTime.MinValue,
Gender = p7.User != null ? p7.User.Gender : Gender.Male,
SignUpStatus = p7.User != null ? p7.User.SignUpStatus : SignUpStatus.StartSignOn,
NationalId = p7.User != null ? p7.User.NationalId : string.Empty,
Email = p7.User != null ? p7.User.Email : string.Empty,
Id = p7.Id,
CreatedAt = p7.CreatedAt
};
}
}