using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Brizco.Common.Extensions;
using Brizco.Domain.Dtos.LargeDtos;
using Brizco.Domain.Dtos.SmallDtos;
using Brizco.Domain.Entities.Complexes;
using Brizco.Domain.Entities.Shifts;
using Brizco.Domain.Entities.Tasks;
using Mapster.Models;
using Task = Brizco.Domain.Entities.Tasks.Task;

namespace Brizco.Domain.Mappers
{
    public static partial class TaskMapper
    {
        public static Task AdaptToTask(this TaskSDto p1)
        {
            return p1 == null ? null : new Task()
            {
                Type = p1.Type,
                Title = p1.Title,
                Description = p1.Description,
                IsDisposable = p1.IsDisposable,
                SetFor = Convert.ToDateTime(p1.SetFor),
                HasDisposed = p1.HasDisposed,
                ScheduleType = p1.ScheduleType,
                ComplexId = p1.ComplexId,
                Complex = new Complex() {Id = p1.ComplexId},
                Amount = p1.Amount,
                AmountType = p1.AmountType,
                Shifts = funcMain1(p1.Shifts),
                Days = funcMain2(p1.Days),
                Routines = funcMain3(p1.Routines),
                Positions = funcMain4(p1.Positions),
                Id = p1.Id
            };
        }
        public static Task AdaptTo(this TaskSDto p6, Task p7)
        {
            if (p6 == null)
            {
                return null;
            }
            Task result = p7 ?? new Task();
            
            result.Type = p6.Type;
            result.Title = p6.Title;
            result.Description = p6.Description;
            result.IsDisposable = p6.IsDisposable;
            result.SetFor = Convert.ToDateTime(p6.SetFor);
            result.HasDisposed = p6.HasDisposed;
            result.ScheduleType = p6.ScheduleType;
            result.ComplexId = p6.ComplexId;
            result.Complex = funcMain5(new Never(), result.Complex, p6);
            result.Amount = p6.Amount;
            result.AmountType = p6.AmountType;
            result.Shifts = funcMain6(p6.Shifts, result.Shifts);
            result.Days = funcMain7(p6.Days, result.Days);
            result.Routines = funcMain8(p6.Routines, result.Routines);
            result.Positions = funcMain9(p6.Positions, result.Positions);
            result.Id = p6.Id;
            return result;
            
        }
        public static Expression<Func<TaskSDto, Task>> ProjectToTask => p18 => new Task()
        {
            Type = p18.Type,
            Title = p18.Title,
            Description = p18.Description,
            IsDisposable = p18.IsDisposable,
            SetFor = Convert.ToDateTime(p18.SetFor),
            HasDisposed = p18.HasDisposed,
            ScheduleType = p18.ScheduleType,
            ComplexId = p18.ComplexId,
            Complex = new Complex() {Id = p18.ComplexId},
            Amount = p18.Amount,
            AmountType = p18.AmountType,
            Shifts = p18.Shifts.Select<string, TaskShift>(p19 => (TaskShift)Convert.ChangeType((object)p19, typeof(TaskShift))).ToList<TaskShift>(),
            Days = p18.Days.Select<string, TaskDay>(p20 => (TaskDay)Convert.ChangeType((object)p20, typeof(TaskDay))).ToList<TaskDay>(),
            Routines = p18.Routines.Select<string, TaskRoutine>(p21 => (TaskRoutine)Convert.ChangeType((object)p21, typeof(TaskRoutine))).ToList<TaskRoutine>(),
            Positions = p18.Positions.Select<string, TaskPosition>(p22 => (TaskPosition)Convert.ChangeType((object)p22, typeof(TaskPosition))).ToList<TaskPosition>(),
            Id = p18.Id
        };
        public static TaskSDto AdaptToSDto(this Task p23)
        {
            return p23 == null ? null : new TaskSDto()
            {
                Type = p23.Type,
                Title = p23.Title,
                Description = p23.Description,
                IsDisposable = p23.IsDisposable,
                SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p23.SetFor),
                HasDisposed = p23.HasDisposed,
                ComplexId = p23.ComplexId,
                ScheduleType = p23.ScheduleType,
                Shifts = funcMain10(p23.Shifts.Select<TaskShift, string>(funcMain11)),
                Routines = funcMain12(p23.Routines.Select<TaskRoutine, string>(funcMain13)),
                Positions = funcMain14(p23.Positions.Select<TaskPosition, string>(funcMain15)),
                Days = funcMain16(p23.Days.Select<TaskDay, string>(funcMain17).ToList<string>()),
                Amount = p23.Amount,
                AmountType = p23.AmountType,
                Id = p23.Id
            };
        }
        public static TaskSDto AdaptTo(this Task p28, TaskSDto p29)
        {
            if (p28 == null)
            {
                return null;
            }
            TaskSDto result = p29 ?? new TaskSDto();
            
            result.Type = p28.Type;
            result.Title = p28.Title;
            result.Description = p28.Description;
            result.IsDisposable = p28.IsDisposable;
            result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p28.SetFor);
            result.HasDisposed = p28.HasDisposed;
            result.ComplexId = p28.ComplexId;
            result.ScheduleType = p28.ScheduleType;
            result.Shifts = funcMain18(p28.Shifts.Select<TaskShift, string>(funcMain11), result.Shifts);
            result.Routines = funcMain19(p28.Routines.Select<TaskRoutine, string>(funcMain13), result.Routines);
            result.Positions = funcMain20(p28.Positions.Select<TaskPosition, string>(funcMain15), result.Positions);
            result.Days = funcMain21(p28.Days.Select<TaskDay, string>(funcMain17).ToList<string>(), result.Days);
            result.Amount = p28.Amount;
            result.AmountType = p28.AmountType;
            result.Id = p28.Id;
            return result;
            
        }
        public static Expression<Func<Task, TaskSDto>> ProjectToSDto => p38 => new TaskSDto()
        {
            Type = p38.Type,
            Title = p38.Title,
            Description = p38.Description,
            IsDisposable = p38.IsDisposable,
            SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p38.SetFor),
            HasDisposed = p38.HasDisposed,
            ComplexId = p38.ComplexId,
            ScheduleType = p38.ScheduleType,
            Shifts = (List<string>)p38.Shifts.Select<TaskShift, string>(d => d.Shift != null ? d.Shift.Title : string.Empty),
            Routines = (List<string>)p38.Routines.Select<TaskRoutine, string>(d => d.Routine != null ? d.Routine.Name : string.Empty),
            Positions = (List<string>)p38.Positions.Select<TaskPosition, string>(d => d.Position != null ? d.Position.Name : string.Empty),
            Days = p38.Days.Select<TaskDay, string>(d => d.DayOfWeek.GetPersianDayOfWeek()).ToList<string>(),
            Amount = p38.Amount,
            AmountType = p38.AmountType,
            Id = p38.Id
        };
        public static Task AdaptToTask(this TaskLDto p39)
        {
            return p39 == null ? null : new Task()
            {
                Type = p39.Type,
                Title = p39.Title,
                Description = p39.Description,
                IsDisposable = p39.IsDisposable,
                SetFor = Convert.ToDateTime(p39.SetFor),
                HasDisposed = p39.HasDisposed,
                ScheduleType = p39.ScheduleType,
                Amount = p39.Amount,
                AmountType = p39.AmountType,
                Shifts = funcMain22(p39.Shifts),
                Days = funcMain23(p39.Days),
                Routines = funcMain24(p39.Routines),
                Positions = funcMain25(p39.Positions),
                Id = p39.Id
            };
        }
        public static Task AdaptTo(this TaskLDto p44, Task p45)
        {
            if (p44 == null)
            {
                return null;
            }
            Task result = p45 ?? new Task();
            
            result.Type = p44.Type;
            result.Title = p44.Title;
            result.Description = p44.Description;
            result.IsDisposable = p44.IsDisposable;
            result.SetFor = Convert.ToDateTime(p44.SetFor);
            result.HasDisposed = p44.HasDisposed;
            result.ScheduleType = p44.ScheduleType;
            result.Amount = p44.Amount;
            result.AmountType = p44.AmountType;
            result.Shifts = funcMain26(p44.Shifts, result.Shifts);
            result.Days = funcMain27(p44.Days, result.Days);
            result.Routines = funcMain28(p44.Routines, result.Routines);
            result.Positions = funcMain29(p44.Positions, result.Positions);
            result.Id = p44.Id;
            return result;
            
        }
        public static TaskLDto AdaptToLDto(this Task p54)
        {
            return p54 == null ? null : new TaskLDto()
            {
                Type = p54.Type,
                Title = p54.Title,
                Description = p54.Description,
                IsDisposable = p54.IsDisposable,
                SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p54.SetFor),
                HasDisposed = p54.HasDisposed,
                ScheduleType = p54.ScheduleType,
                Amount = p54.Amount,
                AmountType = p54.AmountType,
                Shifts = funcMain30(p54.Shifts),
                Positions = funcMain31(p54.Positions),
                Days = funcMain32(p54.Days),
                Routines = funcMain33(p54.Routines),
                Id = p54.Id
            };
        }
        public static TaskLDto AdaptTo(this Task p59, TaskLDto p60)
        {
            if (p59 == null)
            {
                return null;
            }
            TaskLDto result = p60 ?? new TaskLDto();
            
            result.Type = p59.Type;
            result.Title = p59.Title;
            result.Description = p59.Description;
            result.IsDisposable = p59.IsDisposable;
            result.SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p59.SetFor);
            result.HasDisposed = p59.HasDisposed;
            result.ScheduleType = p59.ScheduleType;
            result.Amount = p59.Amount;
            result.AmountType = p59.AmountType;
            result.Shifts = funcMain34(p59.Shifts, result.Shifts);
            result.Positions = funcMain35(p59.Positions, result.Positions);
            result.Days = funcMain36(p59.Days, result.Days);
            result.Routines = funcMain37(p59.Routines, result.Routines);
            result.Id = p59.Id;
            return result;
            
        }
        public static Expression<Func<Task, TaskLDto>> ProjectToLDto => p69 => new TaskLDto()
        {
            Type = p69.Type,
            Title = p69.Title,
            Description = p69.Description,
            IsDisposable = p69.IsDisposable,
            SetFor = DateTimeExtensions.DateTimeToUnixTimeStamp(p69.SetFor),
            HasDisposed = p69.HasDisposed,
            ScheduleType = p69.ScheduleType,
            Amount = p69.Amount,
            AmountType = p69.AmountType,
            Shifts = p69.Shifts.Select<TaskShift, TaskShiftSDto>(p70 => new TaskShiftSDto()
            {
                ShiftId = p70.ShiftId,
                ShiftName = p70.Shift != null ? p70.Shift.Title : string.Empty,
                TaskId = p70.TaskId,
                TaskTitle = p70.Task != null ? p70.Task.Title : string.Empty,
                Id = p70.Id
            }).ToList<TaskShiftSDto>(),
            Positions = p69.Positions.Select<TaskPosition, TaskPositionSDto>(p71 => new TaskPositionSDto()
            {
                PositionId = p71.PositionId,
                PositionName = p71.Position != null ? p71.Position.Name : string.Empty,
                TaskId = p71.TaskId,
                Id = p71.Id
            }).ToList<TaskPositionSDto>(),
            Days = p69.Days.Select<TaskDay, TaskDaySDto>(p72 => new TaskDaySDto()
            {
                DayOfWeek = p72.DayOfWeek,
                TaskId = p72.TaskId,
                Id = p72.Id
            }).ToList<TaskDaySDto>(),
            Routines = p69.Routines.Select<TaskRoutine, TaskRoutineSDto>(p73 => new TaskRoutineSDto()
            {
                TaskId = p73.TaskId,
                RoutineId = p73.RoutineId,
                Id = p73.Id
            }).ToList<TaskRoutineSDto>(),
            Id = p69.Id
        };
        
        private static List<TaskShift> funcMain1(List<string> p2)
        {
            if (p2 == null)
            {
                return null;
            }
            List<TaskShift> result = new List<TaskShift>(p2.Count);
            
            int i = 0;
            int len = p2.Count;
            
            while (i < len)
            {
                string item = p2[i];
                result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDay> funcMain2(List<string> p3)
        {
            if (p3 == null)
            {
                return null;
            }
            List<TaskDay> result = new List<TaskDay>(p3.Count);
            
            int i = 0;
            int len = p3.Count;
            
            while (i < len)
            {
                string item = p3[i];
                result.Add(item == null ? null : (TaskDay)Convert.ChangeType((object)item, typeof(TaskDay)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutine> funcMain3(List<string> p4)
        {
            if (p4 == null)
            {
                return null;
            }
            List<TaskRoutine> result = new List<TaskRoutine>(p4.Count);
            
            int i = 0;
            int len = p4.Count;
            
            while (i < len)
            {
                string item = p4[i];
                result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPosition> funcMain4(List<string> p5)
        {
            if (p5 == null)
            {
                return null;
            }
            List<TaskPosition> result = new List<TaskPosition>(p5.Count);
            
            int i = 0;
            int len = p5.Count;
            
            while (i < len)
            {
                string item = p5[i];
                result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition)));
                i++;
            }
            return result;
            
        }
        
        private static Complex funcMain5(Never p8, Complex p9, TaskSDto p6)
        {
            Complex result = p9 ?? new Complex();
            
            result.Id = p6.ComplexId;
            return result;
            
        }
        
        private static List<TaskShift> funcMain6(List<string> p10, List<TaskShift> p11)
        {
            if (p10 == null)
            {
                return null;
            }
            List<TaskShift> result = new List<TaskShift>(p10.Count);
            
            int i = 0;
            int len = p10.Count;
            
            while (i < len)
            {
                string item = p10[i];
                result.Add(item == null ? null : (TaskShift)Convert.ChangeType((object)item, typeof(TaskShift)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDay> funcMain7(List<string> p12, List<TaskDay> p13)
        {
            if (p12 == null)
            {
                return null;
            }
            List<TaskDay> result = new List<TaskDay>(p12.Count);
            
            int i = 0;
            int len = p12.Count;
            
            while (i < len)
            {
                string item = p12[i];
                result.Add(item == null ? null : (TaskDay)Convert.ChangeType((object)item, typeof(TaskDay)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutine> funcMain8(List<string> p14, List<TaskRoutine> p15)
        {
            if (p14 == null)
            {
                return null;
            }
            List<TaskRoutine> result = new List<TaskRoutine>(p14.Count);
            
            int i = 0;
            int len = p14.Count;
            
            while (i < len)
            {
                string item = p14[i];
                result.Add(item == null ? null : (TaskRoutine)Convert.ChangeType((object)item, typeof(TaskRoutine)));
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPosition> funcMain9(List<string> p16, List<TaskPosition> p17)
        {
            if (p16 == null)
            {
                return null;
            }
            List<TaskPosition> result = new List<TaskPosition>(p16.Count);
            
            int i = 0;
            int len = p16.Count;
            
            while (i < len)
            {
                string item = p16[i];
                result.Add(item == null ? null : (TaskPosition)Convert.ChangeType((object)item, typeof(TaskPosition)));
                i++;
            }
            return result;
            
        }
        
        private static List<string> funcMain10(IEnumerable<string> p24)
        {
            if (p24 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p24.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static string funcMain11(TaskShift d)
        {
            return d.Shift != null ? d.Shift.Title : string.Empty;
        }
        
        private static List<string> funcMain12(IEnumerable<string> p25)
        {
            if (p25 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p25.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static string funcMain13(TaskRoutine d)
        {
            return d.Routine != null ? d.Routine.Name : string.Empty;
        }
        
        private static List<string> funcMain14(IEnumerable<string> p26)
        {
            if (p26 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p26.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static string funcMain15(TaskPosition d)
        {
            return d.Position != null ? d.Position.Name : string.Empty;
        }
        
        private static List<string> funcMain16(List<string> p27)
        {
            if (p27 == null)
            {
                return null;
            }
            List<string> result = new List<string>(p27.Count);
            
            int i = 0;
            int len = p27.Count;
            
            while (i < len)
            {
                string item = p27[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static string funcMain17(TaskDay d)
        {
            return d.DayOfWeek.GetPersianDayOfWeek();
        }
        
        private static List<string> funcMain18(IEnumerable<string> p30, List<string> p31)
        {
            if (p30 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p30.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static List<string> funcMain19(IEnumerable<string> p32, List<string> p33)
        {
            if (p32 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p32.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static List<string> funcMain20(IEnumerable<string> p34, List<string> p35)
        {
            if (p34 == null)
            {
                return null;
            }
            List<string> result = new List<string>();
            
            IEnumerator<string> enumerator = p34.GetEnumerator();
            
            while (enumerator.MoveNext())
            {
                string item = enumerator.Current;
                result.Add(item);
            }
            return result;
            
        }
        
        private static List<string> funcMain21(List<string> p36, List<string> p37)
        {
            if (p36 == null)
            {
                return null;
            }
            List<string> result = new List<string>(p36.Count);
            
            int i = 0;
            int len = p36.Count;
            
            while (i < len)
            {
                string item = p36[i];
                result.Add(item);
                i++;
            }
            return result;
            
        }
        
        private static List<TaskShift> funcMain22(List<TaskShiftSDto> p40)
        {
            if (p40 == null)
            {
                return null;
            }
            List<TaskShift> result = new List<TaskShift>(p40.Count);
            
            int i = 0;
            int len = p40.Count;
            
            while (i < len)
            {
                TaskShiftSDto item = p40[i];
                result.Add(item == null ? null : new TaskShift()
                {
                    TaskId = item.TaskId,
                    Task = new Task()
                    {
                        Title = item.TaskTitle,
                        Id = item.TaskId
                    },
                    ShiftId = item.ShiftId,
                    Shift = new Shift() {Id = item.ShiftId},
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDay> funcMain23(List<TaskDaySDto> p41)
        {
            if (p41 == null)
            {
                return null;
            }
            List<TaskDay> result = new List<TaskDay>(p41.Count);
            
            int i = 0;
            int len = p41.Count;
            
            while (i < len)
            {
                TaskDaySDto item = p41[i];
                result.Add(item == null ? null : new TaskDay()
                {
                    DayOfWeek = item.DayOfWeek,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutine> funcMain24(List<TaskRoutineSDto> p42)
        {
            if (p42 == null)
            {
                return null;
            }
            List<TaskRoutine> result = new List<TaskRoutine>(p42.Count);
            
            int i = 0;
            int len = p42.Count;
            
            while (i < len)
            {
                TaskRoutineSDto item = p42[i];
                result.Add(item == null ? null : new TaskRoutine()
                {
                    TaskId = item.TaskId,
                    RoutineId = item.RoutineId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPosition> funcMain25(List<TaskPositionSDto> p43)
        {
            if (p43 == null)
            {
                return null;
            }
            List<TaskPosition> result = new List<TaskPosition>(p43.Count);
            
            int i = 0;
            int len = p43.Count;
            
            while (i < len)
            {
                TaskPositionSDto item = p43[i];
                result.Add(item == null ? null : new TaskPosition()
                {
                    PositionId = item.PositionId,
                    Position = new Position()
                    {
                        Name = item.PositionName,
                        Id = item.PositionId
                    },
                    TaskId = item.TaskId,
                    Task = new Task() {Id = item.TaskId},
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskShift> funcMain26(List<TaskShiftSDto> p46, List<TaskShift> p47)
        {
            if (p46 == null)
            {
                return null;
            }
            List<TaskShift> result = new List<TaskShift>(p46.Count);
            
            int i = 0;
            int len = p46.Count;
            
            while (i < len)
            {
                TaskShiftSDto item = p46[i];
                result.Add(item == null ? null : new TaskShift()
                {
                    TaskId = item.TaskId,
                    Task = new Task()
                    {
                        Title = item.TaskTitle,
                        Id = item.TaskId
                    },
                    ShiftId = item.ShiftId,
                    Shift = new Shift() {Id = item.ShiftId},
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDay> funcMain27(List<TaskDaySDto> p48, List<TaskDay> p49)
        {
            if (p48 == null)
            {
                return null;
            }
            List<TaskDay> result = new List<TaskDay>(p48.Count);
            
            int i = 0;
            int len = p48.Count;
            
            while (i < len)
            {
                TaskDaySDto item = p48[i];
                result.Add(item == null ? null : new TaskDay()
                {
                    DayOfWeek = item.DayOfWeek,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutine> funcMain28(List<TaskRoutineSDto> p50, List<TaskRoutine> p51)
        {
            if (p50 == null)
            {
                return null;
            }
            List<TaskRoutine> result = new List<TaskRoutine>(p50.Count);
            
            int i = 0;
            int len = p50.Count;
            
            while (i < len)
            {
                TaskRoutineSDto item = p50[i];
                result.Add(item == null ? null : new TaskRoutine()
                {
                    TaskId = item.TaskId,
                    RoutineId = item.RoutineId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPosition> funcMain29(List<TaskPositionSDto> p52, List<TaskPosition> p53)
        {
            if (p52 == null)
            {
                return null;
            }
            List<TaskPosition> result = new List<TaskPosition>(p52.Count);
            
            int i = 0;
            int len = p52.Count;
            
            while (i < len)
            {
                TaskPositionSDto item = p52[i];
                result.Add(item == null ? null : new TaskPosition()
                {
                    PositionId = item.PositionId,
                    Position = new Position()
                    {
                        Name = item.PositionName,
                        Id = item.PositionId
                    },
                    TaskId = item.TaskId,
                    Task = new Task() {Id = item.TaskId},
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskShiftSDto> funcMain30(List<TaskShift> p55)
        {
            if (p55 == null)
            {
                return null;
            }
            List<TaskShiftSDto> result = new List<TaskShiftSDto>(p55.Count);
            
            int i = 0;
            int len = p55.Count;
            
            while (i < len)
            {
                TaskShift item = p55[i];
                result.Add(item == null ? null : new TaskShiftSDto()
                {
                    ShiftId = item.ShiftId,
                    ShiftName = item.Shift != null ? item.Shift.Title : string.Empty,
                    TaskId = item.TaskId,
                    TaskTitle = item.Task != null ? item.Task.Title : string.Empty,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPositionSDto> funcMain31(List<TaskPosition> p56)
        {
            if (p56 == null)
            {
                return null;
            }
            List<TaskPositionSDto> result = new List<TaskPositionSDto>(p56.Count);
            
            int i = 0;
            int len = p56.Count;
            
            while (i < len)
            {
                TaskPosition item = p56[i];
                result.Add(item == null ? null : new TaskPositionSDto()
                {
                    PositionId = item.PositionId,
                    PositionName = item.Position != null ? item.Position.Name : string.Empty,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDaySDto> funcMain32(List<TaskDay> p57)
        {
            if (p57 == null)
            {
                return null;
            }
            List<TaskDaySDto> result = new List<TaskDaySDto>(p57.Count);
            
            int i = 0;
            int len = p57.Count;
            
            while (i < len)
            {
                TaskDay item = p57[i];
                result.Add(item == null ? null : new TaskDaySDto()
                {
                    DayOfWeek = item.DayOfWeek,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutineSDto> funcMain33(List<TaskRoutine> p58)
        {
            if (p58 == null)
            {
                return null;
            }
            List<TaskRoutineSDto> result = new List<TaskRoutineSDto>(p58.Count);
            
            int i = 0;
            int len = p58.Count;
            
            while (i < len)
            {
                TaskRoutine item = p58[i];
                result.Add(item == null ? null : new TaskRoutineSDto()
                {
                    TaskId = item.TaskId,
                    RoutineId = item.RoutineId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskShiftSDto> funcMain34(List<TaskShift> p61, List<TaskShiftSDto> p62)
        {
            if (p61 == null)
            {
                return null;
            }
            List<TaskShiftSDto> result = new List<TaskShiftSDto>(p61.Count);
            
            int i = 0;
            int len = p61.Count;
            
            while (i < len)
            {
                TaskShift item = p61[i];
                result.Add(item == null ? null : new TaskShiftSDto()
                {
                    ShiftId = item.ShiftId,
                    ShiftName = item.Shift != null ? item.Shift.Title : string.Empty,
                    TaskId = item.TaskId,
                    TaskTitle = item.Task != null ? item.Task.Title : string.Empty,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskPositionSDto> funcMain35(List<TaskPosition> p63, List<TaskPositionSDto> p64)
        {
            if (p63 == null)
            {
                return null;
            }
            List<TaskPositionSDto> result = new List<TaskPositionSDto>(p63.Count);
            
            int i = 0;
            int len = p63.Count;
            
            while (i < len)
            {
                TaskPosition item = p63[i];
                result.Add(item == null ? null : new TaskPositionSDto()
                {
                    PositionId = item.PositionId,
                    PositionName = item.Position != null ? item.Position.Name : string.Empty,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskDaySDto> funcMain36(List<TaskDay> p65, List<TaskDaySDto> p66)
        {
            if (p65 == null)
            {
                return null;
            }
            List<TaskDaySDto> result = new List<TaskDaySDto>(p65.Count);
            
            int i = 0;
            int len = p65.Count;
            
            while (i < len)
            {
                TaskDay item = p65[i];
                result.Add(item == null ? null : new TaskDaySDto()
                {
                    DayOfWeek = item.DayOfWeek,
                    TaskId = item.TaskId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<TaskRoutineSDto> funcMain37(List<TaskRoutine> p67, List<TaskRoutineSDto> p68)
        {
            if (p67 == null)
            {
                return null;
            }
            List<TaskRoutineSDto> result = new List<TaskRoutineSDto>(p67.Count);
            
            int i = 0;
            int len = p67.Count;
            
            while (i < len)
            {
                TaskRoutine item = p67[i];
                result.Add(item == null ? null : new TaskRoutineSDto()
                {
                    TaskId = item.TaskId,
                    RoutineId = item.RoutineId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
    }
}