Api-PWA/DocuMed.Domain/Mappers/StudentMapper.g.cs

157 lines
5.9 KiB
C#

using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.City;
using DocuMed.Domain.Entities.Hospitals;
using DocuMed.Domain.Entities.Staffs;
using DocuMed.Domain.Entities.User;
using Mapster.Models;
namespace DocuMed.Domain.Mappers
{
public static partial class StudentMapper
{
public static Student AdaptToStudent(this StudentSDto p1)
{
return p1 == null ? null : new Student()
{
StudentId = p1.StudentId,
UniversityId = p1.UniversityId,
University = new University()
{
Name = p1.UniversityName,
Id = p1.UniversityId
},
SectionId = p1.SectionId,
Section = new Section()
{
Name = p1.SectionName,
Id = p1.SectionId
},
UserId = p1.UserId,
User = new ApplicationUser() {Id = p1.UserId},
Id = p1.Id
};
}
public static Student AdaptTo(this StudentSDto p2, Student p3)
{
if (p2 == null)
{
return null;
}
Student result = p3 ?? new Student();
result.StudentId = p2.StudentId;
result.UniversityId = p2.UniversityId;
result.University = funcMain1(new Never(), result.University, p2);
result.SectionId = p2.SectionId;
result.Section = funcMain2(new Never(), result.Section, p2);
result.UserId = p2.UserId;
result.User = funcMain3(new Never(), result.User, p2);
result.Id = p2.Id;
return result;
}
public static Expression<Func<StudentSDto, Student>> ProjectToStudent => p10 => new Student()
{
StudentId = p10.StudentId,
UniversityId = p10.UniversityId,
University = new University()
{
Name = p10.UniversityName,
Id = p10.UniversityId
},
SectionId = p10.SectionId,
Section = new Section()
{
Name = p10.SectionName,
Id = p10.SectionId
},
UserId = p10.UserId,
User = new ApplicationUser() {Id = p10.UserId},
Id = p10.Id
};
public static StudentSDto AdaptToSDto(this Student p11)
{
return p11 == null ? null : new StudentSDto()
{
StudentId = p11.StudentId,
UniversityId = p11.UniversityId,
UniversityName = p11.University != null ? p11.University.Name : string.Empty,
SectionId = p11.SectionId,
SectionName = p11.Section != null ? p11.Section.Name : string.Empty,
UserId = p11.UserId,
PhoneNumber = p11.User != null ? p11.User.PhoneNumber : string.Empty,
FirstName = p11.User != null ? p11.User.FirstName : string.Empty,
LastName = p11.User != null ? p11.User.LastName : string.Empty,
NationalId = p11.User != null ? p11.User.NationalId : string.Empty,
Id = p11.Id
};
}
public static StudentSDto AdaptTo(this Student p12, StudentSDto p13)
{
if (p12 == null)
{
return null;
}
StudentSDto result = p13 ?? new StudentSDto();
result.StudentId = p12.StudentId;
result.UniversityId = p12.UniversityId;
result.UniversityName = p12.University != null ? p12.University.Name : string.Empty;
result.SectionId = p12.SectionId;
result.SectionName = p12.Section != null ? p12.Section.Name : string.Empty;
result.UserId = p12.UserId;
result.PhoneNumber = p12.User != null ? p12.User.PhoneNumber : string.Empty;
result.FirstName = p12.User != null ? p12.User.FirstName : string.Empty;
result.LastName = p12.User != null ? p12.User.LastName : string.Empty;
result.NationalId = p12.User != null ? p12.User.NationalId : string.Empty;
result.Id = p12.Id;
return result;
}
public static Expression<Func<Student, StudentSDto>> ProjectToSDto => p14 => new StudentSDto()
{
StudentId = p14.StudentId,
UniversityId = p14.UniversityId,
UniversityName = p14.University != null ? p14.University.Name : string.Empty,
SectionId = p14.SectionId,
SectionName = p14.Section != null ? p14.Section.Name : string.Empty,
UserId = p14.UserId,
PhoneNumber = p14.User != null ? p14.User.PhoneNumber : string.Empty,
FirstName = p14.User != null ? p14.User.FirstName : string.Empty,
LastName = p14.User != null ? p14.User.LastName : string.Empty,
NationalId = p14.User != null ? p14.User.NationalId : string.Empty,
Id = p14.Id
};
private static University funcMain1(Never p4, University p5, StudentSDto p2)
{
University result = p5 ?? new University();
result.Name = p2.UniversityName;
result.Id = p2.UniversityId;
return result;
}
private static Section funcMain2(Never p6, Section p7, StudentSDto p2)
{
Section result = p7 ?? new Section();
result.Name = p2.SectionName;
result.Id = p2.SectionId;
return result;
}
private static ApplicationUser funcMain3(Never p8, ApplicationUser p9, StudentSDto p2)
{
ApplicationUser result = p9 ?? new ApplicationUser();
result.Id = p2.UserId;
return result;
}
}
}