443 lines
14 KiB
C#
443 lines
14 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.Task;
|
|
using Task = Brizco.Domain.Entities.Task.Task;
|
|
|
|
namespace Brizco.Domain.Mappers
|
|
{
|
|
public static partial class TaskMapper
|
|
{
|
|
public static Task AdaptToTask(this TaskSDto p1)
|
|
{
|
|
return p1 == null ? null : new Task()
|
|
{
|
|
Type = p1.Type,
|
|
Title = p1.Title,
|
|
Description = p1.Description,
|
|
IsDisposable = p1.IsDisposable,
|
|
SetFor = p1.SetFor,
|
|
HasDisposed = p1.HasDisposed,
|
|
ComplexId = p1.ComplexId,
|
|
Amount = p1.Amount,
|
|
AmountType = p1.AmountType,
|
|
Id = p1.Id
|
|
};
|
|
}
|
|
public static Task AdaptTo(this TaskSDto p2, Task p3)
|
|
{
|
|
if (p2 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Task result = p3 ?? new Task();
|
|
|
|
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.ComplexId = p2.ComplexId;
|
|
result.Amount = p2.Amount;
|
|
result.AmountType = p2.AmountType;
|
|
result.Id = p2.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<TaskSDto, Task>> ProjectToTask => p4 => new Task()
|
|
{
|
|
Type = p4.Type,
|
|
Title = p4.Title,
|
|
Description = p4.Description,
|
|
IsDisposable = p4.IsDisposable,
|
|
SetFor = p4.SetFor,
|
|
HasDisposed = p4.HasDisposed,
|
|
ComplexId = p4.ComplexId,
|
|
Amount = p4.Amount,
|
|
AmountType = p4.AmountType,
|
|
Id = p4.Id
|
|
};
|
|
public static TaskSDto AdaptToSDto(this Task p5)
|
|
{
|
|
return p5 == null ? null : new TaskSDto()
|
|
{
|
|
Type = p5.Type,
|
|
Title = p5.Title,
|
|
Description = p5.Description,
|
|
IsDisposable = p5.IsDisposable,
|
|
SetFor = p5.SetFor,
|
|
HasDisposed = p5.HasDisposed,
|
|
ComplexId = p5.ComplexId,
|
|
Amount = p5.Amount,
|
|
AmountType = p5.AmountType,
|
|
Id = p5.Id
|
|
};
|
|
}
|
|
public static TaskSDto AdaptTo(this Task p6, TaskSDto p7)
|
|
{
|
|
if (p6 == null)
|
|
{
|
|
return null;
|
|
}
|
|
TaskSDto result = p7 ?? new TaskSDto();
|
|
|
|
result.Type = p6.Type;
|
|
result.Title = p6.Title;
|
|
result.Description = p6.Description;
|
|
result.IsDisposable = p6.IsDisposable;
|
|
result.SetFor = p6.SetFor;
|
|
result.HasDisposed = p6.HasDisposed;
|
|
result.ComplexId = p6.ComplexId;
|
|
result.Amount = p6.Amount;
|
|
result.AmountType = p6.AmountType;
|
|
result.Id = p6.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Task, TaskSDto>> ProjectToSDto => p8 => new TaskSDto()
|
|
{
|
|
Type = p8.Type,
|
|
Title = p8.Title,
|
|
Description = p8.Description,
|
|
IsDisposable = p8.IsDisposable,
|
|
SetFor = p8.SetFor,
|
|
HasDisposed = p8.HasDisposed,
|
|
ComplexId = p8.ComplexId,
|
|
Amount = p8.Amount,
|
|
AmountType = p8.AmountType,
|
|
Id = p8.Id
|
|
};
|
|
public static Task AdaptToTask(this TaskLDto p9)
|
|
{
|
|
return p9 == null ? null : new Task()
|
|
{
|
|
Type = p9.Type,
|
|
Title = p9.Title,
|
|
Description = p9.Description,
|
|
IsDisposable = p9.IsDisposable,
|
|
SetFor = p9.SetFor,
|
|
HasDisposed = p9.HasDisposed,
|
|
Amount = p9.Amount,
|
|
AmountType = p9.AmountType,
|
|
Shifts = funcMain1(p9.Shifts),
|
|
Positions = funcMain2(p9.Positions),
|
|
Id = p9.Id
|
|
};
|
|
}
|
|
public static Task AdaptTo(this TaskLDto p12, Task p13)
|
|
{
|
|
if (p12 == null)
|
|
{
|
|
return null;
|
|
}
|
|
Task result = p13 ?? new Task();
|
|
|
|
result.Type = p12.Type;
|
|
result.Title = p12.Title;
|
|
result.Description = p12.Description;
|
|
result.IsDisposable = p12.IsDisposable;
|
|
result.SetFor = p12.SetFor;
|
|
result.HasDisposed = p12.HasDisposed;
|
|
result.Amount = p12.Amount;
|
|
result.AmountType = p12.AmountType;
|
|
result.Shifts = funcMain3(p12.Shifts, result.Shifts);
|
|
result.Positions = funcMain4(p12.Positions, result.Positions);
|
|
result.Id = p12.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<TaskLDto, Task>> ProjectLDtoToTask => p18 => new Task()
|
|
{
|
|
Type = p18.Type,
|
|
Title = p18.Title,
|
|
Description = p18.Description,
|
|
IsDisposable = p18.IsDisposable,
|
|
SetFor = p18.SetFor,
|
|
HasDisposed = p18.HasDisposed,
|
|
Amount = p18.Amount,
|
|
AmountType = p18.AmountType,
|
|
Shifts = p18.Shifts.Select<TaskShiftSDto, TaskShift>(p19 => new TaskShift()
|
|
{
|
|
TaskId = p19.TaskId,
|
|
ShiftId = p19.ShiftId
|
|
}).ToList<TaskShift>(),
|
|
Positions = p18.Positions.Select<TaskPositionSDto, TaskPosition>(p20 => new TaskPosition()
|
|
{
|
|
PositionId = p20.PositionId,
|
|
TaskId = p20.TaskId,
|
|
Id = p20.Id
|
|
}).ToList<TaskPosition>(),
|
|
Id = p18.Id
|
|
};
|
|
public static TaskLDto AdaptToLDto(this Task p21)
|
|
{
|
|
return p21 == null ? null : new TaskLDto()
|
|
{
|
|
Type = p21.Type,
|
|
Title = p21.Title,
|
|
Description = p21.Description,
|
|
IsDisposable = p21.IsDisposable,
|
|
SetFor = p21.SetFor,
|
|
HasDisposed = p21.HasDisposed,
|
|
Amount = p21.Amount,
|
|
AmountType = p21.AmountType,
|
|
Shifts = funcMain5(p21.Shifts),
|
|
Positions = funcMain6(p21.Positions),
|
|
Id = p21.Id
|
|
};
|
|
}
|
|
public static TaskLDto AdaptTo(this Task p24, TaskLDto p25)
|
|
{
|
|
if (p24 == null)
|
|
{
|
|
return null;
|
|
}
|
|
TaskLDto result = p25 ?? new TaskLDto();
|
|
|
|
result.Type = p24.Type;
|
|
result.Title = p24.Title;
|
|
result.Description = p24.Description;
|
|
result.IsDisposable = p24.IsDisposable;
|
|
result.SetFor = p24.SetFor;
|
|
result.HasDisposed = p24.HasDisposed;
|
|
result.Amount = p24.Amount;
|
|
result.AmountType = p24.AmountType;
|
|
result.Shifts = funcMain7(p24.Shifts, result.Shifts);
|
|
result.Positions = funcMain8(p24.Positions, result.Positions);
|
|
result.Id = p24.Id;
|
|
return result;
|
|
|
|
}
|
|
public static Expression<Func<Task, TaskLDto>> ProjectToLDto => p30 => new TaskLDto()
|
|
{
|
|
Type = p30.Type,
|
|
Title = p30.Title,
|
|
Description = p30.Description,
|
|
IsDisposable = p30.IsDisposable,
|
|
SetFor = p30.SetFor,
|
|
HasDisposed = p30.HasDisposed,
|
|
Amount = p30.Amount,
|
|
AmountType = p30.AmountType,
|
|
Shifts = p30.Shifts.Select<TaskShift, TaskShiftSDto>(p31 => new TaskShiftSDto()
|
|
{
|
|
ShiftId = p31.ShiftId,
|
|
TaskId = p31.TaskId
|
|
}).ToList<TaskShiftSDto>(),
|
|
Positions = p30.Positions.Select<TaskPosition, TaskPositionSDto>(p32 => new TaskPositionSDto()
|
|
{
|
|
PositionId = p32.PositionId,
|
|
TaskId = p32.TaskId,
|
|
Id = p32.Id
|
|
}).ToList<TaskPositionSDto>(),
|
|
Id = p30.Id
|
|
};
|
|
|
|
private static List<TaskShift> funcMain1(List<TaskShiftSDto> p10)
|
|
{
|
|
if (p10 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskShift> result = new List<TaskShift>(p10.Count);
|
|
|
|
int i = 0;
|
|
int len = p10.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskShiftSDto item = p10[i];
|
|
result.Add(item == null ? null : new TaskShift()
|
|
{
|
|
TaskId = item.TaskId,
|
|
ShiftId = item.ShiftId
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskPosition> funcMain2(List<TaskPositionSDto> p11)
|
|
{
|
|
if (p11 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskPosition> result = new List<TaskPosition>(p11.Count);
|
|
|
|
int i = 0;
|
|
int len = p11.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskPositionSDto item = p11[i];
|
|
result.Add(item == null ? null : new TaskPosition()
|
|
{
|
|
PositionId = item.PositionId,
|
|
TaskId = item.TaskId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskShift> funcMain3(List<TaskShiftSDto> p14, List<TaskShift> p15)
|
|
{
|
|
if (p14 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskShift> result = new List<TaskShift>(p14.Count);
|
|
|
|
int i = 0;
|
|
int len = p14.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskShiftSDto item = p14[i];
|
|
result.Add(item == null ? null : new TaskShift()
|
|
{
|
|
TaskId = item.TaskId,
|
|
ShiftId = item.ShiftId
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskPosition> funcMain4(List<TaskPositionSDto> p16, List<TaskPosition> p17)
|
|
{
|
|
if (p16 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskPosition> result = new List<TaskPosition>(p16.Count);
|
|
|
|
int i = 0;
|
|
int len = p16.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskPositionSDto item = p16[i];
|
|
result.Add(item == null ? null : new TaskPosition()
|
|
{
|
|
PositionId = item.PositionId,
|
|
TaskId = item.TaskId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskShiftSDto> funcMain5(List<TaskShift> p22)
|
|
{
|
|
if (p22 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p22.Count);
|
|
|
|
int i = 0;
|
|
int len = p22.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskShift item = p22[i];
|
|
result.Add(item == null ? null : new TaskShiftSDto()
|
|
{
|
|
ShiftId = item.ShiftId,
|
|
TaskId = item.TaskId
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskPositionSDto> funcMain6(List<TaskPosition> p23)
|
|
{
|
|
if (p23 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskPositionSDto> result = new List<TaskPositionSDto>(p23.Count);
|
|
|
|
int i = 0;
|
|
int len = p23.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskPosition item = p23[i];
|
|
result.Add(item == null ? null : new TaskPositionSDto()
|
|
{
|
|
PositionId = item.PositionId,
|
|
TaskId = item.TaskId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskShiftSDto> funcMain7(List<TaskShift> p26, List<TaskShiftSDto> p27)
|
|
{
|
|
if (p26 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p26.Count);
|
|
|
|
int i = 0;
|
|
int len = p26.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskShift item = p26[i];
|
|
result.Add(item == null ? null : new TaskShiftSDto()
|
|
{
|
|
ShiftId = item.ShiftId,
|
|
TaskId = item.TaskId
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
|
|
private static List<TaskPositionSDto> funcMain8(List<TaskPosition> p28, List<TaskPositionSDto> p29)
|
|
{
|
|
if (p28 == null)
|
|
{
|
|
return null;
|
|
}
|
|
List<TaskPositionSDto> result = new List<TaskPositionSDto>(p28.Count);
|
|
|
|
int i = 0;
|
|
int len = p28.Count;
|
|
|
|
while (i < len)
|
|
{
|
|
TaskPosition item = p28[i];
|
|
result.Add(item == null ? null : new TaskPositionSDto()
|
|
{
|
|
PositionId = item.PositionId,
|
|
TaskId = item.TaskId,
|
|
Id = item.Id
|
|
});
|
|
i++;
|
|
}
|
|
return result;
|
|
|
|
}
|
|
}
|
|
} |