using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Brizco.Domain.Dtos.LargeDtos;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complexes;
using Brizco.Domain.Entities.Shifts;
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},
                Days = funcMain1(p1.Days),
                Id = p1.Id
            };
        }
        public static Shift AdaptTo(this ShiftSDto p3, Shift p4)
        {
            if (p3 == null)
            {
                return null;
            }
            Shift result = p4 ?? new Shift();
            
            result.Title = p3.Title;
            result.StartAt = p3.StartAt;
            result.EndAt = p3.EndAt;
            result.Description = p3.Description;
            result.ComplexId = p3.ComplexId;
            result.Complex = funcMain2(new Never(), result.Complex, p3);
            result.Days = funcMain3(p3.Days, result.Days);
            result.Id = p3.Id;
            return result;
            
        }
        public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p9 => new Shift()
        {
            Title = p9.Title,
            StartAt = p9.StartAt,
            EndAt = p9.EndAt,
            Description = p9.Description,
            ComplexId = p9.ComplexId,
            Complex = new Complex() {Id = p9.ComplexId},
            Days = p9.Days.Select<DayOfWeek, ShiftDay>(p10 => new ShiftDay() {}).ToList<ShiftDay>(),
            Id = p9.Id
        };
        public static ShiftSDto AdaptToSDto(this Shift p11)
        {
            return p11 == null ? null : new ShiftSDto()
            {
                Title = p11.Title,
                Description = p11.Description,
                StartAt = p11.StartAt,
                EndAt = p11.EndAt,
                ComplexId = p11.ComplexId,
                Days = funcMain4(p11.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>()),
                Id = p11.Id
            };
        }
        public static ShiftSDto AdaptTo(this Shift p13, ShiftSDto p14)
        {
            if (p13 == null)
            {
                return null;
            }
            ShiftSDto result = p14 ?? new ShiftSDto();
            
            result.Title = p13.Title;
            result.Description = p13.Description;
            result.StartAt = p13.StartAt;
            result.EndAt = p13.EndAt;
            result.ComplexId = p13.ComplexId;
            result.Days = funcMain6(p13.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>(), result.Days);
            result.Id = p13.Id;
            return result;
            
        }
        public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p17 => new ShiftSDto()
        {
            Title = p17.Title,
            Description = p17.Description,
            StartAt = p17.StartAt,
            EndAt = p17.EndAt,
            ComplexId = p17.ComplexId,
            Days = p17.Days.Select<ShiftDay, DayOfWeek>(d => d.DayOfWeek).ToList<DayOfWeek>(),
            Id = p17.Id
        };
        public static Shift AdaptToShift(this ShiftLDto p18)
        {
            return p18 == null ? null : new Shift()
            {
                Title = p18.Title,
                StartAt = p18.StartAt,
                EndAt = p18.EndAt,
                Description = p18.Description,
                ComplexId = p18.ComplexId,
                Complex = new Complex() {Id = p18.ComplexId},
                Days = funcMain7(p18.Days),
                Routines = funcMain8(p18.Routines),
                Id = p18.Id
            };
        }
        public static Shift AdaptTo(this ShiftLDto p21, Shift p22)
        {
            if (p21 == null)
            {
                return null;
            }
            Shift result = p22 ?? new Shift();
            
            result.Title = p21.Title;
            result.StartAt = p21.StartAt;
            result.EndAt = p21.EndAt;
            result.Description = p21.Description;
            result.ComplexId = p21.ComplexId;
            result.Complex = funcMain9(new Never(), result.Complex, p21);
            result.Days = funcMain10(p21.Days, result.Days);
            result.Routines = funcMain11(p21.Routines, result.Routines);
            result.Id = p21.Id;
            return result;
            
        }
        public static ShiftLDto AdaptToLDto(this Shift p29)
        {
            return p29 == null ? null : new ShiftLDto()
            {
                Title = p29.Title,
                Description = p29.Description,
                StartAt = p29.StartAt,
                EndAt = p29.EndAt,
                ComplexId = p29.ComplexId,
                Days = funcMain12(p29.Days.Select<ShiftDay, DayOfWeek>(funcMain13).ToList<DayOfWeek>()),
                Routines = funcMain14(p29.Routines),
                Id = p29.Id
            };
        }
        public static ShiftLDto AdaptTo(this Shift p32, ShiftLDto p33)
        {
            if (p32 == null)
            {
                return null;
            }
            ShiftLDto result = p33 ?? new ShiftLDto();
            
            result.Title = p32.Title;
            result.Description = p32.Description;
            result.StartAt = p32.StartAt;
            result.EndAt = p32.EndAt;
            result.ComplexId = p32.ComplexId;
            result.Days = funcMain15(p32.Days.Select<ShiftDay, DayOfWeek>(funcMain13).ToList<DayOfWeek>(), result.Days);
            result.Routines = funcMain16(p32.Routines, result.Routines);
            result.Id = p32.Id;
            return result;
            
        }
        public static Expression<Func<Shift, ShiftLDto>> ProjectToLDto => p38 => new ShiftLDto()
        {
            Title = p38.Title,
            Description = p38.Description,
            StartAt = p38.StartAt,
            EndAt = p38.EndAt,
            ComplexId = p38.ComplexId,
            Days = p38.Days.Select<ShiftDay, DayOfWeek>(d => d.DayOfWeek).ToList<DayOfWeek>(),
            Routines = p38.Routines.Select<ShiftRoutine, ShiftRoutineSDto>(p39 => new ShiftRoutineSDto()
            {
                RoutineId = p39.RoutineId,
                ShiftId = p39.ShiftId,
                Id = p39.Id
            }).ToList<ShiftRoutineSDto>(),
            Id = p38.Id
        };
        
        private static List<ShiftDay> funcMain1(List<DayOfWeek> p2)
        {
            if (p2 == null)
            {
                return null;
            }
            List<ShiftDay> result = new List<ShiftDay>(p2.Count);
            
            int i = 0;
            int len = p2.Count;
            
            while (i < len)
            {
                DayOfWeek item = p2[i];
                result.Add(new ShiftDay() {});
                i++;
            }
            return result;
            
        }
        
        private static Complex funcMain2(Never p5, Complex p6, ShiftSDto p3)
        {
            Complex result = p6 ?? new Complex();
            
            result.Id = p3.ComplexId;
            return result;
            
        }
        
        private static List<ShiftDay> funcMain3(List<DayOfWeek> p7, List<ShiftDay> p8)
        {
            if (p7 == null)
            {
                return null;
            }
            List<ShiftDay> result = new List<ShiftDay>(p7.Count);
            
            int i = 0;
            int len = p7.Count;
            
            while (i < len)
            {
                DayOfWeek item = p7[i];
                result.Add(new ShiftDay() {});
                i++;
            }
            return result;
            
        }
        
        private static List<DayOfWeek> funcMain4(List<DayOfWeek> p12)
        {
            if (p12 == null)
            {
                return null;
            }
            List<DayOfWeek> result = new List<DayOfWeek>(p12.Count);
            
            int i = 0;
            int len = p12.Count;
            
            while (i < len)
            {
                DayOfWeek item = p12[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static DayOfWeek funcMain5(ShiftDay d)
        {
            return d.DayOfWeek;
        }
        
        private static List<DayOfWeek> funcMain6(List<DayOfWeek> p15, List<DayOfWeek> p16)
        {
            if (p15 == null)
            {
                return null;
            }
            List<DayOfWeek> result = new List<DayOfWeek>(p15.Count);
            
            int i = 0;
            int len = p15.Count;
            
            while (i < len)
            {
                DayOfWeek item = p15[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static List<ShiftDay> funcMain7(List<DayOfWeek> p19)
        {
            if (p19 == null)
            {
                return null;
            }
            List<ShiftDay> result = new List<ShiftDay>(p19.Count);
            
            int i = 0;
            int len = p19.Count;
            
            while (i < len)
            {
                DayOfWeek item = p19[i];
                result.Add(new ShiftDay() {});
                i++;
            }
            return result;
            
        }
        
        private static List<ShiftRoutine> funcMain8(List<ShiftRoutineSDto> p20)
        {
            if (p20 == null)
            {
                return null;
            }
            List<ShiftRoutine> result = new List<ShiftRoutine>(p20.Count);
            
            int i = 0;
            int len = p20.Count;
            
            while (i < len)
            {
                ShiftRoutineSDto item = p20[i];
                result.Add(item == null ? null : new ShiftRoutine()
                {
                    RoutineId = item.RoutineId,
                    ShiftId = item.ShiftId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static Complex funcMain9(Never p23, Complex p24, ShiftLDto p21)
        {
            Complex result = p24 ?? new Complex();
            
            result.Id = p21.ComplexId;
            return result;
            
        }
        
        private static List<ShiftDay> funcMain10(List<DayOfWeek> p25, List<ShiftDay> p26)
        {
            if (p25 == null)
            {
                return null;
            }
            List<ShiftDay> result = new List<ShiftDay>(p25.Count);
            
            int i = 0;
            int len = p25.Count;
            
            while (i < len)
            {
                DayOfWeek item = p25[i];
                result.Add(new ShiftDay() {});
                i++;
            }
            return result;
            
        }
        
        private static List<ShiftRoutine> funcMain11(List<ShiftRoutineSDto> p27, List<ShiftRoutine> p28)
        {
            if (p27 == null)
            {
                return null;
            }
            List<ShiftRoutine> result = new List<ShiftRoutine>(p27.Count);
            
            int i = 0;
            int len = p27.Count;
            
            while (i < len)
            {
                ShiftRoutineSDto item = p27[i];
                result.Add(item == null ? null : new ShiftRoutine()
                {
                    RoutineId = item.RoutineId,
                    ShiftId = item.ShiftId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<DayOfWeek> funcMain12(List<DayOfWeek> p30)
        {
            if (p30 == null)
            {
                return null;
            }
            List<DayOfWeek> result = new List<DayOfWeek>(p30.Count);
            
            int i = 0;
            int len = p30.Count;
            
            while (i < len)
            {
                DayOfWeek item = p30[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static DayOfWeek funcMain13(ShiftDay d)
        {
            return d.DayOfWeek;
        }
        
        private static List<ShiftRoutineSDto> funcMain14(List<ShiftRoutine> p31)
        {
            if (p31 == null)
            {
                return null;
            }
            List<ShiftRoutineSDto> result = new List<ShiftRoutineSDto>(p31.Count);
            
            int i = 0;
            int len = p31.Count;
            
            while (i < len)
            {
                ShiftRoutine item = p31[i];
                result.Add(item == null ? null : new ShiftRoutineSDto()
                {
                    RoutineId = item.RoutineId,
                    ShiftId = item.ShiftId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<DayOfWeek> funcMain15(List<DayOfWeek> p34, List<DayOfWeek> p35)
        {
            if (p34 == null)
            {
                return null;
            }
            List<DayOfWeek> result = new List<DayOfWeek>(p34.Count);
            
            int i = 0;
            int len = p34.Count;
            
            while (i < len)
            {
                DayOfWeek item = p34[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static List<ShiftRoutineSDto> funcMain16(List<ShiftRoutine> p36, List<ShiftRoutineSDto> p37)
        {
            if (p36 == null)
            {
                return null;
            }
            List<ShiftRoutineSDto> result = new List<ShiftRoutineSDto>(p36.Count);
            
            int i = 0;
            int len = p36.Count;
            
            while (i < len)
            {
                ShiftRoutine item = p36[i];
                result.Add(item == null ? null : new ShiftRoutineSDto()
                {
                    RoutineId = item.RoutineId,
                    ShiftId = item.ShiftId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
    }
}