130 lines
4.8 KiB
C#
130 lines
4.8 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using DocuMed.Domain.Dtos.SmallDtos;
|
|
using DocuMed.Domain.Entities.User;
|
|
|
|
namespace DocuMed.Domain.Mappers
|
|
{
|
|
public static partial class ApplicationUserMapper
|
|
{
|
|
public static ApplicationUser AdaptToApplicationUser(this ApplicationUserSDto p1)
|
|
{
|
|
return p1 == null ? null : new ApplicationUser()
|
|
{
|
|
FirstName = p1.FirstName,
|
|
LastName = p1.LastName,
|
|
NationalId = p1.NationalId,
|
|
BirthDate = p1.BirthDate,
|
|
Gender = p1.Gender,
|
|
SignUpStatus = p1.SignUpStatus,
|
|
Id = p1.Id,
|
|
UserName = p1.UserName,
|
|
Email = p1.Email,
|
|
PhoneNumber = p1.PhoneNumber,
|
|
PhoneNumberConfirmed = p1.PhoneNumberConfirmed
|
|
};
|
|
}
|
|
public static ApplicationUser AdaptTo(this ApplicationUserSDto p2, ApplicationUser p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ApplicationUser result = p3 ?? new ApplicationUser();
|
|
|
|
result.FirstName = p2.FirstName;
|
|
result.LastName = p2.LastName;
|
|
result.NationalId = p2.NationalId;
|
|
result.BirthDate = p2.BirthDate;
|
|
result.Gender = p2.Gender;
|
|
result.SignUpStatus = p2.SignUpStatus;
|
|
result.Id = p2.Id;
|
|
result.UserName = p2.UserName;
|
|
result.Email = p2.Email;
|
|
result.PhoneNumber = p2.PhoneNumber;
|
|
result.PhoneNumberConfirmed = p2.PhoneNumberConfirmed;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ApplicationUserSDto, ApplicationUser>> ProjectToApplicationUser => p4 => new ApplicationUser()
|
|
{
|
|
FirstName = p4.FirstName,
|
|
LastName = p4.LastName,
|
|
NationalId = p4.NationalId,
|
|
BirthDate = p4.BirthDate,
|
|
Gender = p4.Gender,
|
|
SignUpStatus = p4.SignUpStatus,
|
|
Id = p4.Id,
|
|
UserName = p4.UserName,
|
|
Email = p4.Email,
|
|
PhoneNumber = p4.PhoneNumber,
|
|
PhoneNumberConfirmed = p4.PhoneNumberConfirmed
|
|
};
|
|
public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5)
|
|
{
|
|
return p5 == null ? null : new ApplicationUserSDto()
|
|
{
|
|
FirstName = p5.FirstName,
|
|
LastName = p5.LastName,
|
|
UserName = p5.UserName,
|
|
Email = p5.Email,
|
|
PhoneNumber = p5.PhoneNumber,
|
|
PhoneNumberConfirmed = p5.PhoneNumberConfirmed,
|
|
NationalId = p5.NationalId,
|
|
StudentId = funcMain1(p5.Student == null ? null : (Guid?)p5.Student.Id),
|
|
BirthDate = p5.BirthDate,
|
|
Gender = p5.Gender,
|
|
SignUpStatus = p5.SignUpStatus,
|
|
Id = p5.Id
|
|
};
|
|
}
|
|
public static ApplicationUserSDto AdaptTo(this ApplicationUser p7, ApplicationUserSDto p8)
|
|
{
|
|
if (p7 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ApplicationUserSDto result = p8 ?? new ApplicationUserSDto();
|
|
|
|
result.FirstName = p7.FirstName;
|
|
result.LastName = p7.LastName;
|
|
result.UserName = p7.UserName;
|
|
result.Email = p7.Email;
|
|
result.PhoneNumber = p7.PhoneNumber;
|
|
result.PhoneNumberConfirmed = p7.PhoneNumberConfirmed;
|
|
result.NationalId = p7.NationalId;
|
|
result.StudentId = funcMain2(p7.Student == null ? null : (Guid?)p7.Student.Id, result.StudentId);
|
|
result.BirthDate = p7.BirthDate;
|
|
result.Gender = p7.Gender;
|
|
result.SignUpStatus = p7.SignUpStatus;
|
|
result.Id = p7.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ApplicationUser, ApplicationUserSDto>> ProjectToSDto => p11 => new ApplicationUserSDto()
|
|
{
|
|
FirstName = p11.FirstName,
|
|
LastName = p11.LastName,
|
|
UserName = p11.UserName,
|
|
Email = p11.Email,
|
|
PhoneNumber = p11.PhoneNumber,
|
|
PhoneNumberConfirmed = p11.PhoneNumberConfirmed,
|
|
NationalId = p11.NationalId,
|
|
StudentId = p11.Student.Id.ToString(),
|
|
BirthDate = p11.BirthDate,
|
|
Gender = p11.Gender,
|
|
SignUpStatus = p11.SignUpStatus,
|
|
Id = p11.Id
|
|
};
|
|
|
|
private static string funcMain1(Guid? p6)
|
|
{
|
|
return p6 == null ? null : ((Guid)p6).ToString();
|
|
}
|
|
|
|
private static string funcMain2(Guid? p9, string p10)
|
|
{
|
|
return p9 == null ? null : ((Guid)p9).ToString();
|
|
}
|
|
}
|
|
} |