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

namespace Brizco.Domain.Mappers
{
    public static partial class TaskPositionMapper
    {
        public static TaskPosition AdaptToTaskPosition(this TaskPositionSDto p1)
        {
            return p1 == null ? null : new TaskPosition()
            {
                PositionId = p1.PositionId,
                TaskId = p1.TaskId,
                Id = p1.Id
            };
        }
        public static TaskPosition AdaptTo(this TaskPositionSDto p2, TaskPosition p3)
        {
            if (p2 == null)
            {
                return null;
            }
            TaskPosition result = p3 ?? new TaskPosition();
            
            result.PositionId = p2.PositionId;
            result.TaskId = p2.TaskId;
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<TaskPositionSDto, TaskPosition>> ProjectToTaskPosition => p4 => new TaskPosition()
        {
            PositionId = p4.PositionId,
            TaskId = p4.TaskId,
            Id = p4.Id
        };
        public static TaskPositionSDto AdaptToSDto(this TaskPosition p5)
        {
            return p5 == null ? null : new TaskPositionSDto()
            {
                PositionId = p5.PositionId,
                TaskId = p5.TaskId,
                Id = p5.Id
            };
        }
        public static TaskPositionSDto AdaptTo(this TaskPosition p6, TaskPositionSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            TaskPositionSDto result = p7 ?? new TaskPositionSDto();
            
            result.PositionId = p6.PositionId;
            result.TaskId = p6.TaskId;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<TaskPosition, TaskPositionSDto>> ProjectToSDto => p8 => new TaskPositionSDto()
        {
            PositionId = p8.PositionId,
            TaskId = p8.TaskId,
            Id = p8.Id
        };
    }
}