532 lines
20 KiB
C#
532 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using Brizco.Domain.Dtos.LargeDtos;
|
|
using Brizco.Domain.Dtos.SmallDtos;
|
|
using Brizco.Domain.Entities.Complex;
|
|
using Brizco.Domain.Entities.Routine;
|
|
using Brizco.Domain.Entities.Shift;
|
|
using Brizco.Domain.Entities.User;
|
|
using Mapster.Models;
|
|
|
|
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,
|
|
Shift = new Shift()
|
|
{
|
|
Title = p1.ShiftTitle,
|
|
Id = p1.ShiftId
|
|
},
|
|
Users = funcMain1(p1.Users),
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static ShiftPlan AdaptTo(this ShiftPlanSDto p3, ShiftPlan p4)
|
|
{
|
|
if (p3 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShiftPlan result = p4 ?? new ShiftPlan();
|
|
|
|
result.PlanFor = p3.PlanFor;
|
|
result.IsCompleted = p3.IsCompleted;
|
|
result.CompletePercent = p3.CompletePercent;
|
|
result.CompleteDescription = p3.CompleteDescription;
|
|
result.ShiftId = p3.ShiftId;
|
|
result.Shift = funcMain2(new Never(), result.Shift, p3);
|
|
result.Users = funcMain3(p3.Users, result.Users);
|
|
result.Id = p3.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ShiftPlanSDto, ShiftPlan>> ProjectToShiftPlan => p9 => new ShiftPlan()
|
|
{
|
|
PlanFor = p9.PlanFor,
|
|
IsCompleted = p9.IsCompleted,
|
|
CompletePercent = p9.CompletePercent,
|
|
CompleteDescription = p9.CompleteDescription,
|
|
ShiftId = p9.ShiftId,
|
|
Shift = new Shift()
|
|
{
|
|
Title = p9.ShiftTitle,
|
|
Id = p9.ShiftId
|
|
},
|
|
Users = p9.Users.Select<ShiftPlanUserSDto, ShiftPlanUser>(p10 => new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = p10.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId},
|
|
PositionId = p10.PositionId,
|
|
Position = new Position()
|
|
{
|
|
Name = p10.PositionName,
|
|
Id = p10.PositionId
|
|
},
|
|
UserId = p10.UserId,
|
|
User = new ApplicationUser() {Id = p10.UserId},
|
|
Id = p10.Id
|
|
}).ToList<ShiftPlanUser>(),
|
|
Id = p9.Id
|
|
};
|
|
public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p11)
|
|
{
|
|
return p11 == null ? null : new ShiftPlanSDto()
|
|
{
|
|
PlanFor = p11.PlanFor,
|
|
IsCompleted = p11.IsCompleted,
|
|
CompletePercent = p11.CompletePercent,
|
|
SupervisorFullName = p11.Supervisor != null ? p11.Supervisor.FirstName + " " + p11.Supervisor.LastName : string.Empty,
|
|
CompleteDescription = p11.CompleteDescription,
|
|
ShiftId = p11.ShiftId,
|
|
ShiftTitle = p11.Shift == null ? null : p11.Shift.Title,
|
|
StartAt = p11.Shift != null ? p11.Shift.StartAt : TimeSpan.MinValue,
|
|
EndAt = p11.Shift != null ? p11.Shift.EndAt : TimeSpan.MinValue,
|
|
Users = funcMain4(p11.Users),
|
|
Id = p11.Id
|
|
};
|
|
}
|
|
public static ShiftPlanSDto AdaptTo(this ShiftPlan p13, ShiftPlanSDto p14)
|
|
{
|
|
if (p13 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShiftPlanSDto result = p14 ?? new ShiftPlanSDto();
|
|
|
|
result.PlanFor = p13.PlanFor;
|
|
result.IsCompleted = p13.IsCompleted;
|
|
result.CompletePercent = p13.CompletePercent;
|
|
result.SupervisorFullName = p13.Supervisor != null ? p13.Supervisor.FirstName + " " + p13.Supervisor.LastName : string.Empty;
|
|
result.CompleteDescription = p13.CompleteDescription;
|
|
result.ShiftId = p13.ShiftId;
|
|
result.ShiftTitle = p13.Shift == null ? null : p13.Shift.Title;
|
|
result.StartAt = p13.Shift != null ? p13.Shift.StartAt : TimeSpan.MinValue;
|
|
result.EndAt = p13.Shift != null ? p13.Shift.EndAt : TimeSpan.MinValue;
|
|
result.Users = funcMain5(p13.Users, result.Users);
|
|
result.Id = p13.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ShiftPlan, ShiftPlanSDto>> ProjectToSDto => p17 => new ShiftPlanSDto()
|
|
{
|
|
PlanFor = p17.PlanFor,
|
|
IsCompleted = p17.IsCompleted,
|
|
CompletePercent = p17.CompletePercent,
|
|
SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty,
|
|
CompleteDescription = p17.CompleteDescription,
|
|
ShiftId = p17.ShiftId,
|
|
ShiftTitle = p17.Shift.Title,
|
|
StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue,
|
|
EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue,
|
|
Users = p17.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p18 => new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = p18.ShiftPlanId,
|
|
UserId = p18.UserId,
|
|
UserFullName = p18.User != null ? p18.User.FirstName + " " + p18.User.LastName : string.Empty,
|
|
PositionId = p18.PositionId,
|
|
PositionName = p18.Position != null ? p18.Position.Name : string.Empty,
|
|
Id = p18.Id
|
|
}).ToList<ShiftPlanUserSDto>(),
|
|
Id = p17.Id
|
|
};
|
|
public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p19)
|
|
{
|
|
return p19 == null ? null : new ShiftPlan()
|
|
{
|
|
PlanFor = p19.PlanFor,
|
|
IsCompleted = p19.IsCompleted,
|
|
CompletePercent = p19.CompletePercent,
|
|
CompleteDescription = p19.CompleteDescription,
|
|
ShiftId = p19.ShiftId,
|
|
Shift = new Shift() {Id = p19.ShiftId},
|
|
RoutineId = p19.RoutineId,
|
|
Routine = new Routine() {Id = p19.RoutineId},
|
|
SupervisorId = p19.SupervisorId,
|
|
Supervisor = new ApplicationUser() {Id = p19.SupervisorId},
|
|
Users = funcMain6(p19.Users),
|
|
Id = p19.Id
|
|
};
|
|
}
|
|
public static ShiftPlan AdaptTo(this ShiftPlanLDto p21, ShiftPlan p22)
|
|
{
|
|
if (p21 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShiftPlan result = p22 ?? new ShiftPlan();
|
|
|
|
result.PlanFor = p21.PlanFor;
|
|
result.IsCompleted = p21.IsCompleted;
|
|
result.CompletePercent = p21.CompletePercent;
|
|
result.CompleteDescription = p21.CompleteDescription;
|
|
result.ShiftId = p21.ShiftId;
|
|
result.Shift = funcMain7(new Never(), result.Shift, p21);
|
|
result.RoutineId = p21.RoutineId;
|
|
result.Routine = funcMain8(new Never(), result.Routine, p21);
|
|
result.SupervisorId = p21.SupervisorId;
|
|
result.Supervisor = funcMain9(new Never(), result.Supervisor, p21);
|
|
result.Users = funcMain10(p21.Users, result.Users);
|
|
result.Id = p21.Id;
|
|
return result;
|
|
|
|
}
|
|
public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p31)
|
|
{
|
|
return p31 == null ? null : new ShiftPlanLDto()
|
|
{
|
|
PlanFor = p31.PlanFor,
|
|
RoutineId = p31.RoutineId,
|
|
IsCompleted = p31.IsCompleted,
|
|
CompletePercent = p31.CompletePercent,
|
|
CompleteDescription = p31.CompleteDescription,
|
|
ShiftId = p31.ShiftId,
|
|
Users = funcMain11(p31.Users),
|
|
SupervisorId = p31.SupervisorId,
|
|
SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty,
|
|
Id = p31.Id
|
|
};
|
|
}
|
|
public static ShiftPlanLDto AdaptTo(this ShiftPlan p33, ShiftPlanLDto p34)
|
|
{
|
|
if (p33 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ShiftPlanLDto result = p34 ?? new ShiftPlanLDto();
|
|
|
|
result.PlanFor = p33.PlanFor;
|
|
result.RoutineId = p33.RoutineId;
|
|
result.IsCompleted = p33.IsCompleted;
|
|
result.CompletePercent = p33.CompletePercent;
|
|
result.CompleteDescription = p33.CompleteDescription;
|
|
result.ShiftId = p33.ShiftId;
|
|
result.Users = funcMain12(p33.Users, result.Users);
|
|
result.SupervisorId = p33.SupervisorId;
|
|
result.SupervisorFullName = p33.Supervisor != null ? p33.Supervisor.FirstName + " " + p33.Supervisor.LastName : string.Empty;
|
|
result.Id = p33.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ShiftPlan, ShiftPlanLDto>> ProjectToLDto => p37 => new ShiftPlanLDto()
|
|
{
|
|
PlanFor = p37.PlanFor,
|
|
RoutineId = p37.RoutineId,
|
|
IsCompleted = p37.IsCompleted,
|
|
CompletePercent = p37.CompletePercent,
|
|
CompleteDescription = p37.CompleteDescription,
|
|
ShiftId = p37.ShiftId,
|
|
Users = p37.Users.Select<ShiftPlanUser, ShiftPlanUserSDto>(p38 => new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = p38.ShiftPlanId,
|
|
UserId = p38.UserId,
|
|
UserFullName = p38.User != null ? p38.User.FirstName + " " + p38.User.LastName : string.Empty,
|
|
PositionId = p38.PositionId,
|
|
PositionName = p38.Position != null ? p38.Position.Name : string.Empty,
|
|
Id = p38.Id
|
|
}).ToList<ShiftPlanUserSDto>(),
|
|
SupervisorId = p37.SupervisorId,
|
|
SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty,
|
|
Id = p37.Id
|
|
};
|
|
|
|
private static List<ShiftPlanUser> funcMain1(List<ShiftPlanUserSDto> p2)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p2.Count);
|
|
|
|
int i = 0;
|
|
int len = p2.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUserSDto item = p2[i];
|
|
result.Add(item == null ? null : new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId},
|
|
PositionId = item.PositionId,
|
|
Position = new Position()
|
|
{
|
|
Name = item.PositionName,
|
|
Id = item.PositionId
|
|
},
|
|
UserId = item.UserId,
|
|
User = new ApplicationUser() {Id = item.UserId},
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static Shift funcMain2(Never p5, Shift p6, ShiftPlanSDto p3)
|
|
{
|
|
Shift result = p6 ?? new Shift();
|
|
|
|
result.Title = p3.ShiftTitle;
|
|
result.Id = p3.ShiftId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUser> funcMain3(List<ShiftPlanUserSDto> p7, List<ShiftPlanUser> p8)
|
|
{
|
|
if (p7 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p7.Count);
|
|
|
|
int i = 0;
|
|
int len = p7.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUserSDto item = p7[i];
|
|
result.Add(item == null ? null : new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId},
|
|
PositionId = item.PositionId,
|
|
Position = new Position()
|
|
{
|
|
Name = item.PositionName,
|
|
Id = item.PositionId
|
|
},
|
|
UserId = item.UserId,
|
|
User = new ApplicationUser() {Id = item.UserId},
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUserSDto> funcMain4(List<ShiftPlanUser> p12)
|
|
{
|
|
if (p12 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p12.Count);
|
|
|
|
int i = 0;
|
|
int len = p12.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p12[i];
|
|
result.Add(item == null ? null : new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
UserId = item.UserId,
|
|
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
|
PositionId = item.PositionId,
|
|
PositionName = item.Position != null ? item.Position.Name : string.Empty,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUserSDto> funcMain5(List<ShiftPlanUser> p15, List<ShiftPlanUserSDto> p16)
|
|
{
|
|
if (p15 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p15.Count);
|
|
|
|
int i = 0;
|
|
int len = p15.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p15[i];
|
|
result.Add(item == null ? null : new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
UserId = item.UserId,
|
|
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
|
PositionId = item.PositionId,
|
|
PositionName = item.Position != null ? item.Position.Name : string.Empty,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUser> funcMain6(List<ShiftPlanUserSDto> p20)
|
|
{
|
|
if (p20 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p20.Count);
|
|
|
|
int i = 0;
|
|
int len = p20.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUserSDto item = p20[i];
|
|
result.Add(item == null ? null : new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId},
|
|
PositionId = item.PositionId,
|
|
Position = new Position()
|
|
{
|
|
Name = item.PositionName,
|
|
Id = item.PositionId
|
|
},
|
|
UserId = item.UserId,
|
|
User = new ApplicationUser() {Id = item.UserId},
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static Shift funcMain7(Never p23, Shift p24, ShiftPlanLDto p21)
|
|
{
|
|
Shift result = p24 ?? new Shift();
|
|
|
|
result.Id = p21.ShiftId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static Routine funcMain8(Never p25, Routine p26, ShiftPlanLDto p21)
|
|
{
|
|
Routine result = p26 ?? new Routine();
|
|
|
|
result.Id = p21.RoutineId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static ApplicationUser funcMain9(Never p27, ApplicationUser p28, ShiftPlanLDto p21)
|
|
{
|
|
ApplicationUser result = p28 ?? new ApplicationUser();
|
|
|
|
result.Id = p21.SupervisorId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUser> funcMain10(List<ShiftPlanUserSDto> p29, List<ShiftPlanUser> p30)
|
|
{
|
|
if (p29 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUser> result = new List<ShiftPlanUser>(p29.Count);
|
|
|
|
int i = 0;
|
|
int len = p29.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUserSDto item = p29[i];
|
|
result.Add(item == null ? null : new ShiftPlanUser()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = item.ShiftPlanId},
|
|
PositionId = item.PositionId,
|
|
Position = new Position()
|
|
{
|
|
Name = item.PositionName,
|
|
Id = item.PositionId
|
|
},
|
|
UserId = item.UserId,
|
|
User = new ApplicationUser() {Id = item.UserId},
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUserSDto> funcMain11(List<ShiftPlanUser> p32)
|
|
{
|
|
if (p32 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p32.Count);
|
|
|
|
int i = 0;
|
|
int len = p32.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p32[i];
|
|
result.Add(item == null ? null : new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
UserId = item.UserId,
|
|
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
|
PositionId = item.PositionId,
|
|
PositionName = item.Position != null ? item.Position.Name : string.Empty,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<ShiftPlanUserSDto> funcMain12(List<ShiftPlanUser> p35, List<ShiftPlanUserSDto> p36)
|
|
{
|
|
if (p35 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<ShiftPlanUserSDto> result = new List<ShiftPlanUserSDto>(p35.Count);
|
|
|
|
int i = 0;
|
|
int len = p35.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
ShiftPlanUser item = p35[i];
|
|
result.Add(item == null ? null : new ShiftPlanUserSDto()
|
|
{
|
|
ShiftPlanId = item.ShiftPlanId,
|
|
UserId = item.UserId,
|
|
UserFullName = item.User != null ? item.User.FirstName + " " + item.User.LastName : string.Empty,
|
|
PositionId = item.PositionId,
|
|
PositionName = item.Position != null ? item.Position.Name : string.Empty,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |