using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.MedicalHistoryTemplate;

namespace DocuMed.Domain.Mappers
{
    public static partial class MedicalHistoryQuestionMapper
    {
        public static MedicalHistoryQuestion AdaptToMedicalHistoryQuestion(this MedicalHistoryQuestionSDto p1)
        {
            return p1 == null ? null : new MedicalHistoryQuestion()
            {
                Question = p1.Question,
                Part = p1.Part,
                QuestionType = p1.QuestionType,
                MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId,
                Id = p1.Id
            };
        }
        public static MedicalHistoryQuestion AdaptTo(this MedicalHistoryQuestionSDto p2, MedicalHistoryQuestion p3)
        {
            if (p2 == null)
            {
                return null;
            }
            MedicalHistoryQuestion result = p3 ?? new MedicalHistoryQuestion();
            
            result.Question = p2.Question;
            result.Part = p2.Part;
            result.QuestionType = p2.QuestionType;
            result.MedicalHistoryTemplateId = p2.MedicalHistoryTemplateId;
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>> ProjectToMedicalHistoryQuestion => p4 => new MedicalHistoryQuestion()
        {
            Question = p4.Question,
            Part = p4.Part,
            QuestionType = p4.QuestionType,
            MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId,
            Id = p4.Id
        };
        public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p5)
        {
            return p5 == null ? null : new MedicalHistoryQuestionSDto()
            {
                Question = p5.Question,
                Part = p5.Part,
                QuestionType = p5.QuestionType,
                MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId,
                Id = p5.Id
            };
        }
        public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p6, MedicalHistoryQuestionSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            MedicalHistoryQuestionSDto result = p7 ?? new MedicalHistoryQuestionSDto();
            
            result.Question = p6.Question;
            result.Part = p6.Part;
            result.QuestionType = p6.QuestionType;
            result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p8 => new MedicalHistoryQuestionSDto()
        {
            Question = p8.Question,
            Part = p8.Part,
            QuestionType = p8.QuestionType,
            MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId,
            Id = p8.Id
        };
    }
}