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

namespace Brizco.Domain.Mappers
{
    public static partial class RoutineMapper
    {
        public static Routine AdaptToRoutine(this RoutineSDto p1)
        {
            return p1 == null ? null : new Routine()
            {
                Name = p1.Name,
                Description = p1.Description,
                Id = p1.Id
            };
        }
        public static Routine AdaptTo(this RoutineSDto p2, Routine p3)
        {
            if (p2 == null)
            {
                return null;
            }
            Routine result = p3 ?? new Routine();
            
            result.Name = p2.Name;
            result.Description = p2.Description;
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<RoutineSDto, Routine>> ProjectToRoutine => p4 => new Routine()
        {
            Name = p4.Name,
            Description = p4.Description,
            Id = p4.Id
        };
        public static RoutineSDto AdaptToSDto(this Routine p5)
        {
            return p5 == null ? null : new RoutineSDto()
            {
                Name = p5.Name,
                Description = p5.Description,
                Id = p5.Id
            };
        }
        public static RoutineSDto AdaptTo(this Routine p6, RoutineSDto p7)
        {
            if (p6 == null)
            {
                return null;
            }
            RoutineSDto result = p7 ?? new RoutineSDto();
            
            result.Name = p6.Name;
            result.Description = p6.Description;
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<Routine, RoutineSDto>> ProjectToSDto => p8 => new RoutineSDto()
        {
            Name = p8.Name,
            Description = p8.Description,
            Id = p8.Id
        };
    }
}