198 lines
6.0 KiB
C#
198 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using Brizco.Domain.Dtos.SmallDtos;
|
|
using Brizco.Domain.Entities.Complex;
|
|
using Brizco.Domain.Entities.Shift;
|
|
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,
|
|
Days = funcMain4(p11.Days != null ? p11.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>() : new List<DayOfWeek>()),
|
|
ComplexId = p11.ComplexId,
|
|
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.Days = funcMain6(p13.Days != null ? p13.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>() : new List<DayOfWeek>(), result.Days);
|
|
result.ComplexId = p13.ComplexId;
|
|
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,
|
|
Days = p17.Days != null ? p17.Days.Select<ShiftDay, DayOfWeek>(d => d.DayOfWeek).ToList<DayOfWeek>() : new List<DayOfWeek>(),
|
|
ComplexId = p17.ComplexId,
|
|
Id = p17.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;
|
|
|
|
}
|
|
}
|
|
} |