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.Complex; namespace Brizco.Domain.Mappers { public static partial class SectionMapper { public static Section AdaptToSection(this SectionSDto p1) { return p1 == null ? null : new Section() { Name = p1.Name, Description = p1.Description, ComplexId = p1.ComplexId, Id = p1.Id }; } public static Section AdaptTo(this SectionSDto p2, Section p3) { if (p2 == null) { return null; } Section result = p3 ?? new Section(); result.Name = p2.Name; result.Description = p2.Description; result.ComplexId = p2.ComplexId; result.Id = p2.Id; return result; } public static Expression> ProjectToSection => p4 => new Section() { Name = p4.Name, Description = p4.Description, ComplexId = p4.ComplexId, Id = p4.Id }; public static SectionSDto AdaptToSDto(this Section p5) { return p5 == null ? null : new SectionSDto() { Name = p5.Name, Description = p5.Description, ComplexId = p5.ComplexId, Id = p5.Id }; } public static SectionSDto AdaptTo(this Section p6, SectionSDto p7) { if (p6 == null) { return null; } SectionSDto result = p7 ?? new SectionSDto(); result.Name = p6.Name; result.Description = p6.Description; result.ComplexId = p6.ComplexId; result.Id = p6.Id; return result; } public static Expression> ProjectToSDto => p8 => new SectionSDto() { Name = p8.Name, Description = p8.Description, ComplexId = p8.ComplexId, Id = p8.Id }; public static Section AdaptToSection(this SectionLDto p9) { return p9 == null ? null : new Section() { Name = p9.Name, Description = p9.Description, ComplexId = p9.ComplexId, Positions = funcMain1(p9.Positions), Id = p9.Id }; } public static Section AdaptTo(this SectionLDto p11, Section p12) { if (p11 == null) { return null; } Section result = p12 ?? new Section(); result.Name = p11.Name; result.Description = p11.Description; result.ComplexId = p11.ComplexId; result.Positions = funcMain2(p11.Positions, result.Positions); result.Id = p11.Id; return result; } public static Expression> ProjectLDtoToSection => p15 => new Section() { Name = p15.Name, Description = p15.Description, ComplexId = p15.ComplexId, Positions = p15.Positions.Select(p16 => new Position() { Name = p16.Name, Description = p16.Description, ComplexId = p16.ComplexId, SectionId = p16.SectionId, Id = p16.Id }).ToList(), Id = p15.Id }; public static SectionLDto AdaptToLDto(this Section p17) { return p17 == null ? null : new SectionLDto() { Name = p17.Name, Description = p17.Description, ComplexId = p17.ComplexId, Positions = funcMain3(p17.Positions), Id = p17.Id }; } public static SectionLDto AdaptTo(this Section p19, SectionLDto p20) { if (p19 == null) { return null; } SectionLDto result = p20 ?? new SectionLDto(); result.Name = p19.Name; result.Description = p19.Description; result.ComplexId = p19.ComplexId; result.Positions = funcMain4(p19.Positions, result.Positions); result.Id = p19.Id; return result; } public static Expression> ProjectToLDto => p23 => new SectionLDto() { Name = p23.Name, Description = p23.Description, ComplexId = p23.ComplexId, Positions = p23.Positions.Select(p24 => new PositionSDto() { Name = p24.Name, Description = p24.Description, ComplexId = p24.ComplexId, SectionId = p24.SectionId, Id = p24.Id }).ToList(), Id = p23.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) { PositionSDto item = p10[i]; result.Add(item == null ? null : new Position() { Name = item.Name, Description = item.Description, ComplexId = item.ComplexId, SectionId = item.SectionId, 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) { PositionSDto item = p13[i]; result.Add(item == null ? null : new Position() { Name = item.Name, Description = item.Description, ComplexId = item.ComplexId, SectionId = item.SectionId, Id = item.Id }); i++; } return result; } private static List funcMain3(List p18) { if (p18 == null) { return null; } List result = new List(p18.Count); int i = 0; int len = p18.Count; while (i < len) { Position item = p18[i]; result.Add(item == null ? null : new PositionSDto() { Name = item.Name, Description = item.Description, ComplexId = item.ComplexId, SectionId = item.SectionId, Id = item.Id }); i++; } return result; } private static List funcMain4(List p21, List p22) { if (p21 == null) { return null; } List result = new List(p21.Count); int i = 0; int len = p21.Count; while (i < len) { Position item = p21[i]; result.Add(item == null ? null : new PositionSDto() { Name = item.Name, Description = item.Description, ComplexId = item.ComplexId, SectionId = item.SectionId, Id = item.Id }); i++; } return result; } } }