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