Api-PWA/DocuMed.Domain/Mappers/MedicalHistoryAnswerMapper....

87 lines
3.1 KiB
C#

using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.MedicalHistory;
namespace DocuMed.Domain.Mappers
{
public static partial class MedicalHistoryAnswerMapper
{
public static MedicalHistoryAnswer AdaptToMedicalHistoryAnswer(this MedicalHistoryAnswerSDto p1)
{
return p1 == null ? null : new MedicalHistoryAnswer()
{
Answer = p1.Answer,
Question = p1.Question,
Part = p1.Part,
QuestionType = p1.QuestionType,
MedicalHistoryId = p1.MedicalHistoryId,
Id = p1.Id
};
}
public static MedicalHistoryAnswer AdaptTo(this MedicalHistoryAnswerSDto p2, MedicalHistoryAnswer p3)
{
if (p2 == null)
{
return null;
}
MedicalHistoryAnswer result = p3 ?? new MedicalHistoryAnswer();
result.Answer = p2.Answer;
result.Question = p2.Question;
result.Part = p2.Part;
result.QuestionType = p2.QuestionType;
result.MedicalHistoryId = p2.MedicalHistoryId;
result.Id = p2.Id;
return result;
}
public static Expression<Func<MedicalHistoryAnswerSDto, MedicalHistoryAnswer>> ProjectToMedicalHistoryAnswer => p4 => new MedicalHistoryAnswer()
{
Answer = p4.Answer,
Question = p4.Question,
Part = p4.Part,
QuestionType = p4.QuestionType,
MedicalHistoryId = p4.MedicalHistoryId,
Id = p4.Id
};
public static MedicalHistoryAnswerSDto AdaptToSDto(this MedicalHistoryAnswer p5)
{
return p5 == null ? null : new MedicalHistoryAnswerSDto()
{
Answer = p5.Answer,
Question = p5.Question,
Part = p5.Part,
QuestionType = p5.QuestionType,
MedicalHistoryId = p5.MedicalHistoryId,
Id = p5.Id
};
}
public static MedicalHistoryAnswerSDto AdaptTo(this MedicalHistoryAnswer p6, MedicalHistoryAnswerSDto p7)
{
if (p6 == null)
{
return null;
}
MedicalHistoryAnswerSDto result = p7 ?? new MedicalHistoryAnswerSDto();
result.Answer = p6.Answer;
result.Question = p6.Question;
result.Part = p6.Part;
result.QuestionType = p6.QuestionType;
result.MedicalHistoryId = p6.MedicalHistoryId;
result.Id = p6.Id;
return result;
}
public static Expression<Func<MedicalHistoryAnswer, MedicalHistoryAnswerSDto>> ProjectToSDto => p8 => new MedicalHistoryAnswerSDto()
{
Answer = p8.Answer,
Question = p8.Question,
Part = p8.Part,
QuestionType = p8.QuestionType,
MedicalHistoryId = p8.MedicalHistoryId,
Id = p8.Id
};
}
}