using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargDtos; using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Shift; namespace Brizco.Domain.Mappers { public static partial class ShiftPlanMapper { public static ShiftPlan AdaptToShiftPlan(this ShiftPlanSDto p1) { return p1 == null ? null : new ShiftPlan() { PlanFor = p1.PlanFor, IsCompleted = p1.IsCompleted, CompletePercent = p1.CompletePercent, CompleteDescription = p1.CompleteDescription, ShiftId = p1.ShiftId, Id = p1.Id }; } public static ShiftPlan AdaptTo(this ShiftPlanSDto p2, ShiftPlan p3) { if (p2 == null) { return null; } ShiftPlan result = p3 ?? new ShiftPlan(); result.PlanFor = p2.PlanFor; result.IsCompleted = p2.IsCompleted; result.CompletePercent = p2.CompletePercent; result.CompleteDescription = p2.CompleteDescription; result.ShiftId = p2.ShiftId; result.Id = p2.Id; return result; } public static Expression> ProjectToShiftPlan => p4 => new ShiftPlan() { PlanFor = p4.PlanFor, IsCompleted = p4.IsCompleted, CompletePercent = p4.CompletePercent, CompleteDescription = p4.CompleteDescription, ShiftId = p4.ShiftId, Id = p4.Id }; public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p5) { return p5 == null ? null : new ShiftPlanSDto() { PlanFor = p5.PlanFor, IsCompleted = p5.IsCompleted, CompletePercent = p5.CompletePercent, CompleteDescription = p5.CompleteDescription, ShiftId = p5.ShiftId, ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, Id = p5.Id }; } public static ShiftPlanSDto AdaptTo(this ShiftPlan p6, ShiftPlanSDto p7) { if (p6 == null) { return null; } ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); result.PlanFor = p6.PlanFor; result.IsCompleted = p6.IsCompleted; result.CompletePercent = p6.CompletePercent; result.CompleteDescription = p6.CompleteDescription; result.ShiftId = p6.ShiftId; result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; result.Id = p6.Id; return result; } public static Expression> ProjectToSDto => p8 => new ShiftPlanSDto() { PlanFor = p8.PlanFor, IsCompleted = p8.IsCompleted, CompletePercent = p8.CompletePercent, CompleteDescription = p8.CompleteDescription, ShiftId = p8.ShiftId, ShiftTitle = p8.Shift.Title, Id = p8.Id }; public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p9) { return p9 == null ? null : new ShiftPlan() { PlanFor = p9.PlanFor, IsCompleted = p9.IsCompleted, CompletePercent = p9.CompletePercent, CompleteDescription = p9.CompleteDescription, ShiftId = p9.ShiftId, RoutineId = p9.RoutineId, Users = funcMain1(p9.Users), Id = p9.Id }; } public static ShiftPlan AdaptTo(this ShiftPlanLDto p11, ShiftPlan p12) { if (p11 == null) { return null; } ShiftPlan result = p12 ?? new ShiftPlan(); result.PlanFor = p11.PlanFor; result.IsCompleted = p11.IsCompleted; result.CompletePercent = p11.CompletePercent; result.CompleteDescription = p11.CompleteDescription; result.ShiftId = p11.ShiftId; result.RoutineId = p11.RoutineId; result.Users = funcMain2(p11.Users, result.Users); result.Id = p11.Id; return result; } public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p15) { return p15 == null ? null : new ShiftPlanLDto() { PlanFor = p15.PlanFor, RoutineId = p15.RoutineId, IsCompleted = p15.IsCompleted, CompletePercent = p15.CompletePercent, CompleteDescription = p15.CompleteDescription, ShiftId = p15.ShiftId, Users = funcMain3(p15.Users), Id = p15.Id }; } public static ShiftPlanLDto AdaptTo(this ShiftPlan p17, ShiftPlanLDto p18) { if (p17 == null) { return null; } ShiftPlanLDto result = p18 ?? new ShiftPlanLDto(); result.PlanFor = p17.PlanFor; result.RoutineId = p17.RoutineId; result.IsCompleted = p17.IsCompleted; result.CompletePercent = p17.CompletePercent; result.CompleteDescription = p17.CompleteDescription; result.ShiftId = p17.ShiftId; result.Users = funcMain4(p17.Users, result.Users); result.Id = p17.Id; return result; } public static Expression> ProjectToLDto => p21 => new ShiftPlanLDto() { PlanFor = p21.PlanFor, RoutineId = p21.RoutineId, IsCompleted = p21.IsCompleted, CompletePercent = p21.CompletePercent, CompleteDescription = p21.CompleteDescription, ShiftId = p21.ShiftId, Users = p21.Users.Select(p22 => new ShiftPlanUserSDto() { ShiftPlanId = p22.ShiftPlanId, UserId = p22.UserId, PositionId = p22.PositionId, Id = p22.Id }).ToList(), Id = p21.Id }; private static List funcMain1(List p10) { if (p10 == null) { return null; } List result = new List(p10.Count); int i = 0; int len = p10.Count; while (i < len) { ShiftPlanUserSDto item = p10[i]; result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, PositionId = item.PositionId, UserId = item.UserId, Id = item.Id }); i++; } return result; } private static List funcMain2(List p13, List p14) { if (p13 == null) { return null; } List result = new List(p13.Count); int i = 0; int len = p13.Count; while (i < len) { ShiftPlanUserSDto item = p13[i]; result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, PositionId = item.PositionId, UserId = item.UserId, Id = item.Id }); i++; } return result; } private static List funcMain3(List p16) { if (p16 == null) { return null; } List result = new List(p16.Count); int i = 0; int len = p16.Count; while (i < len) { ShiftPlanUser item = p16[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, UserId = item.UserId, PositionId = item.PositionId, Id = item.Id }); i++; } return result; } private static List funcMain4(List p19, List p20) { if (p19 == null) { return null; } List result = new List(p19.Count); int i = 0; int len = p19.Count; while (i < len) { ShiftPlanUser item = p19[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, UserId = item.UserId, PositionId = item.PositionId, Id = item.Id }); i++; } return result; } } }