using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Tasks;

namespace Brizco.Domain.Mappers
{
    public static partial class TaskRoutineMapper
    {
        public static TaskRoutine AdaptToTaskRoutine(this TaskRoutineSDto p1)
        {
            return p1 == null ? null : new TaskRoutine()
            {
                TaskId = p1.TaskId,
                RoutineId = p1.RoutineId,
                Id = p1.Id
            };
        }
        public static TaskRoutine AdaptTo(this TaskRoutineSDto p2, TaskRoutine p3)
        {
            if (p2 == null)
            {
                return null;
            }
            TaskRoutine result = p3 ?? new TaskRoutine();
            
            result.TaskId = p2.TaskId;
            result.RoutineId = p2.RoutineId;
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<TaskRoutineSDto, TaskRoutine>> ProjectToTaskRoutine => p4 => new TaskRoutine()
        {
            TaskId = p4.TaskId,
            RoutineId = p4.RoutineId,
            Id = p4.Id
        };
        public static TaskRoutineSDto AdaptToSDto(this TaskRoutine p5)
        {
            return p5 == null ? null : new TaskRoutineSDto()
            {
                TaskId = p5.TaskId,
                RoutineId = p5.RoutineId,
                Id = p5.Id
            };
        }
        public static TaskRoutineSDto AdaptTo(this TaskRoutine p6, TaskRoutineSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            TaskRoutineSDto result = p7 ?? new TaskRoutineSDto();
            
            result.TaskId = p6.TaskId;
            result.RoutineId = p6.RoutineId;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<TaskRoutine, TaskRoutineSDto>> ProjectToSDto => p8 => new TaskRoutineSDto()
        {
            TaskId = p8.TaskId,
            RoutineId = p8.RoutineId,
            Id = p8.Id
        };
    }
}