using System;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complex;
using Brizco.Domain.Entities.Shift;
using Mapster.Models;

namespace Brizco.Domain.Mappers
{
    public static partial class ShiftMapper
    {
        public static Shift AdaptToShift(this ShiftSDto p1)
        {
            return p1 == null ? null : new Shift()
            {
                Title = p1.Title,
                StartAt = p1.StartAt,
                EndAt = p1.EndAt,
                Description = p1.Description,
                ComplexId = p1.ComplexId,
                Complex = new Complex() {Id = p1.ComplexId},
                Id = p1.Id
            };
        }
        public static Shift AdaptTo(this ShiftSDto p2, Shift p3)
        {
            if (p2 == null)
            {
                return null;
            }
            Shift result = p3 ?? new Shift();
            
            result.Title = p2.Title;
            result.StartAt = p2.StartAt;
            result.EndAt = p2.EndAt;
            result.Description = p2.Description;
            result.ComplexId = p2.ComplexId;
            result.Complex = funcMain1(new Never(), result.Complex, p2);
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p6 => new Shift()
        {
            Title = p6.Title,
            StartAt = p6.StartAt,
            EndAt = p6.EndAt,
            Description = p6.Description,
            ComplexId = p6.ComplexId,
            Complex = new Complex() {Id = p6.ComplexId},
            Id = p6.Id
        };
        public static ShiftSDto AdaptToSDto(this Shift p7)
        {
            return p7 == null ? null : new ShiftSDto()
            {
                Title = p7.Title,
                Description = p7.Description,
                StartAt = p7.StartAt,
                EndAt = p7.EndAt,
                ComplexId = p7.ComplexId,
                Id = p7.Id
            };
        }
        public static ShiftSDto AdaptTo(this Shift p8, ShiftSDto p9)
        {
            if (p8 == null)
            {
                return null;
            }
            ShiftSDto result = p9 ?? new ShiftSDto();
            
            result.Title = p8.Title;
            result.Description = p8.Description;
            result.StartAt = p8.StartAt;
            result.EndAt = p8.EndAt;
            result.ComplexId = p8.ComplexId;
            result.Id = p8.Id;
            return result;
            
        }
        public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p10 => new ShiftSDto()
        {
            Title = p10.Title,
            Description = p10.Description,
            StartAt = p10.StartAt,
            EndAt = p10.EndAt,
            ComplexId = p10.ComplexId,
            Id = p10.Id
        };
        
        private static Complex funcMain1(Never p4, Complex p5, ShiftSDto p2)
        {
            Complex result = p5 ?? new Complex();
            
            result.Id = p2.ComplexId;
            return result;
            
        }
    }
}