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

91 lines
2.9 KiB
C#

using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.Patients;
namespace DocuMed.Domain.Mappers
{
public static partial class PatientMapper
{
public static Patient AdaptToPatient(this PatientSDto p1)
{
return p1 == null ? null : new Patient()
{
UnitNumber = p1.UnitNumber,
Room = p1.Room,
Bed = p1.Bed,
AdmissionAt = p1.AdmissionAt,
SectionId = p1.SectionId,
Id = p1.Id
};
}
public static Patient AdaptTo(this PatientSDto p2, Patient p3)
{
if (p2 == null)
{
return null;
}
Patient result = p3 ?? new Patient();
result.UnitNumber = p2.UnitNumber;
result.Room = p2.Room;
result.Bed = p2.Bed;
result.AdmissionAt = p2.AdmissionAt;
result.SectionId = p2.SectionId;
result.Id = p2.Id;
return result;
}
public static Expression<Func<PatientSDto, Patient>> ProjectToPatient => p4 => new Patient()
{
UnitNumber = p4.UnitNumber,
Room = p4.Room,
Bed = p4.Bed,
AdmissionAt = p4.AdmissionAt,
SectionId = p4.SectionId,
Id = p4.Id
};
public static PatientSDto AdaptToSDto(this Patient p5)
{
return p5 == null ? null : new PatientSDto()
{
UnitNumber = p5.UnitNumber,
Room = p5.Room,
Bed = p5.Bed,
AdmissionAt = p5.AdmissionAt,
SectionId = p5.SectionId,
SectionName = p5.Section == null ? null : p5.Section.Name,
Id = p5.Id
};
}
public static PatientSDto AdaptTo(this Patient p6, PatientSDto p7)
{
if (p6 == null)
{
return null;
}
PatientSDto result = p7 ?? new PatientSDto();
result.UnitNumber = p6.UnitNumber;
result.Room = p6.Room;
result.Bed = p6.Bed;
result.AdmissionAt = p6.AdmissionAt;
result.SectionId = p6.SectionId;
result.SectionName = p6.Section == null ? null : p6.Section.Name;
result.Id = p6.Id;
return result;
}
public static Expression<Func<Patient, PatientSDto>> ProjectToSDto => p8 => new PatientSDto()
{
UnitNumber = p8.UnitNumber,
Room = p8.Room,
Bed = p8.Bed,
HospitalId = p8.HospitalId,
AdmissionAt = p8.AdmissionAt,
SectionId = p8.SectionId,
SectionName = p8.Section.Name,
Id = p8.Id
};
}
}