175 lines
5.6 KiB
C#
175 lines
5.6 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using Brizco.Domain.Dtos.LargDtos;
|
|
using Brizco.Domain.Dtos.SmallDtos;
|
|
using Brizco.Domain.Entities.Complex;
|
|
using Mapster.Models;
|
|
|
|
namespace Brizco.Domain.Mappers
|
|
{
|
|
public static partial class PositionMapper
|
|
{
|
|
public static Position AdaptToPosition(this PositionSDto p1)
|
|
{
|
|
return p1 == null ? null : new Position()
|
|
{
|
|
Name = p1.Name,
|
|
Description = p1.Description,
|
|
ComplexId = p1.ComplexId,
|
|
SectionId = p1.SectionId,
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static Position AdaptTo(this PositionSDto p2, Position p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Position result = p3 ?? new Position();
|
|
|
|
result.Name = p2.Name;
|
|
result.Description = p2.Description;
|
|
result.ComplexId = p2.ComplexId;
|
|
result.SectionId = p2.SectionId;
|
|
result.Id = p2.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<PositionSDto, Position>> ProjectToPosition => p4 => new Position()
|
|
{
|
|
Name = p4.Name,
|
|
Description = p4.Description,
|
|
ComplexId = p4.ComplexId,
|
|
SectionId = p4.SectionId,
|
|
Id = p4.Id
|
|
};
|
|
public static PositionSDto AdaptToSDto(this Position p5)
|
|
{
|
|
return p5 == null ? null : new PositionSDto()
|
|
{
|
|
Name = p5.Name,
|
|
Description = p5.Description,
|
|
ComplexId = p5.ComplexId,
|
|
SectionId = p5.SectionId,
|
|
Id = p5.Id
|
|
};
|
|
}
|
|
public static PositionSDto AdaptTo(this Position p6, PositionSDto p7)
|
|
{
|
|
if (p6 == null)
|
|
{
|
|
return null;
|
|
}
|
|
PositionSDto result = p7 ?? new PositionSDto();
|
|
|
|
result.Name = p6.Name;
|
|
result.Description = p6.Description;
|
|
result.ComplexId = p6.ComplexId;
|
|
result.SectionId = p6.SectionId;
|
|
result.Id = p6.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Position, PositionSDto>> ProjectToSDto => p8 => new PositionSDto()
|
|
{
|
|
Name = p8.Name,
|
|
Description = p8.Description,
|
|
ComplexId = p8.ComplexId,
|
|
SectionId = p8.SectionId,
|
|
Id = p8.Id
|
|
};
|
|
public static Position AdaptToPosition(this PositionLDto p9)
|
|
{
|
|
return p9 == null ? null : new Position()
|
|
{
|
|
Name = p9.Name,
|
|
Description = p9.Description,
|
|
ComplexId = p9.ComplexId,
|
|
Complex = new Complex() {Id = p9.ComplexId},
|
|
SectionId = p9.SectionId,
|
|
Section = new Section()
|
|
{
|
|
Name = p9.SectionName,
|
|
Id = p9.SectionId
|
|
},
|
|
Id = p9.Id
|
|
};
|
|
}
|
|
public static Position AdaptTo(this PositionLDto p10, Position p11)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Position result = p11 ?? new Position();
|
|
|
|
result.Name = p10.Name;
|
|
result.Description = p10.Description;
|
|
result.ComplexId = p10.ComplexId;
|
|
result.Complex = funcMain1(new Never(), result.Complex, p10);
|
|
result.SectionId = p10.SectionId;
|
|
result.Section = funcMain2(new Never(), result.Section, p10);
|
|
result.Id = p10.Id;
|
|
return result;
|
|
|
|
}
|
|
public static PositionLDto AdaptToLDto(this Position p16)
|
|
{
|
|
return p16 == null ? null : new PositionLDto()
|
|
{
|
|
Name = p16.Name,
|
|
Description = p16.Description,
|
|
ComplexId = p16.ComplexId,
|
|
SectionId = p16.SectionId,
|
|
SectionName = p16.Section != null ? p16.Section.Name : string.Empty,
|
|
Id = p16.Id
|
|
};
|
|
}
|
|
public static PositionLDto AdaptTo(this Position p17, PositionLDto p18)
|
|
{
|
|
if (p17 == null)
|
|
{
|
|
return null;
|
|
}
|
|
PositionLDto result = p18 ?? new PositionLDto();
|
|
|
|
result.Name = p17.Name;
|
|
result.Description = p17.Description;
|
|
result.ComplexId = p17.ComplexId;
|
|
result.SectionId = p17.SectionId;
|
|
result.SectionName = p17.Section != null ? p17.Section.Name : string.Empty;
|
|
result.Id = p17.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Position, PositionLDto>> ProjectToLDto => p19 => new PositionLDto()
|
|
{
|
|
Name = p19.Name,
|
|
Description = p19.Description,
|
|
ComplexId = p19.ComplexId,
|
|
SectionId = p19.SectionId,
|
|
SectionName = p19.Section != null ? p19.Section.Name : string.Empty,
|
|
Id = p19.Id
|
|
};
|
|
|
|
private static Complex funcMain1(Never p12, Complex p13, PositionLDto p10)
|
|
{
|
|
Complex result = p13 ?? new Complex();
|
|
|
|
result.Id = p10.ComplexId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static Section funcMain2(Never p14, Section p15, PositionLDto p10)
|
|
{
|
|
Section result = p15 ?? new Section();
|
|
|
|
result.Name = p10.SectionName;
|
|
result.Id = p10.SectionId;
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |