295 lines
10 KiB
C#
295 lines
10 KiB
C#
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()
|
|
{
|
|
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.IsCompleted = p2.IsCompleted;
|
|
result.CompletePercent = p2.CompletePercent;
|
|
result.CompleteDescription = p2.CompleteDescription;
|
|
result.ShiftId = p2.ShiftId;
|
|
result.Id = p2.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p4 => new ShiftPlan()
|
|
{
|
|
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()
|
|
{
|
|
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.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<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p8 => new ShiftPlanSDto()
|
|
{
|
|
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 Expression<Func<ShiftPlanLDto, ShiftPlan>> ProjectLDtoToShiftPlan => p15 => new ShiftPlan()
|
|
{
|
|
PlanFor = p15.PlanFor,
|
|
IsCompleted = p15.IsCompleted,
|
|
CompletePercent = p15.CompletePercent,
|
|
CompleteDescription = p15.CompleteDescription,
|
|
ShiftId = p15.ShiftId,
|
|
RoutineId = p15.RoutineId,
|
|
Users = p15.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p16 => new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = p16.ShiftPlanId,
|
|
PositionId = p16.PositionId,
|
|
UserId = p16.UserId,
|
|
Id = p16.Id
|
|
}).ToList<ShiftPlanUser>(),
|
|
Id = p15.Id
|
|
};
|
|
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p17)
|
|
{
|
|
return p17 == null ? null : new ShiftPlanLDto()
|
|
{
|
|
PlanFor = p17.PlanFor,
|
|
RoutineId = p17.RoutineId,
|
|
IsCompleted = p17.IsCompleted,
|
|
CompletePercent = p17.CompletePercent,
|
|
CompleteDescription = p17.CompleteDescription,
|
|
ShiftId = p17.ShiftId,
|
|
Users = funcMain3(p17.Users),
|
|
Id = p17.Id
|
|
};
|
|
}
|
|
public static ShiftPlanLDto AdaptTo(this ShiftPlan p19, ShiftPlanLDto p20)
|
|
{
|
|
if (p19 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShiftPlanLDto result = p20 ?? new ShiftPlanLDto();
|
|
|
|
result.PlanFor = p19.PlanFor;
|
|
result.RoutineId = p19.RoutineId;
|
|
result.IsCompleted = p19.IsCompleted;
|
|
result.CompletePercent = p19.CompletePercent;
|
|
result.CompleteDescription = p19.CompleteDescription;
|
|
result.ShiftId = p19.ShiftId;
|
|
result.Users = funcMain4(p19.Users, result.Users);
|
|
result.Id = p19.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p23 => new ShiftPlanLDto()
|
|
{
|
|
PlanFor = p23.PlanFor,
|
|
RoutineId = p23.RoutineId,
|
|
IsCompleted = p23.IsCompleted,
|
|
CompletePercent = p23.CompletePercent,
|
|
CompleteDescription = p23.CompleteDescription,
|
|
ShiftId = p23.ShiftId,
|
|
Users = p23.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p24 => new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = p24.ShiftPlanId,
|
|
UserId = p24.UserId,
|
|
PositionId = p24.PositionId,
|
|
Id = p24.Id
|
|
}).ToList<ShiftPlanUserSDto>(),
|
|
Id = p23.Id
|
|
};
|
|
|
|
private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p10)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(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<ShiftPlanUser> funcMain2(List<ShiftPlanUserSDto> p13, List<ShiftPlanUser> p14)
|
|
{
|
|
if (p13 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(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<ShiftPlanUserSDto> funcMain3(List<ShiftPlanUser> p18)
|
|
{
|
|
if (p18 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p18.Count);
|
|
|
|
int i = 0;
|
|
int len = p18.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p18[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<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p21, List<ShiftPlanUserSDto> p22)
|
|
{
|
|
if (p21 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p21.Count);
|
|
|
|
int i = 0;
|
|
int len = p21.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p21[i];
|
|
result.Add(item == null ? null : new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
UserId = item.UserId,
|
|
PositionId = item.PositionId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |