314 lines
12 KiB
C#
314 lines
12 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using Brizco.Domain.Dtos.LargeDtos;
|
|
using Brizco.Domain.Dtos.SmallDtos;
|
|
using Brizco.Domain.Entities.ShiftPlans;
|
|
using Brizco.Domain.Entities.Tasks;
|
|
using Brizco.Domain.Entities.Users;
|
|
using Mapster.Models;
|
|
|
|
namespace Brizco.Domain.Mappers
|
|
{
|
|
public static partial class ActivityMapper
|
|
{
|
|
public static Activity AdaptToActivity(this ActivitySDto p1)
|
|
{
|
|
return p1 == null ? null : new Activity()
|
|
{
|
|
Status = p1.Status,
|
|
DoneAt = p1.DoneAt,
|
|
IsDone = p1.IsDone,
|
|
UnDoneReason = p1.UnDoneReason,
|
|
PerformanceDescription = p1.PerformanceDescription,
|
|
UserId = p1.UserId,
|
|
User = new ApplicationUser()
|
|
{
|
|
FirstName = p1.UserFirstName,
|
|
LastName = p1.UserLastName,
|
|
Id = p1.UserId
|
|
},
|
|
ShiftPlanId = p1.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId},
|
|
Type = p1.Type,
|
|
Title = p1.Title,
|
|
Description = p1.Description,
|
|
IsDisposable = p1.IsDisposable,
|
|
SetFor = p1.SetFor,
|
|
HasDisposed = p1.HasDisposed,
|
|
ScheduleType = p1.ScheduleType,
|
|
Amount = p1.Amount,
|
|
AmountType = p1.AmountType,
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static Activity AdaptTo(this ActivitySDto p2, Activity p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Activity result = p3 ?? new Activity();
|
|
|
|
result.Status = p2.Status;
|
|
result.DoneAt = p2.DoneAt;
|
|
result.IsDone = p2.IsDone;
|
|
result.UnDoneReason = p2.UnDoneReason;
|
|
result.PerformanceDescription = p2.PerformanceDescription;
|
|
result.UserId = p2.UserId;
|
|
result.User = funcMain1(new Never(), result.User, p2);
|
|
result.ShiftPlanId = p2.ShiftPlanId;
|
|
result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2);
|
|
result.Type = p2.Type;
|
|
result.Title = p2.Title;
|
|
result.Description = p2.Description;
|
|
result.IsDisposable = p2.IsDisposable;
|
|
result.SetFor = p2.SetFor;
|
|
result.HasDisposed = p2.HasDisposed;
|
|
result.ScheduleType = p2.ScheduleType;
|
|
result.Amount = p2.Amount;
|
|
result.AmountType = p2.AmountType;
|
|
result.Id = p2.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<ActivitySDto, Activity>> ProjectToActivity => p8 => new Activity()
|
|
{
|
|
Status = p8.Status,
|
|
DoneAt = p8.DoneAt,
|
|
IsDone = p8.IsDone,
|
|
UnDoneReason = p8.UnDoneReason,
|
|
PerformanceDescription = p8.PerformanceDescription,
|
|
UserId = p8.UserId,
|
|
User = new ApplicationUser()
|
|
{
|
|
FirstName = p8.UserFirstName,
|
|
LastName = p8.UserLastName,
|
|
Id = p8.UserId
|
|
},
|
|
ShiftPlanId = p8.ShiftPlanId,
|
|
ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId},
|
|
Type = p8.Type,
|
|
Title = p8.Title,
|
|
Description = p8.Description,
|
|
IsDisposable = p8.IsDisposable,
|
|
SetFor = p8.SetFor,
|
|
HasDisposed = p8.HasDisposed,
|
|
ScheduleType = p8.ScheduleType,
|
|
Amount = p8.Amount,
|
|
AmountType = p8.AmountType,
|
|
Id = p8.Id
|
|
};
|
|
public static ActivitySDto AdaptToSDto(this Activity p9)
|
|
{
|
|
return p9 == null ? null : new ActivitySDto()
|
|
{
|
|
Type = p9.Type,
|
|
Title = p9.Title,
|
|
Description = p9.Description,
|
|
IsDisposable = p9.IsDisposable,
|
|
SetFor = p9.SetFor,
|
|
HasDisposed = p9.HasDisposed,
|
|
ScheduleType = p9.ScheduleType,
|
|
UnDoneReason = p9.UnDoneReason,
|
|
Status = p9.Status,
|
|
DoneAt = p9.DoneAt,
|
|
IsDone = p9.IsDone,
|
|
ShiftTitle = p9.ShiftPlan != null ? (p9.ShiftPlan.Shift != null ? p9.ShiftPlan.Shift.Title : string.Empty) : string.Empty,
|
|
PerformanceDescription = p9.PerformanceDescription,
|
|
UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty,
|
|
UserLastName = p9.User != null ? p9.User.LastName : string.Empty,
|
|
UserId = p9.UserId,
|
|
Amount = p9.Amount,
|
|
ShiftPlanId = p9.ShiftPlanId,
|
|
AmountType = p9.AmountType,
|
|
Id = p9.Id
|
|
};
|
|
}
|
|
public static ActivitySDto AdaptTo(this Activity p10, ActivitySDto p11)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ActivitySDto result = p11 ?? new ActivitySDto();
|
|
|
|
result.Type = p10.Type;
|
|
result.Title = p10.Title;
|
|
result.Description = p10.Description;
|
|
result.IsDisposable = p10.IsDisposable;
|
|
result.SetFor = p10.SetFor;
|
|
result.HasDisposed = p10.HasDisposed;
|
|
result.ScheduleType = p10.ScheduleType;
|
|
result.UnDoneReason = p10.UnDoneReason;
|
|
result.Status = p10.Status;
|
|
result.DoneAt = p10.DoneAt;
|
|
result.IsDone = p10.IsDone;
|
|
result.ShiftTitle = p10.ShiftPlan != null ? (p10.ShiftPlan.Shift != null ? p10.ShiftPlan.Shift.Title : string.Empty) : string.Empty;
|
|
result.PerformanceDescription = p10.PerformanceDescription;
|
|
result.UserFirstName = p10.User != null ? p10.User.FirstName : string.Empty;
|
|
result.UserLastName = p10.User != null ? p10.User.LastName : string.Empty;
|
|
result.UserId = p10.UserId;
|
|
result.Amount = p10.Amount;
|
|
result.ShiftPlanId = p10.ShiftPlanId;
|
|
result.AmountType = p10.AmountType;
|
|
result.Id = p10.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Activity, ActivitySDto>> ProjectToSDto => p12 => new ActivitySDto()
|
|
{
|
|
Type = p12.Type,
|
|
Title = p12.Title,
|
|
Description = p12.Description,
|
|
IsDisposable = p12.IsDisposable,
|
|
SetFor = p12.SetFor,
|
|
HasDisposed = p12.HasDisposed,
|
|
ScheduleType = p12.ScheduleType,
|
|
UnDoneReason = p12.UnDoneReason,
|
|
Status = p12.Status,
|
|
DoneAt = p12.DoneAt,
|
|
IsDone = p12.IsDone,
|
|
ShiftTitle = p12.ShiftPlan != null ? (p12.ShiftPlan.Shift != null ? p12.ShiftPlan.Shift.Title : string.Empty) : string.Empty,
|
|
PerformanceDescription = p12.PerformanceDescription,
|
|
UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty,
|
|
UserLastName = p12.User != null ? p12.User.LastName : string.Empty,
|
|
UserId = p12.UserId,
|
|
Amount = p12.Amount,
|
|
ShiftPlanId = p12.ShiftPlanId,
|
|
AmountType = p12.AmountType,
|
|
Id = p12.Id
|
|
};
|
|
public static Activity AdaptToActivity(this ActivityLDto p13)
|
|
{
|
|
return p13 == null ? null : new Activity()
|
|
{
|
|
Status = p13.Status,
|
|
DoneAt = p13.DoneAt,
|
|
IsDone = p13.IsDone,
|
|
PerformanceDescription = p13.PerformanceDescription,
|
|
UserId = p13.UserId,
|
|
Type = p13.Type,
|
|
Title = p13.Title,
|
|
Description = p13.Description,
|
|
IsDisposable = p13.IsDisposable,
|
|
SetFor = p13.SetFor,
|
|
HasDisposed = p13.HasDisposed,
|
|
ScheduleType = p13.ScheduleType,
|
|
Amount = p13.Amount,
|
|
AmountType = p13.AmountType,
|
|
Id = p13.Id
|
|
};
|
|
}
|
|
public static Activity AdaptTo(this ActivityLDto p14, Activity p15)
|
|
{
|
|
if (p14 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Activity result = p15 ?? new Activity();
|
|
|
|
result.Status = p14.Status;
|
|
result.DoneAt = p14.DoneAt;
|
|
result.IsDone = p14.IsDone;
|
|
result.PerformanceDescription = p14.PerformanceDescription;
|
|
result.UserId = p14.UserId;
|
|
result.Type = p14.Type;
|
|
result.Title = p14.Title;
|
|
result.Description = p14.Description;
|
|
result.IsDisposable = p14.IsDisposable;
|
|
result.SetFor = p14.SetFor;
|
|
result.HasDisposed = p14.HasDisposed;
|
|
result.ScheduleType = p14.ScheduleType;
|
|
result.Amount = p14.Amount;
|
|
result.AmountType = p14.AmountType;
|
|
result.Id = p14.Id;
|
|
return result;
|
|
|
|
}
|
|
public static ActivityLDto AdaptToLDto(this Activity p16)
|
|
{
|
|
return p16 == null ? null : new ActivityLDto()
|
|
{
|
|
Type = p16.Type,
|
|
Title = p16.Title,
|
|
Description = p16.Description,
|
|
IsDisposable = p16.IsDisposable,
|
|
SetFor = p16.SetFor,
|
|
HasDisposed = p16.HasDisposed,
|
|
Status = p16.Status,
|
|
ScheduleType = p16.ScheduleType,
|
|
DoneAt = p16.DoneAt,
|
|
IsDone = p16.IsDone,
|
|
PerformanceDescription = p16.PerformanceDescription,
|
|
UserId = p16.UserId,
|
|
Amount = p16.Amount,
|
|
AmountType = p16.AmountType,
|
|
Id = p16.Id
|
|
};
|
|
}
|
|
public static ActivityLDto AdaptTo(this Activity p17, ActivityLDto p18)
|
|
{
|
|
if (p17 == null)
|
|
{
|
|
return null;
|
|
}
|
|
ActivityLDto result = p18 ?? new ActivityLDto();
|
|
|
|
result.Type = p17.Type;
|
|
result.Title = p17.Title;
|
|
result.Description = p17.Description;
|
|
result.IsDisposable = p17.IsDisposable;
|
|
result.SetFor = p17.SetFor;
|
|
result.HasDisposed = p17.HasDisposed;
|
|
result.Status = p17.Status;
|
|
result.ScheduleType = p17.ScheduleType;
|
|
result.DoneAt = p17.DoneAt;
|
|
result.IsDone = p17.IsDone;
|
|
result.PerformanceDescription = p17.PerformanceDescription;
|
|
result.UserId = p17.UserId;
|
|
result.Amount = p17.Amount;
|
|
result.AmountType = p17.AmountType;
|
|
result.Id = p17.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Activity, ActivityLDto>> ProjectToLDto => p19 => new ActivityLDto()
|
|
{
|
|
Type = p19.Type,
|
|
Title = p19.Title,
|
|
Description = p19.Description,
|
|
IsDisposable = p19.IsDisposable,
|
|
SetFor = p19.SetFor,
|
|
HasDisposed = p19.HasDisposed,
|
|
Status = p19.Status,
|
|
ScheduleType = p19.ScheduleType,
|
|
DoneAt = p19.DoneAt,
|
|
IsDone = p19.IsDone,
|
|
PerformanceDescription = p19.PerformanceDescription,
|
|
UserId = p19.UserId,
|
|
Amount = p19.Amount,
|
|
AmountType = p19.AmountType,
|
|
Id = p19.Id
|
|
};
|
|
|
|
private static ApplicationUser funcMain1(Never p4, ApplicationUser p5, ActivitySDto p2)
|
|
{
|
|
ApplicationUser result = p5 ?? new ApplicationUser();
|
|
|
|
result.FirstName = p2.UserFirstName;
|
|
result.LastName = p2.UserLastName;
|
|
result.Id = p2.UserId;
|
|
return result;
|
|
|
|
}
|
|
|
|
private static ShiftPlan funcMain2(Never p6, ShiftPlan p7, ActivitySDto p2)
|
|
{
|
|
ShiftPlan result = p7 ?? new ShiftPlan();
|
|
|
|
result.Id = p2.ShiftPlanId;
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |