Compare commits
2 Commits
9092109cd2
...
ab133ed004
Author | SHA1 | Date |
---|---|---|
|
ab133ed004 | |
|
574e3eae62 |
|
@ -6,8 +6,8 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
<AssemblyVersion>0.1.0.3</AssemblyVersion>
|
||||
<FileVersion>0.1.0.3</FileVersion>
|
||||
<AssemblyVersion>0.1.1.0</AssemblyVersion>
|
||||
<FileVersion>0.1.1.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
namespace Brizco.Api.Controllers;
|
||||
|
||||
public class PositionController : ICarterModule
|
||||
{
|
||||
|
||||
public virtual void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Position")
|
||||
.MapGroup($"api/position")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("", GetAllAsync)
|
||||
.WithDisplayName("GetAllPositions")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("{id}", GetAsync)
|
||||
.WithDisplayName("GetPosition")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", Post)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPut("", Put)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapDelete("{id}", Delete)
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetPositionsQuery(page), cancellationToken));
|
||||
|
||||
// GET:Get An Entity By Id
|
||||
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetPositionQuery(id), cancellationToken));
|
||||
|
||||
// POST:Create Entity
|
||||
public async Task<IResult> Post([FromBody] CreatePositionCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// PUT:Update Entity
|
||||
public async Task<IResult> Put([FromBody] UpdatePositionCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// DELETE:Delete Entity
|
||||
public async Task<IResult> Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new DeletePositionCommand(id), cancellationToken));
|
||||
|
||||
}
|
|
@ -25,14 +25,14 @@ public class RoleController : ICarterModule
|
|||
.WithDisplayName("GetOneRole")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", Post)
|
||||
.HasApiVersion(1.0);
|
||||
//group.MapPost("", Post)
|
||||
// .HasApiVersion(1.0);
|
||||
|
||||
group.MapPut("", Put)
|
||||
.HasApiVersion(1.0);
|
||||
//group.MapPut("", Put)
|
||||
// .HasApiVersion(1.0);
|
||||
|
||||
group.MapDelete("{id}", Delete)
|
||||
.HasApiVersion(1.0);
|
||||
//group.MapDelete("{id}", Delete)
|
||||
// .HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
// GET:Get All Entity
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
namespace Brizco.Api.Controllers;
|
||||
|
||||
public class RoutineController : ICarterModule
|
||||
{
|
||||
public virtual void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Routine")
|
||||
.MapGroup($"api/routine")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("", GetAllAsync)
|
||||
.WithDisplayName("GetAllRoutines")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("{id}", GetAsync)
|
||||
.WithDisplayName("GetRoutine")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", Post)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPut("", Put)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapDelete("{id}", Delete)
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetRoutinesQuery(page), cancellationToken));
|
||||
|
||||
// GET:Get An Entity By Id
|
||||
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetRoutineQuery(id), cancellationToken));
|
||||
|
||||
// POST:Create Entity
|
||||
public async Task<IResult> Post([FromBody] CreateRoutineCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// PUT:Update Entity
|
||||
public async Task<IResult> Put([FromBody] UpdateRoutineCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// DELETE:Delete Entity
|
||||
public async Task<IResult> Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new DeleteRoutineCommand(id), cancellationToken));
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
namespace Brizco.Api.Controllers;
|
||||
|
||||
public class SectionController : ICarterModule
|
||||
{
|
||||
|
||||
public virtual void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.NewVersionedApi("Section")
|
||||
.MapGroup($"api/section")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("", GetAllAsync)
|
||||
.WithDisplayName("GetAllSections")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("{id}", GetAsync)
|
||||
.WithDisplayName("GetSection")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("", Post)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPut("", Put)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapDelete("{id}", Delete)
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
// GET:Get All Entity
|
||||
public async Task<IResult> GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetSectionsQuery(page), cancellationToken));
|
||||
|
||||
// GET:Get An Entity By Id
|
||||
public async Task<IResult> GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await sender.Send(new GetSectionQuery(id), cancellationToken));
|
||||
|
||||
// POST:Create Entity
|
||||
public async Task<IResult> Post([FromBody] CreateSectionCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// PUT:Update Entity
|
||||
public async Task<IResult> Put([FromBody] UpdateSectionCommand ent, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(ent, cancellationToken));
|
||||
|
||||
// DELETE:Delete Entity
|
||||
public async Task<IResult> Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new DeleteSectionCommand(id), cancellationToken));
|
||||
|
||||
}
|
|
@ -26,11 +26,6 @@ public class ShiftController : ICarterModule
|
|||
|
||||
group.MapDelete("{id}", Delete)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
|
||||
group.MapPost("/plan", Post)
|
||||
.WithDisplayName("AddNewPlan")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
// GET:Get All Entity
|
||||
|
|
|
@ -18,6 +18,21 @@ public static class ApplicationClaims
|
|||
Detail = "دسترسی به مشاهده مجموعه ها"
|
||||
};
|
||||
|
||||
public static ClaimDto ManageStaffs { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ManageStaffs,
|
||||
Title = "دسترسی کامل به کارکنان",
|
||||
Detail = "دسترسی به افزودن و مدیریت کارکنان مجموعه"
|
||||
};
|
||||
public static ClaimDto ViewStaffs { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
Value = ApplicationPermission.ViewStaffs,
|
||||
Title = "مشاهده کارکنان",
|
||||
Detail = "دسترسی به مشاهده کارکنان مجموعه"
|
||||
};
|
||||
|
||||
public static ClaimDto ManageShifts { get; } = new ClaimDto
|
||||
{
|
||||
Type = CustomClaimType.Permission,
|
||||
|
@ -78,6 +93,9 @@ public static class ApplicationClaims
|
|||
|
||||
public static List<Claim> AllClaims = new List<Claim>
|
||||
{
|
||||
ManageStaffs.GetClaim,
|
||||
ViewStaffs.GetClaim,
|
||||
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
|
@ -92,6 +110,9 @@ public static class ApplicationClaims
|
|||
|
||||
public static List<Claim> ManagerClaims = new List<Claim>
|
||||
{
|
||||
ManageStaffs.GetClaim,
|
||||
ViewStaffs.GetClaim,
|
||||
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
|
@ -100,4 +121,22 @@ public static class ApplicationClaims
|
|||
ViewShifts.GetClaim,
|
||||
ManageShifts.GetClaim,
|
||||
};
|
||||
|
||||
|
||||
public static List<Claim> SuperVisorClaims = new List<Claim>
|
||||
{
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
ManageTasks.GetClaim,
|
||||
|
||||
ManageShiftPlans.GetClaim,
|
||||
ViewShifts.GetClaim,
|
||||
ManageShifts.GetClaim,
|
||||
};
|
||||
|
||||
public static List<Claim> StaffClaims = new List<Claim>
|
||||
{
|
||||
ManageActivities.GetClaim,
|
||||
ViewTasks.GetClaim,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@ public static class ApplicationPermission
|
|||
public const string ManageComplexes = nameof(ManageComplexes);
|
||||
public const string ViewComplexes = nameof(ViewComplexes);
|
||||
|
||||
|
||||
public const string ManageStaffs = nameof(ManageStaffs);
|
||||
public const string ViewStaffs = nameof(ViewStaffs);
|
||||
|
||||
public const string ManageShifts = nameof(ManageShifts);
|
||||
public const string ViewShifts = nameof(ViewShifts);
|
||||
public const string ManageShiftPlans = nameof(ManageShiftPlans);
|
||||
|
|
|
@ -36,6 +36,38 @@ public class ComplexService : IComplexService
|
|||
foreach (var claim in ApplicationClaims.ManagerClaims)
|
||||
await _roleManager.AddClaimAsync(managerRole, claim);
|
||||
|
||||
var superVisorRole = new ApplicationRole
|
||||
{
|
||||
ComplexId = complex.Id,
|
||||
EnglishName = "SuperVisor",
|
||||
PersianName = "سوپروایزر",
|
||||
Description = "انجام فعالیت مدیریت کارکنان و وظیفه ها",
|
||||
Name = $"SuperVisor_{complex.Id.ToString()}"
|
||||
};
|
||||
var superVisorRoleResult = await _roleManager.CreateAsync(superVisorRole);
|
||||
if (!superVisorRoleResult.Succeeded)
|
||||
throw new AppException(string.Join('|', superVisorRoleResult.Errors));
|
||||
|
||||
foreach (var claim in ApplicationClaims.SuperVisorClaims)
|
||||
await _roleManager.AddClaimAsync(superVisorRole, claim);
|
||||
|
||||
|
||||
var staffRole = new ApplicationRole
|
||||
{
|
||||
ComplexId = complex.Id,
|
||||
EnglishName = "Staff",
|
||||
PersianName = "کارمند",
|
||||
Description = "انجام فعالیت ها و وظیفه ها",
|
||||
Name = $"Staff_{complex.Id.ToString()}"
|
||||
};
|
||||
var staffRoleResult = await _roleManager.CreateAsync(staffRole);
|
||||
if (!staffRoleResult.Succeeded)
|
||||
throw new AppException(string.Join('|', staffRoleResult.Errors));
|
||||
|
||||
foreach (var claim in ApplicationClaims.StaffClaims)
|
||||
await _roleManager.AddClaimAsync(staffRole, claim);
|
||||
|
||||
|
||||
var complexUser = await _sender.Send(new CreateComplexUserCommand(complex.Id, managerUserId, new List<Guid>{ managerRole.Id }), cancellationToken);
|
||||
|
||||
return complex;
|
||||
|
|
|
@ -115,6 +115,11 @@ public class UserService : IUserService
|
|||
dto.RoleIds.Add(role.Id);
|
||||
}
|
||||
|
||||
var positionUser = await _repositoryWrapper.SetRepository<PositionUser>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(f => f.ApplicationUserId == userId);
|
||||
if (positionUser != null)
|
||||
dto.PositionId = positionUser.PositionId;
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -163,6 +168,7 @@ public class UserService : IUserService
|
|||
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
|
||||
}
|
||||
|
||||
await _sender.Send(new CreatePositionUserCommand(request.PositionId, user.Id), cancellationToken);
|
||||
await _sender.Send(new CreateComplexUserCommand(complexId, user.Id, request.RoleIds), cancellationToken);
|
||||
return user;
|
||||
}
|
||||
|
@ -202,6 +208,7 @@ public class UserService : IUserService
|
|||
throw new AppException(string.Join('|', addPassResult.Errors.Select(e => e.Description)));
|
||||
}
|
||||
|
||||
await _sender.Send(new UpdatePositionUserCommand(request.PositionId, user.Id), cancellationToken);
|
||||
await _sender.Send(new UpdateComplexUserCommand(user.Id, complexId, request.RoleIds), cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
<Using Include="Brizco.Common.Models.Mapper" />
|
||||
<Using Include="Brizco.Domain.Dtos.LargDtos" />
|
||||
<Using Include="Brizco.Domain.Dtos.SmallDtos" />
|
||||
<Using Include="Brizco.Domain.Entities.Complex" />
|
||||
<Using Include="Brizco.Domain.Entities.Routine" />
|
||||
<Using Include="Brizco.Domain.Entities.Shift" />
|
||||
<Using Include="Brizco.Domain.Entities.Task" />
|
||||
<Using Include="Brizco.Domain.Enums" />
|
||||
<Using Include="Mapster" />
|
||||
<Using Include="Microsoft.AspNetCore.Identity" />
|
||||
|
@ -66,7 +70,6 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\LargDtos\" />
|
||||
<Folder Include="Dtos\RequestDtos\" />
|
||||
<Folder Include="Models\Settings\" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -7,16 +7,13 @@ public sealed record CreateActivityCommand(
|
|||
TaskType Type,
|
||||
string Title,
|
||||
string Description,
|
||||
bool IsRelatedToRole,
|
||||
bool IsRelatedToPerson,
|
||||
bool IsDisposable,
|
||||
DateTime SetFor,
|
||||
bool HasDisposed,
|
||||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
List<Guid> Users,
|
||||
List<Guid> Shifts,
|
||||
List<Guid> Roles) : IRequest<ActivityLDto>;
|
||||
List<Guid> Positions) : IRequest<ActivityLDto>;
|
||||
|
||||
public sealed record UpdateActivityCommand(Guid Id,
|
||||
ActivityStatus Status,
|
||||
|
@ -25,16 +22,13 @@ public sealed record UpdateActivityCommand(Guid Id,
|
|||
TaskType Type,
|
||||
string Title,
|
||||
string Description,
|
||||
bool IsRelatedToRole,
|
||||
bool IsRelatedToPerson,
|
||||
bool IsDisposable,
|
||||
DateTime SetFor,
|
||||
bool HasDisposed,
|
||||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
List<Guid> Users,
|
||||
List<Guid> Shifts,
|
||||
List<Guid> Roles) : IRequest<bool>;
|
||||
List<Guid> Positions) : IRequest<bool>;
|
||||
|
||||
|
||||
public sealed record DeleteActivityCommand(Guid Id)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
public sealed record CreatePositionCommand(string Title, string Description, Guid SectionId)
|
||||
: IRequest<PositionSDto>;
|
||||
|
||||
public sealed record UpdatePositionCommand(Guid Id, string Title, string Description, Guid SectionId)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record DeletePositionCommand(Guid Id)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record CreatePositionUserCommand(Guid PositionId,Guid UserId)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record UpdatePositionUserCommand(Guid PositionId, Guid UserId)
|
||||
: IRequest<bool>;
|
|
@ -0,0 +1,11 @@
|
|||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
|
||||
public sealed record CreateRoutineCommand(string Title, string Description)
|
||||
: IRequest<RoutineSDto>;
|
||||
|
||||
public sealed record UpdateRoutineCommand(Guid Id, string Title, string Description)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record DeleteRoutineCommand(Guid Id)
|
||||
: IRequest<bool>;
|
|
@ -0,0 +1,10 @@
|
|||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
public sealed record CreateSectionCommand(string Title, string Description)
|
||||
: IRequest<SectionSDto>;
|
||||
|
||||
public sealed record UpdateSectionCommand(Guid Id, string Title, string Description)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record DeleteSectionCommand(Guid Id)
|
||||
: IRequest<bool>;
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description )
|
||||
public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List<DayOfWeek> DayOfWeeks)
|
||||
: IRequest<ShiftSDto>;
|
||||
|
||||
public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description)
|
||||
public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List<DayOfWeek> DayOfWeeks)
|
||||
: IRequest<bool>;
|
||||
|
||||
public sealed record DeleteShiftCommand(Guid Id)
|
||||
|
|
|
@ -3,34 +3,26 @@
|
|||
public sealed record CreateTaskCommand(TaskType Type,
|
||||
string Title,
|
||||
string Description,
|
||||
bool IsRelatedToShift,
|
||||
bool IsRelatedToRole,
|
||||
bool IsRelatedToPerson,
|
||||
bool IsDisposable,
|
||||
DateTime SetFor,
|
||||
bool HasDisposed,
|
||||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
List<Guid> Users,
|
||||
List<Guid> Shifts,
|
||||
List<Guid> Roles,
|
||||
List<Guid> Positions,
|
||||
List<DayOfWeek> Days) : IRequest<TaskLDto>;
|
||||
|
||||
public sealed record UpdateTaskCommand(Guid Id,
|
||||
TaskType Type,
|
||||
string Title,
|
||||
string Description,
|
||||
bool IsRelatedToShift,
|
||||
bool IsRelatedToRole,
|
||||
bool IsRelatedToPerson,
|
||||
bool IsDisposable,
|
||||
DateTime SetFor,
|
||||
bool HasDisposed,
|
||||
int Amount,
|
||||
PurchaseAmountType AmountType,
|
||||
List<Guid> Users,
|
||||
List<Guid> Shifts,
|
||||
List<Guid> Roles,
|
||||
List<Guid> Positions,
|
||||
List<DayOfWeek> Days) : IRequest<bool>;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetPositionsQuery(int Page = 0) :
|
||||
IRequest<List<PositionSDto>>;
|
||||
|
||||
public sealed record GetPositionQuery(Guid Id) :
|
||||
IRequest<PositionLDto>;
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetRoutinesQuery(int Page = 0) :
|
||||
IRequest<List<RoutineSDto>>;
|
||||
|
||||
public sealed record GetRoutineQuery(Guid Id) :
|
||||
IRequest<RoutineSDto>;
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.CommandQueries.Queries;
|
||||
|
||||
public sealed record GetSectionsQuery(int Page = 0) :
|
||||
IRequest<List<SectionSDto>>;
|
||||
|
||||
public sealed record GetSectionQuery(Guid Id) :
|
||||
IRequest<SectionLDto>;
|
|
@ -7,9 +7,6 @@ public class ActivityLDto : BaseDto<ActivityLDto , Activity>
|
|||
public TaskType Type { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsRelatedToShift { get; set; }
|
||||
public bool IsRelatedToRole { get; set; }
|
||||
public bool IsRelatedToPerson { get; set; }
|
||||
public bool IsDisposable { get; set; }
|
||||
public DateTime SetFor { get; set; }
|
||||
public bool HasDisposed { get; set; }
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
namespace Brizco.Domain.Dtos.LargDtos;
|
||||
|
||||
public class PositionLDto : BaseDto<PositionLDto, Position>
|
||||
{
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
|
||||
public Guid SectionId { get; set; }
|
||||
public string SectionName { get; set; } = string.Empty;
|
||||
|
||||
public List<PositionUserSDto> Users { get; set; } = new();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
namespace Brizco.Domain.Dtos.LargDtos;
|
||||
|
||||
public class SectionLDto : BaseDto<SectionLDto, Section>
|
||||
{
|
||||
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
|
||||
public List<PositionSDto> Positions { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace Brizco.Domain.Dtos.LargDtos;
|
||||
|
||||
public class ShiftLDto : BaseDto<ShiftLDto,Shift>
|
||||
{
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public TimeSpan StartAt { get; set; }
|
||||
public TimeSpan EndAt { get; set; }
|
||||
public Guid ComplexId { get; set; }
|
||||
public List<ShiftDaySDto> Days { get; set; } = new();
|
||||
}
|
|
@ -7,9 +7,6 @@ public class TaskLDto : BaseDto<TaskLDto, Entities.Task.Task>
|
|||
public TaskType Type { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsRelatedToShift { get; set; }
|
||||
public bool IsRelatedToRole { get; set; }
|
||||
public bool IsRelatedToPerson { get; set; }
|
||||
public bool IsDisposable { get; set; }
|
||||
public DateTime SetFor { get; set; }
|
||||
public bool HasDisposed { get; set; }
|
||||
|
@ -19,9 +16,8 @@ public class TaskLDto : BaseDto<TaskLDto, Entities.Task.Task>
|
|||
public PurchaseAmountType AmountType { get; set; }
|
||||
|
||||
|
||||
public List<TaskUserSDto> Users { get; set; } = new();
|
||||
|
||||
public List<TaskShiftSDto> Shifts { get; set; } = new();
|
||||
|
||||
public List<TaskRoleSDto> Roles { get; set; } = new();
|
||||
public List<TaskPositionSDto> Positions { get; set; } = new();
|
||||
}
|
|
@ -11,6 +11,7 @@ public class UserActionRequestDto
|
|||
public string NationalId { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public List<Guid> RoleIds { get; set; } = new();
|
||||
public Guid PositionId { get; set; }
|
||||
|
||||
|
||||
public string SelectedRoleName { get; set; } = string.Empty;
|
||||
|
|
|
@ -7,9 +7,6 @@ public class ActivitySDto : BaseDto<ActivitySDto , Activity>
|
|||
public TaskType Type { get; internal set; }
|
||||
public string Title { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
public bool IsRelatedToShift { get; internal set; }
|
||||
public bool IsRelatedToRole { get; internal set; }
|
||||
public bool IsRelatedToPerson { get; internal set; }
|
||||
public bool IsDisposable { get; internal set; }
|
||||
public DateTime SetFor { get; internal set; }
|
||||
public bool HasDisposed { get; internal set; }
|
||||
|
|
|
@ -15,5 +15,6 @@ public class ApplicationUserSDto : BaseDto<ApplicationUserSDto,ApplicationUser>
|
|||
public string NationalId { get; set; } = string.Empty;
|
||||
|
||||
public List<Guid> RoleIds { get; set; } = new();
|
||||
public Guid PositionId { get; set; }
|
||||
public long BirthDateTimeStamp => DateTimeExtensions.DateTimeToUnixTimeStamp(BirthDate);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class PositionSDto : BaseDto<PositionSDto, Position>
|
||||
{
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
|
||||
public Guid SectionId { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class PositionUserSDto : BaseDto<PositionUserSDto, PositionUser>
|
||||
{
|
||||
public Guid ApplicationUserId { get; set; }
|
||||
public Guid PositionId { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class RoutineSDto : BaseDto<RoutineSDto,Routine>
|
||||
{
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class SectionSDto : BaseDto<SectionSDto, Section>
|
||||
{
|
||||
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class ShiftDaySDto : BaseDto<ShiftDaySDto,ShiftDay>
|
||||
{
|
||||
public DayOfWeek DayOfWeek { get; set; }
|
||||
public Guid ShiftId { get; set; }
|
||||
}
|
|
@ -8,4 +8,5 @@ public class ShiftSDto : BaseDto<ShiftSDto,Shift>
|
|||
public TimeSpan StartAt { get; set; }
|
||||
public TimeSpan EndAt { get; set; }
|
||||
public Guid ComplexId { get; set; }
|
||||
public List<DayOfWeek> Days { get; set; } = new();
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class TaskRoleSDto : BaseDto<TaskRoleSDto , TaskRole>
|
||||
public class TaskPositionSDto : BaseDto<TaskPositionSDto , TaskPosition>
|
||||
{
|
||||
public Guid RoleId { get; set; }
|
||||
public Guid PositionId { get; set; }
|
||||
public Guid TaskId { get; set; }
|
||||
}
|
|
@ -5,9 +5,6 @@ public class TaskSDto : BaseDto<TaskSDto,Entities.Task.Task>
|
|||
public TaskType Type { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsRelatedToShift { get; set; }
|
||||
public bool IsRelatedToRole { get; set; }
|
||||
public bool IsRelatedToPerson { get; set; }
|
||||
public bool IsDisposable { get; set; }
|
||||
public DateTime SetFor { get; set; }
|
||||
public bool HasDisposed { get; set; }
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
namespace Brizco.Domain.Dtos.SmallDtos;
|
||||
|
||||
public class TaskUserSDto
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public Guid TaskId { get; set; }
|
||||
}
|
|
@ -28,3 +28,41 @@ public partial class ComplexUser
|
|||
return role;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Section
|
||||
{
|
||||
public static Section Create(string name, string description, Guid complexId)
|
||||
{
|
||||
return new Section(name, description, complexId);
|
||||
}
|
||||
|
||||
public Position AddPosition(string name, string description, Guid complexId)
|
||||
{
|
||||
var position = Position.Create(name, description, complexId, this.Id);
|
||||
this.Positions.Add(position);
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Position
|
||||
{
|
||||
public static Position Create(string name, string description, Guid complexId, Guid sectionId)
|
||||
{
|
||||
return new Position(name, description, complexId, sectionId);
|
||||
}
|
||||
|
||||
public PositionUser AddUser(Guid userId)
|
||||
{
|
||||
var positionUser = PositionUser.Create(this.Id, userId);
|
||||
this.Users.Add(positionUser);
|
||||
return positionUser;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class PositionUser
|
||||
{
|
||||
public static PositionUser Create(Guid positionId, Guid userId)
|
||||
{
|
||||
return new PositionUser(positionId, userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
namespace Brizco.Domain.Entities.Complex;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class Position : ApiEntity
|
||||
{
|
||||
public Position()
|
||||
{
|
||||
|
||||
}
|
||||
public Position(string name, string description, Guid complexId, Guid sectionId)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
ComplexId = complexId;
|
||||
SectionId = sectionId;
|
||||
}
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
public Complex? Complex { get; set; }
|
||||
|
||||
public Guid SectionId { get; set; }
|
||||
public Section? Section { get; set; }
|
||||
|
||||
public List<PositionUser> Users { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using Brizco.Domain.Entities.User;
|
||||
|
||||
namespace Brizco.Domain.Entities.Complex;
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class PositionUser : ApiEntity
|
||||
{
|
||||
public PositionUser()
|
||||
{
|
||||
|
||||
}
|
||||
public PositionUser(Guid positionId,Guid applicationUserId)
|
||||
{
|
||||
ApplicationUserId = applicationUserId;
|
||||
PositionId = positionId;
|
||||
}
|
||||
|
||||
public Guid ApplicationUserId { get; set; }
|
||||
public ApplicationUser? ApplicationUser { get; set; }
|
||||
|
||||
public Guid PositionId { get; set; }
|
||||
public Position? Position { get; set; }
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
namespace Brizco.Domain.Entities.Complex;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class Section : ApiEntity
|
||||
{
|
||||
public Section()
|
||||
{
|
||||
|
||||
}
|
||||
public Section(string name, string description, Guid complexId)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
ComplexId = complexId;
|
||||
}
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; set; }
|
||||
public Complex? Complex { get; set; }
|
||||
|
||||
public List<Position> Positions { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
namespace Brizco.Domain.Entities.Routine;
|
||||
|
||||
public partial class Routine
|
||||
{
|
||||
public static Routine Create(string name, string description, Guid complexId)
|
||||
{
|
||||
return new Routine(name, description, complexId);
|
||||
}
|
||||
|
||||
public ShiftRoutine AddShift(Guid shiftId)
|
||||
{
|
||||
var shift = new ShiftRoutine(this.Id, shiftId);
|
||||
this.Shifts.Add(shift);
|
||||
return shift;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
namespace Brizco.Domain.Entities.Routine;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class Routine : ApiEntity
|
||||
{
|
||||
public Routine()
|
||||
{
|
||||
|
||||
}
|
||||
public Routine(string name,string description,Guid complexId)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
ComplexId = complexId;
|
||||
}
|
||||
public string Name { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
|
||||
public Guid ComplexId { get; internal set; }
|
||||
public Complex.Complex? Complex { get; internal set; }
|
||||
|
||||
|
||||
public List<TaskRoutine> Tasks { get; internal set; } = new();
|
||||
public List<ShiftRoutine> Shifts { get; internal set; } = new();
|
||||
}
|
|
@ -8,6 +8,12 @@ public partial class Shift
|
|||
return new Shift(title, description, startAt, endAt,complexId);
|
||||
}
|
||||
|
||||
public ShiftDay SetDay(DayOfWeek dayOfWeek)
|
||||
{
|
||||
var shiftDay = new ShiftDay(dayOfWeek, this.Id);
|
||||
this.Days.Add(shiftDay);
|
||||
return shiftDay;
|
||||
}
|
||||
public ShiftPlan AddPlan(DateTime planDate)
|
||||
{
|
||||
var plan = new ShiftPlan(planDate , Id);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
namespace Brizco.Domain.Entities.Shift;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public partial class Shift : ApiEntity
|
||||
{
|
||||
|
@ -23,5 +24,7 @@ public partial class Shift : ApiEntity
|
|||
public Guid ComplexId { get; set; }
|
||||
public Complex.Complex? Complex { get; set; }
|
||||
|
||||
public List<ShiftDay> Days { get; internal set; } = new();
|
||||
public List<ShiftPlan> Plans { get; internal set; } = new();
|
||||
public List<ShiftRoutine> Routines { get; internal set; } = new();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
namespace Brizco.Domain.Entities.Shift;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class ShiftDay : ApiEntity
|
||||
{
|
||||
public ShiftDay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal ShiftDay(DayOfWeek dayOfWeek, Guid shiftId)
|
||||
{
|
||||
DayOfWeek = dayOfWeek;
|
||||
ShiftId = shiftId;
|
||||
}
|
||||
|
||||
public DayOfWeek DayOfWeek { get; internal set; }
|
||||
|
||||
public Guid ShiftId { get; internal set; }
|
||||
public Shift? Shift { get; internal set; }
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
namespace Brizco.Domain.Entities.Shift;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class ShiftRoutine : ApiEntity
|
||||
{
|
||||
public ShiftRoutine()
|
||||
{
|
||||
|
||||
}
|
||||
public ShiftRoutine(Guid routineId, Guid shiftId)
|
||||
{
|
||||
RoutineId = routineId;
|
||||
ShiftId = shiftId;
|
||||
}
|
||||
public Guid RoutineId { get; set; }
|
||||
public Routine.Routine? Routine { get; set; }
|
||||
|
||||
public Guid ShiftId { get; set; }
|
||||
public Shift? Shift { get; set; }
|
||||
}
|
|
@ -15,8 +15,6 @@ public partial class Activity : Task
|
|||
DateTime doneAt,
|
||||
string performanceDescription,
|
||||
TaskType type,
|
||||
bool isRelatedToRole,
|
||||
bool isRelatedToPerson,
|
||||
bool isDisposable,
|
||||
DateTime setFor,
|
||||
bool hasDisposed,
|
||||
|
@ -25,7 +23,7 @@ public partial class Activity : Task
|
|||
string title,
|
||||
string description,
|
||||
Guid complexId) : base(
|
||||
type,isRelatedToRole, isRelatedToPerson, isDisposable, setFor, hasDisposed, amount, amountType, title, description, complexId)
|
||||
type, isDisposable, setFor, hasDisposed, amount, amountType, title, description, complexId)
|
||||
{
|
||||
Status = status;
|
||||
DoneAt = doneAt;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Brizco.Domain.Entities.Task;
|
||||
using Brizco.Domain.Entities.Routine;
|
||||
|
||||
namespace Brizco.Domain.Entities.Task;
|
||||
|
||||
|
||||
public partial class Task
|
||||
|
@ -8,9 +10,6 @@ public partial class Task
|
|||
string title,
|
||||
string description,
|
||||
TaskType type,
|
||||
bool isRelatedToShift,
|
||||
bool isRelatedToRole,
|
||||
bool isRelatedToPerson,
|
||||
bool isDisposable,
|
||||
DateTime setFor,
|
||||
bool hasDisposed,
|
||||
|
@ -18,9 +17,8 @@ public partial class Task
|
|||
PurchaseAmountType amountType,
|
||||
Guid complexId)
|
||||
{
|
||||
return new Task(type,
|
||||
isRelatedToRole,
|
||||
isRelatedToPerson,
|
||||
return new Task(
|
||||
type,
|
||||
isDisposable,
|
||||
setFor,
|
||||
hasDisposed,
|
||||
|
@ -48,6 +46,7 @@ public partial class Task
|
|||
Shifts.Add(plan);
|
||||
}
|
||||
}
|
||||
|
||||
public TaskShift AddShift(Guid shiftId)
|
||||
{
|
||||
var plan = new TaskShift(Id, shiftId);
|
||||
|
@ -55,35 +54,37 @@ public partial class Task
|
|||
return plan;
|
||||
}
|
||||
|
||||
public void AddUser(params Guid[] userIds)
|
||||
public void AddPosition(params Guid[] positionIds)
|
||||
{
|
||||
foreach (var userId in userIds)
|
||||
foreach (var positionId in positionIds)
|
||||
{
|
||||
var plan = new TaskUser(Id, userId);
|
||||
Users.Add(plan);
|
||||
var position = new TaskPosition(Id, positionId);
|
||||
Positions.Add(position);
|
||||
}
|
||||
}
|
||||
public TaskUser AddUser(Guid userId)
|
||||
public TaskPosition AddPosition(Guid positionId)
|
||||
{
|
||||
var plan = new TaskUser(Id, userId);
|
||||
Users.Add(plan);
|
||||
return plan;
|
||||
var position = new TaskPosition(Id, positionId);
|
||||
Positions.Add(position);
|
||||
return position;
|
||||
}
|
||||
|
||||
public TaskRole AddRole(Guid roleId)
|
||||
|
||||
|
||||
public void AddRoutine(params Guid[] routineIds)
|
||||
{
|
||||
var plan = new TaskRole(Id, roleId);
|
||||
Roles.Add(plan);
|
||||
return plan;
|
||||
}
|
||||
public void AddRole(params Guid[] roleIds)
|
||||
{
|
||||
foreach (var roleId in roleIds)
|
||||
foreach (var routineId in routineIds)
|
||||
{
|
||||
var plan = new TaskRole(Id, roleId);
|
||||
Roles.Add(plan);
|
||||
var routine = new TaskRoutine(Id, routineId);
|
||||
Routines.Add(routine);
|
||||
}
|
||||
}
|
||||
public TaskRoutine AddRoutine(Guid routineId)
|
||||
{
|
||||
var routine = new TaskRoutine(Id, routineId);
|
||||
Routines.Add(routine);
|
||||
return routine;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Activity
|
||||
|
@ -96,8 +97,6 @@ public partial class Activity
|
|||
string title,
|
||||
string description,
|
||||
TaskType type,
|
||||
bool isRelatedToRole,
|
||||
bool isRelatedToPerson,
|
||||
bool isDisposable,
|
||||
DateTime setFor,
|
||||
bool hasDisposed,
|
||||
|
@ -110,8 +109,6 @@ public partial class Activity
|
|||
doneAt,
|
||||
performanceDescription,
|
||||
type,
|
||||
isRelatedToRole,
|
||||
isRelatedToPerson,
|
||||
isDisposable,
|
||||
setFor,
|
||||
hasDisposed,
|
||||
|
|
|
@ -12,8 +12,6 @@ public partial class Task : ApiEntity
|
|||
}
|
||||
internal Task(
|
||||
TaskType type,
|
||||
bool isRelatedToRole,
|
||||
bool isRelatedToPerson,
|
||||
bool isDisposable,
|
||||
DateTime setFor,
|
||||
bool hasDisposed,
|
||||
|
@ -24,8 +22,6 @@ public partial class Task : ApiEntity
|
|||
Guid complexId)
|
||||
{
|
||||
Type = type;
|
||||
IsRelatedToRole = isRelatedToRole;
|
||||
IsRelatedToPerson = isRelatedToPerson;
|
||||
IsDisposable = isDisposable;
|
||||
SetFor = setFor;
|
||||
HasDisposed = hasDisposed;
|
||||
|
@ -39,8 +35,6 @@ public partial class Task : ApiEntity
|
|||
public TaskType Type { get; internal set; }
|
||||
public string Title { get; internal set; } = string.Empty;
|
||||
public string Description { get; internal set; } = string.Empty;
|
||||
public bool IsRelatedToRole { get; internal set; }
|
||||
public bool IsRelatedToPerson { get; internal set; }
|
||||
public bool IsDisposable { get; internal set; }
|
||||
public DateTime SetFor { get; internal set; }
|
||||
public bool HasDisposed { get; internal set; }
|
||||
|
@ -53,11 +47,12 @@ public partial class Task : ApiEntity
|
|||
public PurchaseAmountType AmountType { get; internal set; }
|
||||
|
||||
|
||||
public List<TaskUser> Users { get; internal set; } = new();
|
||||
|
||||
public List<TaskShift> Shifts { get; internal set; } = new();
|
||||
|
||||
public List<TaskDay> Days { get; internal set; } = new();
|
||||
|
||||
public List<TaskRole> Roles { get; internal set; } = new();
|
||||
public List<TaskPosition> Positions { get; internal set; } = new();
|
||||
|
||||
public List<TaskRoutine> Routines { get; internal set; } = new();
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
using Brizco.Domain.Entities.User;
|
||||
using Brizco.Domain.Entities.Complex;
|
||||
|
||||
namespace Brizco.Domain.Entities.Task;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class TaskRole : ApiEntity
|
||||
public class TaskPosition : ApiEntity
|
||||
{
|
||||
public TaskRole()
|
||||
public TaskPosition()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TaskRole(Guid roleId, Guid taskId)
|
||||
public TaskPosition(Guid positionId, Guid taskId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
PositionId = positionId;
|
||||
TaskId = taskId;
|
||||
}
|
||||
public Guid RoleId { get; internal set; }
|
||||
public virtual ApplicationRole? Role { get; internal set; }
|
||||
public Guid PositionId { get; internal set; }
|
||||
public virtual Position? Role { get; internal set; }
|
||||
public Guid TaskId { get; internal set; }
|
||||
public virtual Task? Task { get; internal set; }
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
namespace Brizco.Domain.Entities.Task;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class TaskRoutine : ApiEntity
|
||||
{
|
||||
|
||||
public TaskRoutine()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal TaskRoutine(Guid routineId,Guid taskId)
|
||||
{
|
||||
RoutineId = routineId;
|
||||
TaskId = taskId;
|
||||
}
|
||||
|
||||
public Guid TaskId { get; internal set; }
|
||||
public Task? Task { get; internal set; }
|
||||
|
||||
public Guid RoutineId { get; internal set; }
|
||||
public Routine.Routine? Routine { get; internal set; }
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
using Brizco.Domain.Entities.User;
|
||||
|
||||
namespace Brizco.Domain.Entities.Task;
|
||||
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class TaskUser : ApiEntity
|
||||
{
|
||||
public TaskUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TaskUser(Guid userId,Guid taskId)
|
||||
{
|
||||
UserId = userId;
|
||||
TaskId = taskId;
|
||||
}
|
||||
public Guid UserId { get; internal set; }
|
||||
public virtual ApplicationUser? User { get; internal set; }
|
||||
public Guid TaskId { get; internal set; }
|
||||
public virtual Task? Task { get; internal set; }
|
||||
}
|
|
@ -19,8 +19,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p1.Type,
|
||||
Title = p1.Title,
|
||||
Description = p1.Description,
|
||||
IsRelatedToRole = p1.IsRelatedToRole,
|
||||
IsRelatedToPerson = p1.IsRelatedToPerson,
|
||||
IsDisposable = p1.IsDisposable,
|
||||
SetFor = p1.SetFor,
|
||||
HasDisposed = p1.HasDisposed,
|
||||
|
@ -44,8 +42,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p2.Type;
|
||||
result.Title = p2.Title;
|
||||
result.Description = p2.Description;
|
||||
result.IsRelatedToRole = p2.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p2.IsRelatedToPerson;
|
||||
result.IsDisposable = p2.IsDisposable;
|
||||
result.SetFor = p2.SetFor;
|
||||
result.HasDisposed = p2.HasDisposed;
|
||||
|
@ -64,8 +60,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p4.Type,
|
||||
Title = p4.Title,
|
||||
Description = p4.Description,
|
||||
IsRelatedToRole = p4.IsRelatedToRole,
|
||||
IsRelatedToPerson = p4.IsRelatedToPerson,
|
||||
IsDisposable = p4.IsDisposable,
|
||||
SetFor = p4.SetFor,
|
||||
HasDisposed = p4.HasDisposed,
|
||||
|
@ -80,8 +74,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p5.Type,
|
||||
Title = p5.Title,
|
||||
Description = p5.Description,
|
||||
IsRelatedToRole = p5.IsRelatedToRole,
|
||||
IsRelatedToPerson = p5.IsRelatedToPerson,
|
||||
IsDisposable = p5.IsDisposable,
|
||||
SetFor = p5.SetFor,
|
||||
HasDisposed = p5.HasDisposed,
|
||||
|
@ -105,8 +97,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p6.Type;
|
||||
result.Title = p6.Title;
|
||||
result.Description = p6.Description;
|
||||
result.IsRelatedToRole = p6.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p6.IsRelatedToPerson;
|
||||
result.IsDisposable = p6.IsDisposable;
|
||||
result.SetFor = p6.SetFor;
|
||||
result.HasDisposed = p6.HasDisposed;
|
||||
|
@ -125,8 +115,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p8.Type,
|
||||
Title = p8.Title,
|
||||
Description = p8.Description,
|
||||
IsRelatedToRole = p8.IsRelatedToRole,
|
||||
IsRelatedToPerson = p8.IsRelatedToPerson,
|
||||
IsDisposable = p8.IsDisposable,
|
||||
SetFor = p8.SetFor,
|
||||
HasDisposed = p8.HasDisposed,
|
||||
|
@ -149,8 +137,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p9.Type,
|
||||
Title = p9.Title,
|
||||
Description = p9.Description,
|
||||
IsRelatedToRole = p9.IsRelatedToRole,
|
||||
IsRelatedToPerson = p9.IsRelatedToPerson,
|
||||
IsDisposable = p9.IsDisposable,
|
||||
SetFor = p9.SetFor,
|
||||
HasDisposed = p9.HasDisposed,
|
||||
|
@ -174,8 +160,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p10.Type;
|
||||
result.Title = p10.Title;
|
||||
result.Description = p10.Description;
|
||||
result.IsRelatedToRole = p10.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p10.IsRelatedToPerson;
|
||||
result.IsDisposable = p10.IsDisposable;
|
||||
result.SetFor = p10.SetFor;
|
||||
result.HasDisposed = p10.HasDisposed;
|
||||
|
@ -194,8 +178,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p12.Type,
|
||||
Title = p12.Title,
|
||||
Description = p12.Description,
|
||||
IsRelatedToRole = p12.IsRelatedToRole,
|
||||
IsRelatedToPerson = p12.IsRelatedToPerson,
|
||||
IsDisposable = p12.IsDisposable,
|
||||
SetFor = p12.SetFor,
|
||||
HasDisposed = p12.HasDisposed,
|
||||
|
@ -210,8 +192,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p13.Type,
|
||||
Title = p13.Title,
|
||||
Description = p13.Description,
|
||||
IsRelatedToRole = p13.IsRelatedToRole,
|
||||
IsRelatedToPerson = p13.IsRelatedToPerson,
|
||||
IsDisposable = p13.IsDisposable,
|
||||
SetFor = p13.SetFor,
|
||||
HasDisposed = p13.HasDisposed,
|
||||
|
@ -235,8 +215,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p14.Type;
|
||||
result.Title = p14.Title;
|
||||
result.Description = p14.Description;
|
||||
result.IsRelatedToRole = p14.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p14.IsRelatedToPerson;
|
||||
result.IsDisposable = p14.IsDisposable;
|
||||
result.SetFor = p14.SetFor;
|
||||
result.HasDisposed = p14.HasDisposed;
|
||||
|
@ -255,8 +233,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p16.Type,
|
||||
Title = p16.Title,
|
||||
Description = p16.Description,
|
||||
IsRelatedToRole = p16.IsRelatedToRole,
|
||||
IsRelatedToPerson = p16.IsRelatedToPerson,
|
||||
IsDisposable = p16.IsDisposable,
|
||||
SetFor = p16.SetFor,
|
||||
HasDisposed = p16.HasDisposed,
|
||||
|
|
|
@ -0,0 +1,311 @@
|
|||
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 Mapster.Models;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class PositionMapper
|
||||
{
|
||||
public static Position AdaptToPosition(this PositionSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new Position()
|
||||
{
|
||||
Name = p1.Name,
|
||||
Description = p1.Description,
|
||||
ComplexId = p1.ComplexId,
|
||||
SectionId = p1.SectionId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static Position AdaptTo(this PositionSDto p2, Position p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Position result = p3 ?? new Position();
|
||||
|
||||
result.Name = p2.Name;
|
||||
result.Description = p2.Description;
|
||||
result.ComplexId = p2.ComplexId;
|
||||
result.SectionId = p2.SectionId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<PositionSDto, Position>> ProjectToPosition => p4 => new Position()
|
||||
{
|
||||
Name = p4.Name,
|
||||
Description = p4.Description,
|
||||
ComplexId = p4.ComplexId,
|
||||
SectionId = p4.SectionId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static PositionSDto AdaptToSDto(this Position p5)
|
||||
{
|
||||
return p5 == null ? null : new PositionSDto()
|
||||
{
|
||||
Name = p5.Name,
|
||||
Description = p5.Description,
|
||||
ComplexId = p5.ComplexId,
|
||||
SectionId = p5.SectionId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static PositionSDto AdaptTo(this Position p6, PositionSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PositionSDto result = p7 ?? new PositionSDto();
|
||||
|
||||
result.Name = p6.Name;
|
||||
result.Description = p6.Description;
|
||||
result.ComplexId = p6.ComplexId;
|
||||
result.SectionId = p6.SectionId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Position, PositionSDto>> ProjectToSDto => p8 => new PositionSDto()
|
||||
{
|
||||
Name = p8.Name,
|
||||
Description = p8.Description,
|
||||
ComplexId = p8.ComplexId,
|
||||
SectionId = p8.SectionId,
|
||||
Id = p8.Id
|
||||
};
|
||||
public static Position AdaptToPosition(this PositionLDto p9)
|
||||
{
|
||||
return p9 == null ? null : new Position()
|
||||
{
|
||||
Name = p9.Name,
|
||||
Description = p9.Description,
|
||||
ComplexId = p9.ComplexId,
|
||||
Complex = new Complex() {Id = p9.ComplexId},
|
||||
SectionId = p9.SectionId,
|
||||
Section = new Section()
|
||||
{
|
||||
Name = p9.SectionName,
|
||||
Id = p9.SectionId
|
||||
},
|
||||
Users = funcMain1(p9.Users),
|
||||
Id = p9.Id
|
||||
};
|
||||
}
|
||||
public static Position AdaptTo(this PositionLDto p11, Position p12)
|
||||
{
|
||||
if (p11 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Position result = p12 ?? new Position();
|
||||
|
||||
result.Name = p11.Name;
|
||||
result.Description = p11.Description;
|
||||
result.ComplexId = p11.ComplexId;
|
||||
result.Complex = funcMain2(new Never(), result.Complex, p11);
|
||||
result.SectionId = p11.SectionId;
|
||||
result.Section = funcMain3(new Never(), result.Section, p11);
|
||||
result.Users = funcMain4(p11.Users, result.Users);
|
||||
result.Id = p11.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<PositionLDto, Position>> ProjectLDtoToPosition => p19 => new Position()
|
||||
{
|
||||
Name = p19.Name,
|
||||
Description = p19.Description,
|
||||
ComplexId = p19.ComplexId,
|
||||
Complex = new Complex() {Id = p19.ComplexId},
|
||||
SectionId = p19.SectionId,
|
||||
Section = new Section()
|
||||
{
|
||||
Name = p19.SectionName,
|
||||
Id = p19.SectionId
|
||||
},
|
||||
Users = p19.Users.Select<PositionUserSDto, PositionUser>(p20 => new PositionUser()
|
||||
{
|
||||
ApplicationUserId = p20.ApplicationUserId,
|
||||
PositionId = p20.PositionId,
|
||||
Id = p20.Id
|
||||
}).ToList<PositionUser>(),
|
||||
Id = p19.Id
|
||||
};
|
||||
public static PositionLDto AdaptToLDto(this Position p21)
|
||||
{
|
||||
return p21 == null ? null : new PositionLDto()
|
||||
{
|
||||
Name = p21.Name,
|
||||
Description = p21.Description,
|
||||
ComplexId = p21.ComplexId,
|
||||
SectionId = p21.SectionId,
|
||||
SectionName = p21.Section != null ? p21.Section.Name : string.Empty,
|
||||
Users = funcMain5(p21.Users),
|
||||
Id = p21.Id
|
||||
};
|
||||
}
|
||||
public static PositionLDto AdaptTo(this Position p23, PositionLDto p24)
|
||||
{
|
||||
if (p23 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PositionLDto result = p24 ?? new PositionLDto();
|
||||
|
||||
result.Name = p23.Name;
|
||||
result.Description = p23.Description;
|
||||
result.ComplexId = p23.ComplexId;
|
||||
result.SectionId = p23.SectionId;
|
||||
result.SectionName = p23.Section != null ? p23.Section.Name : string.Empty;
|
||||
result.Users = funcMain6(p23.Users, result.Users);
|
||||
result.Id = p23.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Position, PositionLDto>> ProjectToLDto => p27 => new PositionLDto()
|
||||
{
|
||||
Name = p27.Name,
|
||||
Description = p27.Description,
|
||||
ComplexId = p27.ComplexId,
|
||||
SectionId = p27.SectionId,
|
||||
SectionName = p27.Section != null ? p27.Section.Name : string.Empty,
|
||||
Users = p27.Users.Select<PositionUser, PositionUserSDto>(p28 => new PositionUserSDto()
|
||||
{
|
||||
ApplicationUserId = p28.ApplicationUserId,
|
||||
PositionId = p28.PositionId,
|
||||
Id = p28.Id
|
||||
}).ToList<PositionUserSDto>(),
|
||||
Id = p27.Id
|
||||
};
|
||||
|
||||
private static List<PositionUser> funcMain1(List<PositionUserSDto> p10)
|
||||
{
|
||||
if (p10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionUser> result = new List<PositionUser>(p10.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p10.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionUserSDto item = p10[i];
|
||||
result.Add(item == null ? null : new PositionUser()
|
||||
{
|
||||
ApplicationUserId = item.ApplicationUserId,
|
||||
PositionId = item.PositionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static Complex funcMain2(Never p13, Complex p14, PositionLDto p11)
|
||||
{
|
||||
Complex result = p14 ?? new Complex();
|
||||
|
||||
result.Id = p11.ComplexId;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static Section funcMain3(Never p15, Section p16, PositionLDto p11)
|
||||
{
|
||||
Section result = p16 ?? new Section();
|
||||
|
||||
result.Name = p11.SectionName;
|
||||
result.Id = p11.SectionId;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PositionUser> funcMain4(List<PositionUserSDto> p17, List<PositionUser> p18)
|
||||
{
|
||||
if (p17 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionUser> result = new List<PositionUser>(p17.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p17.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionUserSDto item = p17[i];
|
||||
result.Add(item == null ? null : new PositionUser()
|
||||
{
|
||||
ApplicationUserId = item.ApplicationUserId,
|
||||
PositionId = item.PositionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PositionUserSDto> funcMain5(List<PositionUser> p22)
|
||||
{
|
||||
if (p22 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionUserSDto> result = new List<PositionUserSDto>(p22.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p22.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionUser item = p22[i];
|
||||
result.Add(item == null ? null : new PositionUserSDto()
|
||||
{
|
||||
ApplicationUserId = item.ApplicationUserId,
|
||||
PositionId = item.PositionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PositionUserSDto> funcMain6(List<PositionUser> p25, List<PositionUserSDto> p26)
|
||||
{
|
||||
if (p25 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionUserSDto> result = new List<PositionUserSDto>(p25.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p25.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionUser item = p25[i];
|
||||
result.Add(item == null ? null : new PositionUserSDto()
|
||||
{
|
||||
ApplicationUserId = item.ApplicationUserId,
|
||||
PositionId = item.PositionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Complex;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class PositionUserMapper
|
||||
{
|
||||
public static PositionUser AdaptToPositionUser(this PositionUserSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new PositionUser()
|
||||
{
|
||||
ApplicationUserId = p1.ApplicationUserId,
|
||||
PositionId = p1.PositionId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static PositionUser AdaptTo(this PositionUserSDto p2, PositionUser p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PositionUser result = p3 ?? new PositionUser();
|
||||
|
||||
result.ApplicationUserId = p2.ApplicationUserId;
|
||||
result.PositionId = p2.PositionId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<PositionUserSDto, PositionUser>> ProjectToPositionUser => p4 => new PositionUser()
|
||||
{
|
||||
ApplicationUserId = p4.ApplicationUserId,
|
||||
PositionId = p4.PositionId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static PositionUserSDto AdaptToSDto(this PositionUser p5)
|
||||
{
|
||||
return p5 == null ? null : new PositionUserSDto()
|
||||
{
|
||||
ApplicationUserId = p5.ApplicationUserId,
|
||||
PositionId = p5.PositionId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static PositionUserSDto AdaptTo(this PositionUser p6, PositionUserSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PositionUserSDto result = p7 ?? new PositionUserSDto();
|
||||
|
||||
result.ApplicationUserId = p6.ApplicationUserId;
|
||||
result.PositionId = p6.PositionId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<PositionUser, PositionUserSDto>> ProjectToSDto => p8 => new PositionUserSDto()
|
||||
{
|
||||
ApplicationUserId = p8.ApplicationUserId,
|
||||
PositionId = p8.PositionId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Routine;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class RoutineMapper
|
||||
{
|
||||
public static Routine AdaptToRoutine(this RoutineSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new Routine()
|
||||
{
|
||||
Name = p1.Name,
|
||||
Description = p1.Description,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static Routine AdaptTo(this RoutineSDto p2, Routine p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Routine result = p3 ?? new Routine();
|
||||
|
||||
result.Name = p2.Name;
|
||||
result.Description = p2.Description;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<RoutineSDto, Routine>> ProjectToRoutine => p4 => new Routine()
|
||||
{
|
||||
Name = p4.Name,
|
||||
Description = p4.Description,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static RoutineSDto AdaptToSDto(this Routine p5)
|
||||
{
|
||||
return p5 == null ? null : new RoutineSDto()
|
||||
{
|
||||
Name = p5.Name,
|
||||
Description = p5.Description,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static RoutineSDto AdaptTo(this Routine p6, RoutineSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
RoutineSDto result = p7 ?? new RoutineSDto();
|
||||
|
||||
result.Name = p6.Name;
|
||||
result.Description = p6.Description;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Routine, RoutineSDto>> ProjectToSDto => p8 => new RoutineSDto()
|
||||
{
|
||||
Name = p8.Name,
|
||||
Description = p8.Description,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
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;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class SectionMapper
|
||||
{
|
||||
public static Section AdaptToSection(this SectionSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new Section()
|
||||
{
|
||||
Name = p1.Name,
|
||||
Description = p1.Description,
|
||||
ComplexId = p1.ComplexId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static Section AdaptTo(this SectionSDto p2, Section p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Section result = p3 ?? new Section();
|
||||
|
||||
result.Name = p2.Name;
|
||||
result.Description = p2.Description;
|
||||
result.ComplexId = p2.ComplexId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<SectionSDto, Section>> ProjectToSection => p4 => new Section()
|
||||
{
|
||||
Name = p4.Name,
|
||||
Description = p4.Description,
|
||||
ComplexId = p4.ComplexId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static SectionSDto AdaptToSDto(this Section p5)
|
||||
{
|
||||
return p5 == null ? null : new SectionSDto()
|
||||
{
|
||||
Name = p5.Name,
|
||||
Description = p5.Description,
|
||||
ComplexId = p5.ComplexId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static SectionSDto AdaptTo(this Section p6, SectionSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SectionSDto result = p7 ?? new SectionSDto();
|
||||
|
||||
result.Name = p6.Name;
|
||||
result.Description = p6.Description;
|
||||
result.ComplexId = p6.ComplexId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Section, SectionSDto>> ProjectToSDto => p8 => new SectionSDto()
|
||||
{
|
||||
Name = p8.Name,
|
||||
Description = p8.Description,
|
||||
ComplexId = p8.ComplexId,
|
||||
Id = p8.Id
|
||||
};
|
||||
public static Section AdaptToSection(this SectionLDto p9)
|
||||
{
|
||||
return p9 == null ? null : new Section()
|
||||
{
|
||||
Name = p9.Name,
|
||||
Description = p9.Description,
|
||||
ComplexId = p9.ComplexId,
|
||||
Positions = funcMain1(p9.Positions),
|
||||
Id = p9.Id
|
||||
};
|
||||
}
|
||||
public static Section AdaptTo(this SectionLDto p11, Section p12)
|
||||
{
|
||||
if (p11 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Section result = p12 ?? new Section();
|
||||
|
||||
result.Name = p11.Name;
|
||||
result.Description = p11.Description;
|
||||
result.ComplexId = p11.ComplexId;
|
||||
result.Positions = funcMain2(p11.Positions, result.Positions);
|
||||
result.Id = p11.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<SectionLDto, Section>> ProjectLDtoToSection => p15 => new Section()
|
||||
{
|
||||
Name = p15.Name,
|
||||
Description = p15.Description,
|
||||
ComplexId = p15.ComplexId,
|
||||
Positions = p15.Positions.Select<PositionSDto, Position>(p16 => new Position()
|
||||
{
|
||||
Name = p16.Name,
|
||||
Description = p16.Description,
|
||||
ComplexId = p16.ComplexId,
|
||||
SectionId = p16.SectionId,
|
||||
Id = p16.Id
|
||||
}).ToList<Position>(),
|
||||
Id = p15.Id
|
||||
};
|
||||
public static SectionLDto AdaptToLDto(this Section p17)
|
||||
{
|
||||
return p17 == null ? null : new SectionLDto()
|
||||
{
|
||||
Name = p17.Name,
|
||||
Description = p17.Description,
|
||||
ComplexId = p17.ComplexId,
|
||||
Positions = funcMain3(p17.Positions),
|
||||
Id = p17.Id
|
||||
};
|
||||
}
|
||||
public static SectionLDto AdaptTo(this Section p19, SectionLDto p20)
|
||||
{
|
||||
if (p19 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SectionLDto result = p20 ?? new SectionLDto();
|
||||
|
||||
result.Name = p19.Name;
|
||||
result.Description = p19.Description;
|
||||
result.ComplexId = p19.ComplexId;
|
||||
result.Positions = funcMain4(p19.Positions, result.Positions);
|
||||
result.Id = p19.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Section, SectionLDto>> ProjectToLDto => p23 => new SectionLDto()
|
||||
{
|
||||
Name = p23.Name,
|
||||
Description = p23.Description,
|
||||
ComplexId = p23.ComplexId,
|
||||
Positions = p23.Positions.Select<Position, PositionSDto>(p24 => new PositionSDto()
|
||||
{
|
||||
Name = p24.Name,
|
||||
Description = p24.Description,
|
||||
ComplexId = p24.ComplexId,
|
||||
SectionId = p24.SectionId,
|
||||
Id = p24.Id
|
||||
}).ToList<PositionSDto>(),
|
||||
Id = p23.Id
|
||||
};
|
||||
|
||||
private static List<Position> funcMain1(List<PositionSDto> p10)
|
||||
{
|
||||
if (p10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Position> result = new List<Position>(p10.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p10.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionSDto item = p10[i];
|
||||
result.Add(item == null ? null : new Position()
|
||||
{
|
||||
Name = item.Name,
|
||||
Description = item.Description,
|
||||
ComplexId = item.ComplexId,
|
||||
SectionId = item.SectionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<Position> funcMain2(List<PositionSDto> p13, List<Position> p14)
|
||||
{
|
||||
if (p13 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Position> result = new List<Position>(p13.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p13.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
PositionSDto item = p13[i];
|
||||
result.Add(item == null ? null : new Position()
|
||||
{
|
||||
Name = item.Name,
|
||||
Description = item.Description,
|
||||
ComplexId = item.ComplexId,
|
||||
SectionId = item.SectionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PositionSDto> funcMain3(List<Position> p18)
|
||||
{
|
||||
if (p18 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionSDto> result = new List<PositionSDto>(p18.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p18.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
Position item = p18[i];
|
||||
result.Add(item == null ? null : new PositionSDto()
|
||||
{
|
||||
Name = item.Name,
|
||||
Description = item.Description,
|
||||
ComplexId = item.ComplexId,
|
||||
SectionId = item.SectionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<PositionSDto> funcMain4(List<Position> p21, List<PositionSDto> p22)
|
||||
{
|
||||
if (p21 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PositionSDto> result = new List<PositionSDto>(p21.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p21.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
Position item = p21[i];
|
||||
result.Add(item == null ? null : new PositionSDto()
|
||||
{
|
||||
Name = item.Name,
|
||||
Description = item.Description,
|
||||
ComplexId = item.ComplexId,
|
||||
SectionId = item.SectionId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class ShiftDayMapper
|
||||
{
|
||||
public static ShiftDay AdaptToShiftDay(this ShiftDaySDto p1)
|
||||
{
|
||||
return p1 == null ? null : new ShiftDay()
|
||||
{
|
||||
DayOfWeek = p1.DayOfWeek,
|
||||
ShiftId = p1.ShiftId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static ShiftDay AdaptTo(this ShiftDaySDto p2, ShiftDay p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ShiftDay result = p3 ?? new ShiftDay();
|
||||
|
||||
result.DayOfWeek = p2.DayOfWeek;
|
||||
result.ShiftId = p2.ShiftId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ShiftDaySDto, ShiftDay>> ProjectToShiftDay => p4 => new ShiftDay()
|
||||
{
|
||||
DayOfWeek = p4.DayOfWeek,
|
||||
ShiftId = p4.ShiftId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static ShiftDaySDto AdaptToSDto(this ShiftDay p5)
|
||||
{
|
||||
return p5 == null ? null : new ShiftDaySDto()
|
||||
{
|
||||
DayOfWeek = p5.DayOfWeek,
|
||||
ShiftId = p5.ShiftId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static ShiftDaySDto AdaptTo(this ShiftDay p6, ShiftDaySDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ShiftDaySDto result = p7 ?? new ShiftDaySDto();
|
||||
|
||||
result.DayOfWeek = p6.DayOfWeek;
|
||||
result.ShiftId = p6.ShiftId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ShiftDay, ShiftDaySDto>> ProjectToSDto => p8 => new ShiftDaySDto()
|
||||
{
|
||||
DayOfWeek = p8.DayOfWeek,
|
||||
ShiftId = p8.ShiftId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
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.Shift;
|
||||
|
@ -19,81 +22,372 @@ namespace Brizco.Domain.Mappers
|
|||
Description = p1.Description,
|
||||
ComplexId = p1.ComplexId,
|
||||
Complex = new Complex() {Id = p1.ComplexId},
|
||||
Days = funcMain1(p1.Days),
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static Shift AdaptTo(this ShiftSDto p2, Shift p3)
|
||||
public static Shift AdaptTo(this ShiftSDto p3, Shift p4)
|
||||
{
|
||||
if (p3 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Shift result = p4 ?? new Shift();
|
||||
|
||||
result.Title = p3.Title;
|
||||
result.StartAt = p3.StartAt;
|
||||
result.EndAt = p3.EndAt;
|
||||
result.Description = p3.Description;
|
||||
result.ComplexId = p3.ComplexId;
|
||||
result.Complex = funcMain2(new Never(), result.Complex, p3);
|
||||
result.Days = funcMain3(p3.Days, result.Days);
|
||||
result.Id = p3.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p9 => new Shift()
|
||||
{
|
||||
Title = p9.Title,
|
||||
StartAt = p9.StartAt,
|
||||
EndAt = p9.EndAt,
|
||||
Description = p9.Description,
|
||||
ComplexId = p9.ComplexId,
|
||||
Complex = new Complex() {Id = p9.ComplexId},
|
||||
Days = p9.Days.Select<DayOfWeek, ShiftDay>(p10 => new ShiftDay() {}).ToList<ShiftDay>(),
|
||||
Id = p9.Id
|
||||
};
|
||||
public static ShiftSDto AdaptToSDto(this Shift p11)
|
||||
{
|
||||
return p11 == null ? null : new ShiftSDto()
|
||||
{
|
||||
Title = p11.Title,
|
||||
Description = p11.Description,
|
||||
StartAt = p11.StartAt,
|
||||
EndAt = p11.EndAt,
|
||||
ComplexId = p11.ComplexId,
|
||||
Days = funcMain4(p11.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>()),
|
||||
Id = p11.Id
|
||||
};
|
||||
}
|
||||
public static ShiftSDto AdaptTo(this Shift p13, ShiftSDto p14)
|
||||
{
|
||||
if (p13 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ShiftSDto result = p14 ?? new ShiftSDto();
|
||||
|
||||
result.Title = p13.Title;
|
||||
result.Description = p13.Description;
|
||||
result.StartAt = p13.StartAt;
|
||||
result.EndAt = p13.EndAt;
|
||||
result.ComplexId = p13.ComplexId;
|
||||
result.Days = funcMain6(p13.Days.Select<ShiftDay, DayOfWeek>(funcMain5).ToList<DayOfWeek>(), result.Days);
|
||||
result.Id = p13.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p17 => new ShiftSDto()
|
||||
{
|
||||
Title = p17.Title,
|
||||
Description = p17.Description,
|
||||
StartAt = p17.StartAt,
|
||||
EndAt = p17.EndAt,
|
||||
ComplexId = p17.ComplexId,
|
||||
Days = p17.Days.Select<ShiftDay, DayOfWeek>(d => d.DayOfWeek).ToList<DayOfWeek>(),
|
||||
Id = p17.Id
|
||||
};
|
||||
public static Shift AdaptToShift(this ShiftLDto p18)
|
||||
{
|
||||
return p18 == null ? null : new Shift()
|
||||
{
|
||||
Title = p18.Title,
|
||||
StartAt = p18.StartAt,
|
||||
EndAt = p18.EndAt,
|
||||
Description = p18.Description,
|
||||
ComplexId = p18.ComplexId,
|
||||
Days = funcMain7(p18.Days),
|
||||
Id = p18.Id
|
||||
};
|
||||
}
|
||||
public static Shift AdaptTo(this ShiftLDto p20, Shift p21)
|
||||
{
|
||||
if (p20 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Shift result = p21 ?? new Shift();
|
||||
|
||||
result.Title = p20.Title;
|
||||
result.StartAt = p20.StartAt;
|
||||
result.EndAt = p20.EndAt;
|
||||
result.Description = p20.Description;
|
||||
result.ComplexId = p20.ComplexId;
|
||||
result.Days = funcMain8(p20.Days, result.Days);
|
||||
result.Id = p20.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ShiftLDto, Shift>> ProjectLDtoToShift => p24 => new Shift()
|
||||
{
|
||||
Title = p24.Title,
|
||||
StartAt = p24.StartAt,
|
||||
EndAt = p24.EndAt,
|
||||
Description = p24.Description,
|
||||
ComplexId = p24.ComplexId,
|
||||
Days = p24.Days.Select<ShiftDaySDto, ShiftDay>(p25 => new ShiftDay()
|
||||
{
|
||||
DayOfWeek = p25.DayOfWeek,
|
||||
ShiftId = p25.ShiftId,
|
||||
Id = p25.Id
|
||||
}).ToList<ShiftDay>(),
|
||||
Id = p24.Id
|
||||
};
|
||||
public static ShiftLDto AdaptToLDto(this Shift p26)
|
||||
{
|
||||
return p26 == null ? null : new ShiftLDto()
|
||||
{
|
||||
Title = p26.Title,
|
||||
Description = p26.Description,
|
||||
StartAt = p26.StartAt,
|
||||
EndAt = p26.EndAt,
|
||||
ComplexId = p26.ComplexId,
|
||||
Days = funcMain9(p26.Days),
|
||||
Id = p26.Id
|
||||
};
|
||||
}
|
||||
public static ShiftLDto AdaptTo(this Shift p28, ShiftLDto p29)
|
||||
{
|
||||
if (p28 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ShiftLDto result = p29 ?? new ShiftLDto();
|
||||
|
||||
result.Title = p28.Title;
|
||||
result.Description = p28.Description;
|
||||
result.StartAt = p28.StartAt;
|
||||
result.EndAt = p28.EndAt;
|
||||
result.ComplexId = p28.ComplexId;
|
||||
result.Days = funcMain10(p28.Days, result.Days);
|
||||
result.Id = p28.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Shift, ShiftLDto>> ProjectToLDto => p32 => new ShiftLDto()
|
||||
{
|
||||
Title = p32.Title,
|
||||
Description = p32.Description,
|
||||
StartAt = p32.StartAt,
|
||||
EndAt = p32.EndAt,
|
||||
ComplexId = p32.ComplexId,
|
||||
Days = p32.Days.Select<ShiftDay, ShiftDaySDto>(p33 => new ShiftDaySDto()
|
||||
{
|
||||
DayOfWeek = p33.DayOfWeek,
|
||||
ShiftId = p33.ShiftId,
|
||||
Id = p33.Id
|
||||
}).ToList<ShiftDaySDto>(),
|
||||
Id = p32.Id
|
||||
};
|
||||
|
||||
private static List<ShiftDay> funcMain1(List<DayOfWeek> p2)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Shift result = p3 ?? new Shift();
|
||||
List<ShiftDay> result = new List<ShiftDay>(p2.Count);
|
||||
|
||||
result.Title = p2.Title;
|
||||
result.StartAt = p2.StartAt;
|
||||
result.EndAt = p2.EndAt;
|
||||
result.Description = p2.Description;
|
||||
result.ComplexId = p2.ComplexId;
|
||||
result.Complex = funcMain1(new Never(), result.Complex, p2);
|
||||
result.Id = p2.Id;
|
||||
int i = 0;
|
||||
int len = p2.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
DayOfWeek item = p2[i];
|
||||
result.Add(new ShiftDay() {});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<ShiftSDto, Shift>> ProjectToShift => p6 => new Shift()
|
||||
|
||||
private static Complex funcMain2(Never p5, Complex p6, ShiftSDto p3)
|
||||
{
|
||||
Title = p6.Title,
|
||||
StartAt = p6.StartAt,
|
||||
EndAt = p6.EndAt,
|
||||
Description = p6.Description,
|
||||
ComplexId = p6.ComplexId,
|
||||
Complex = new Complex() {Id = p6.ComplexId},
|
||||
Id = p6.Id
|
||||
};
|
||||
public static ShiftSDto AdaptToSDto(this Shift p7)
|
||||
{
|
||||
return p7 == null ? null : new ShiftSDto()
|
||||
{
|
||||
Title = p7.Title,
|
||||
Description = p7.Description,
|
||||
StartAt = p7.StartAt,
|
||||
EndAt = p7.EndAt,
|
||||
ComplexId = p7.ComplexId,
|
||||
Id = p7.Id
|
||||
};
|
||||
Complex result = p6 ?? new Complex();
|
||||
|
||||
result.Id = p3.ComplexId;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static ShiftSDto AdaptTo(this Shift p8, ShiftSDto p9)
|
||||
|
||||
private static List<ShiftDay> funcMain3(List<DayOfWeek> p7, List<ShiftDay> p8)
|
||||
{
|
||||
if (p8 == null)
|
||||
if (p7 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ShiftSDto result = p9 ?? new ShiftSDto();
|
||||
List<ShiftDay> result = new List<ShiftDay>(p7.Count);
|
||||
|
||||
result.Title = p8.Title;
|
||||
result.Description = p8.Description;
|
||||
result.StartAt = p8.StartAt;
|
||||
result.EndAt = p8.EndAt;
|
||||
result.ComplexId = p8.ComplexId;
|
||||
result.Id = p8.Id;
|
||||
int i = 0;
|
||||
int len = p7.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
DayOfWeek item = p7[i];
|
||||
result.Add(new ShiftDay() {});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<Shift, ShiftSDto>> ProjectToSDto => p10 => new ShiftSDto()
|
||||
{
|
||||
Title = p10.Title,
|
||||
Description = p10.Description,
|
||||
StartAt = p10.StartAt,
|
||||
EndAt = p10.EndAt,
|
||||
ComplexId = p10.ComplexId,
|
||||
Id = p10.Id
|
||||
};
|
||||
|
||||
private static Complex funcMain1(Never p4, Complex p5, ShiftSDto p2)
|
||||
private static List<DayOfWeek> funcMain4(List<DayOfWeek> p12)
|
||||
{
|
||||
Complex result = p5 ?? new Complex();
|
||||
if (p12 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<DayOfWeek> result = new List<DayOfWeek>(p12.Count);
|
||||
|
||||
result.Id = p2.ComplexId;
|
||||
int i = 0;
|
||||
int len = p12.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
DayOfWeek item = p12[i];
|
||||
result.Add(item);
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static DayOfWeek funcMain5(ShiftDay d)
|
||||
{
|
||||
return d.DayOfWeek;
|
||||
}
|
||||
|
||||
private static List<DayOfWeek> funcMain6(List<DayOfWeek> p15, List<DayOfWeek> p16)
|
||||
{
|
||||
if (p15 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<DayOfWeek> result = new List<DayOfWeek>(p15.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p15.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
DayOfWeek item = p15[i];
|
||||
result.Add(item);
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<ShiftDay> funcMain7(List<ShiftDaySDto> p19)
|
||||
{
|
||||
if (p19 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<ShiftDay> result = new List<ShiftDay>(p19.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p19.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
ShiftDaySDto item = p19[i];
|
||||
result.Add(item == null ? null : new ShiftDay()
|
||||
{
|
||||
DayOfWeek = item.DayOfWeek,
|
||||
ShiftId = item.ShiftId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<ShiftDay> funcMain8(List<ShiftDaySDto> p22, List<ShiftDay> p23)
|
||||
{
|
||||
if (p22 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<ShiftDay> result = new List<ShiftDay>(p22.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p22.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
ShiftDaySDto item = p22[i];
|
||||
result.Add(item == null ? null : new ShiftDay()
|
||||
{
|
||||
DayOfWeek = item.DayOfWeek,
|
||||
ShiftId = item.ShiftId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<ShiftDaySDto> funcMain9(List<ShiftDay> p27)
|
||||
{
|
||||
if (p27 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<ShiftDaySDto> result = new List<ShiftDaySDto>(p27.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p27.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
ShiftDay item = p27[i];
|
||||
result.Add(item == null ? null : new ShiftDaySDto()
|
||||
{
|
||||
DayOfWeek = item.DayOfWeek,
|
||||
ShiftId = item.ShiftId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<ShiftDaySDto> funcMain10(List<ShiftDay> p30, List<ShiftDaySDto> p31)
|
||||
{
|
||||
if (p30 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<ShiftDaySDto> result = new List<ShiftDaySDto>(p30.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p30.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
ShiftDay item = p30[i];
|
||||
result.Add(item == null ? null : new ShiftDaySDto()
|
||||
{
|
||||
DayOfWeek = item.DayOfWeek,
|
||||
ShiftId = item.ShiftId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class ShiftRoutineMapper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -18,8 +18,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p1.Type,
|
||||
Title = p1.Title,
|
||||
Description = p1.Description,
|
||||
IsRelatedToRole = p1.IsRelatedToRole,
|
||||
IsRelatedToPerson = p1.IsRelatedToPerson,
|
||||
IsDisposable = p1.IsDisposable,
|
||||
SetFor = p1.SetFor,
|
||||
HasDisposed = p1.HasDisposed,
|
||||
|
@ -40,8 +38,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p2.Type;
|
||||
result.Title = p2.Title;
|
||||
result.Description = p2.Description;
|
||||
result.IsRelatedToRole = p2.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p2.IsRelatedToPerson;
|
||||
result.IsDisposable = p2.IsDisposable;
|
||||
result.SetFor = p2.SetFor;
|
||||
result.HasDisposed = p2.HasDisposed;
|
||||
|
@ -57,8 +53,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p4.Type,
|
||||
Title = p4.Title,
|
||||
Description = p4.Description,
|
||||
IsRelatedToRole = p4.IsRelatedToRole,
|
||||
IsRelatedToPerson = p4.IsRelatedToPerson,
|
||||
IsDisposable = p4.IsDisposable,
|
||||
SetFor = p4.SetFor,
|
||||
HasDisposed = p4.HasDisposed,
|
||||
|
@ -74,8 +68,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p5.Type,
|
||||
Title = p5.Title,
|
||||
Description = p5.Description,
|
||||
IsRelatedToRole = p5.IsRelatedToRole,
|
||||
IsRelatedToPerson = p5.IsRelatedToPerson,
|
||||
IsDisposable = p5.IsDisposable,
|
||||
SetFor = p5.SetFor,
|
||||
HasDisposed = p5.HasDisposed,
|
||||
|
@ -96,8 +88,6 @@ namespace Brizco.Domain.Mappers
|
|||
result.Type = p6.Type;
|
||||
result.Title = p6.Title;
|
||||
result.Description = p6.Description;
|
||||
result.IsRelatedToRole = p6.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p6.IsRelatedToPerson;
|
||||
result.IsDisposable = p6.IsDisposable;
|
||||
result.SetFor = p6.SetFor;
|
||||
result.HasDisposed = p6.HasDisposed;
|
||||
|
@ -113,8 +103,6 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p8.Type,
|
||||
Title = p8.Title,
|
||||
Description = p8.Description,
|
||||
IsRelatedToRole = p8.IsRelatedToRole,
|
||||
IsRelatedToPerson = p8.IsRelatedToPerson,
|
||||
IsDisposable = p8.IsDisposable,
|
||||
SetFor = p8.SetFor,
|
||||
HasDisposed = p8.HasDisposed,
|
||||
|
@ -130,168 +118,142 @@ namespace Brizco.Domain.Mappers
|
|||
Type = p9.Type,
|
||||
Title = p9.Title,
|
||||
Description = p9.Description,
|
||||
IsRelatedToRole = p9.IsRelatedToRole,
|
||||
IsRelatedToPerson = p9.IsRelatedToPerson,
|
||||
IsDisposable = p9.IsDisposable,
|
||||
SetFor = p9.SetFor,
|
||||
HasDisposed = p9.HasDisposed,
|
||||
Amount = p9.Amount,
|
||||
AmountType = p9.AmountType,
|
||||
Users = funcMain1(p9.Users),
|
||||
Shifts = funcMain2(p9.Shifts),
|
||||
Roles = funcMain3(p9.Roles),
|
||||
Shifts = funcMain1(p9.Shifts),
|
||||
Positions = funcMain2(p9.Positions),
|
||||
Id = p9.Id
|
||||
};
|
||||
}
|
||||
public static Task AdaptTo(this TaskLDto p13, Task p14)
|
||||
public static Task AdaptTo(this TaskLDto p12, Task p13)
|
||||
{
|
||||
if (p13 == null)
|
||||
if (p12 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Task result = p14 ?? new Task();
|
||||
Task result = p13 ?? new Task();
|
||||
|
||||
result.Type = p13.Type;
|
||||
result.Title = p13.Title;
|
||||
result.Description = p13.Description;
|
||||
result.IsRelatedToRole = p13.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p13.IsRelatedToPerson;
|
||||
result.IsDisposable = p13.IsDisposable;
|
||||
result.SetFor = p13.SetFor;
|
||||
result.HasDisposed = p13.HasDisposed;
|
||||
result.Amount = p13.Amount;
|
||||
result.AmountType = p13.AmountType;
|
||||
result.Users = funcMain4(p13.Users, result.Users);
|
||||
result.Shifts = funcMain5(p13.Shifts, result.Shifts);
|
||||
result.Roles = funcMain6(p13.Roles, result.Roles);
|
||||
result.Id = p13.Id;
|
||||
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 => p21 => new Task()
|
||||
public static Expression<Func<TaskLDto, Task>> ProjectLDtoToTask => p18 => new Task()
|
||||
{
|
||||
Type = p21.Type,
|
||||
Title = p21.Title,
|
||||
Description = p21.Description,
|
||||
IsRelatedToRole = p21.IsRelatedToRole,
|
||||
IsRelatedToPerson = p21.IsRelatedToPerson,
|
||||
IsDisposable = p21.IsDisposable,
|
||||
SetFor = p21.SetFor,
|
||||
HasDisposed = p21.HasDisposed,
|
||||
Amount = p21.Amount,
|
||||
AmountType = p21.AmountType,
|
||||
Users = p21.Users.Select<TaskUserSDto, TaskUser>(p22 => new TaskUser()
|
||||
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()
|
||||
{
|
||||
UserId = p22.UserId,
|
||||
TaskId = p22.TaskId
|
||||
}).ToList<TaskUser>(),
|
||||
Shifts = p21.Shifts.Select<TaskShiftSDto, TaskShift>(p23 => new TaskShift()
|
||||
{
|
||||
TaskId = p23.TaskId,
|
||||
ShiftId = p23.ShiftId
|
||||
TaskId = p19.TaskId,
|
||||
ShiftId = p19.ShiftId
|
||||
}).ToList<TaskShift>(),
|
||||
Roles = p21.Roles.Select<TaskRoleSDto, TaskRole>(p24 => new TaskRole()
|
||||
Positions = p18.Positions.Select<TaskPositionSDto, TaskPosition>(p20 => new TaskPosition()
|
||||
{
|
||||
RoleId = p24.RoleId,
|
||||
TaskId = p24.TaskId,
|
||||
Id = p24.Id
|
||||
}).ToList<TaskRole>(),
|
||||
Id = p21.Id
|
||||
PositionId = p20.PositionId,
|
||||
TaskId = p20.TaskId,
|
||||
Id = p20.Id
|
||||
}).ToList<TaskPosition>(),
|
||||
Id = p18.Id
|
||||
};
|
||||
public static TaskLDto AdaptToLDto(this Task p25)
|
||||
public static TaskLDto AdaptToLDto(this Task p21)
|
||||
{
|
||||
return p25 == null ? null : new TaskLDto()
|
||||
return p21 == null ? null : new TaskLDto()
|
||||
{
|
||||
Type = p25.Type,
|
||||
Title = p25.Title,
|
||||
Description = p25.Description,
|
||||
IsRelatedToRole = p25.IsRelatedToRole,
|
||||
IsRelatedToPerson = p25.IsRelatedToPerson,
|
||||
IsDisposable = p25.IsDisposable,
|
||||
SetFor = p25.SetFor,
|
||||
HasDisposed = p25.HasDisposed,
|
||||
Amount = p25.Amount,
|
||||
AmountType = p25.AmountType,
|
||||
Users = funcMain7(p25.Users),
|
||||
Shifts = funcMain8(p25.Shifts),
|
||||
Roles = funcMain9(p25.Roles),
|
||||
Id = p25.Id
|
||||
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 p29, TaskLDto p30)
|
||||
public static TaskLDto AdaptTo(this Task p24, TaskLDto p25)
|
||||
{
|
||||
if (p29 == null)
|
||||
if (p24 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskLDto result = p30 ?? new TaskLDto();
|
||||
TaskLDto result = p25 ?? new TaskLDto();
|
||||
|
||||
result.Type = p29.Type;
|
||||
result.Title = p29.Title;
|
||||
result.Description = p29.Description;
|
||||
result.IsRelatedToRole = p29.IsRelatedToRole;
|
||||
result.IsRelatedToPerson = p29.IsRelatedToPerson;
|
||||
result.IsDisposable = p29.IsDisposable;
|
||||
result.SetFor = p29.SetFor;
|
||||
result.HasDisposed = p29.HasDisposed;
|
||||
result.Amount = p29.Amount;
|
||||
result.AmountType = p29.AmountType;
|
||||
result.Users = funcMain10(p29.Users, result.Users);
|
||||
result.Shifts = funcMain11(p29.Shifts, result.Shifts);
|
||||
result.Roles = funcMain12(p29.Roles, result.Roles);
|
||||
result.Id = p29.Id;
|
||||
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 => p37 => new TaskLDto()
|
||||
public static Expression<Func<Task, TaskLDto>> ProjectToLDto => p30 => new TaskLDto()
|
||||
{
|
||||
Type = p37.Type,
|
||||
Title = p37.Title,
|
||||
Description = p37.Description,
|
||||
IsRelatedToRole = p37.IsRelatedToRole,
|
||||
IsRelatedToPerson = p37.IsRelatedToPerson,
|
||||
IsDisposable = p37.IsDisposable,
|
||||
SetFor = p37.SetFor,
|
||||
HasDisposed = p37.HasDisposed,
|
||||
Amount = p37.Amount,
|
||||
AmountType = p37.AmountType,
|
||||
Users = p37.Users.Select<TaskUser, TaskUserSDto>(p38 => new TaskUserSDto()
|
||||
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()
|
||||
{
|
||||
UserId = p38.UserId,
|
||||
TaskId = p38.TaskId
|
||||
}).ToList<TaskUserSDto>(),
|
||||
Shifts = p37.Shifts.Select<TaskShift, TaskShiftSDto>(p39 => new TaskShiftSDto()
|
||||
{
|
||||
ShiftId = p39.ShiftId,
|
||||
TaskId = p39.TaskId
|
||||
ShiftId = p31.ShiftId,
|
||||
TaskId = p31.TaskId
|
||||
}).ToList<TaskShiftSDto>(),
|
||||
Roles = p37.Roles.Select<TaskRole, TaskRoleSDto>(p40 => new TaskRoleSDto()
|
||||
Positions = p30.Positions.Select<TaskPosition, TaskPositionSDto>(p32 => new TaskPositionSDto()
|
||||
{
|
||||
RoleId = p40.RoleId,
|
||||
TaskId = p40.TaskId,
|
||||
Id = p40.Id
|
||||
}).ToList<TaskRoleSDto>(),
|
||||
Id = p37.Id
|
||||
PositionId = p32.PositionId,
|
||||
TaskId = p32.TaskId,
|
||||
Id = p32.Id
|
||||
}).ToList<TaskPositionSDto>(),
|
||||
Id = p30.Id
|
||||
};
|
||||
|
||||
private static List<TaskUser> funcMain1(List<TaskUserSDto> p10)
|
||||
private static List<TaskShift> funcMain1(List<TaskShiftSDto> p10)
|
||||
{
|
||||
if (p10 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskUser> result = new List<TaskUser>(p10.Count);
|
||||
List<TaskShift> result = new List<TaskShift>(p10.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p10.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskUserSDto item = p10[i];
|
||||
result.Add(item == null ? null : new TaskUser()
|
||||
TaskShiftSDto item = p10[i];
|
||||
result.Add(item == null ? null : new TaskShift()
|
||||
{
|
||||
UserId = item.UserId,
|
||||
TaskId = item.TaskId
|
||||
TaskId = item.TaskId,
|
||||
ShiftId = item.ShiftId
|
||||
});
|
||||
i++;
|
||||
}
|
||||
|
@ -299,20 +261,46 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskShift> funcMain2(List<TaskShiftSDto> p11)
|
||||
private static List<TaskPosition> funcMain2(List<TaskPositionSDto> p11)
|
||||
{
|
||||
if (p11 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskShift> result = new List<TaskShift>(p11.Count);
|
||||
List<TaskPosition> result = new List<TaskPosition>(p11.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p11.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskShiftSDto item = p11[i];
|
||||
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,
|
||||
|
@ -324,23 +312,23 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskRole> funcMain3(List<TaskRoleSDto> p12)
|
||||
private static List<TaskPosition> funcMain4(List<TaskPositionSDto> p16, List<TaskPosition> p17)
|
||||
{
|
||||
if (p12 == null)
|
||||
if (p16 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskRole> result = new List<TaskRole>(p12.Count);
|
||||
List<TaskPosition> result = new List<TaskPosition>(p16.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p12.Count;
|
||||
int len = p16.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskRoleSDto item = p12[i];
|
||||
result.Add(item == null ? null : new TaskRole()
|
||||
TaskPositionSDto item = p16[i];
|
||||
result.Add(item == null ? null : new TaskPosition()
|
||||
{
|
||||
RoleId = item.RoleId,
|
||||
PositionId = item.PositionId,
|
||||
TaskId = item.TaskId,
|
||||
Id = item.Id
|
||||
});
|
||||
|
@ -350,23 +338,23 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskUser> funcMain4(List<TaskUserSDto> p15, List<TaskUser> p16)
|
||||
private static List<TaskShiftSDto> funcMain5(List<TaskShift> p22)
|
||||
{
|
||||
if (p15 == null)
|
||||
if (p22 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskUser> result = new List<TaskUser>(p15.Count);
|
||||
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p22.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p15.Count;
|
||||
int len = p22.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskUserSDto item = p15[i];
|
||||
result.Add(item == null ? null : new TaskUser()
|
||||
TaskShift item = p22[i];
|
||||
result.Add(item == null ? null : new TaskShiftSDto()
|
||||
{
|
||||
UserId = item.UserId,
|
||||
ShiftId = item.ShiftId,
|
||||
TaskId = item.TaskId
|
||||
});
|
||||
i++;
|
||||
|
@ -375,48 +363,23 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskShift> funcMain5(List<TaskShiftSDto> p17, List<TaskShift> p18)
|
||||
private static List<TaskPositionSDto> funcMain6(List<TaskPosition> p23)
|
||||
{
|
||||
if (p17 == null)
|
||||
if (p23 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskShift> result = new List<TaskShift>(p17.Count);
|
||||
List<TaskPositionSDto> result = new List<TaskPositionSDto>(p23.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p17.Count;
|
||||
int len = p23.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskShiftSDto item = p17[i];
|
||||
result.Add(item == null ? null : new TaskShift()
|
||||
TaskPosition item = p23[i];
|
||||
result.Add(item == null ? null : new TaskPositionSDto()
|
||||
{
|
||||
TaskId = item.TaskId,
|
||||
ShiftId = item.ShiftId
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<TaskRole> funcMain6(List<TaskRoleSDto> p19, List<TaskRole> p20)
|
||||
{
|
||||
if (p19 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskRole> result = new List<TaskRole>(p19.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p19.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskRoleSDto item = p19[i];
|
||||
result.Add(item == null ? null : new TaskRole()
|
||||
{
|
||||
RoleId = item.RoleId,
|
||||
PositionId = item.PositionId,
|
||||
TaskId = item.TaskId,
|
||||
Id = item.Id
|
||||
});
|
||||
|
@ -426,45 +389,20 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskUserSDto> funcMain7(List<TaskUser> p26)
|
||||
private static List<TaskShiftSDto> funcMain7(List<TaskShift> p26, List<TaskShiftSDto> p27)
|
||||
{
|
||||
if (p26 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskUserSDto> result = new List<TaskUserSDto>(p26.Count);
|
||||
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p26.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p26.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskUser item = p26[i];
|
||||
result.Add(item == null ? null : new TaskUserSDto()
|
||||
{
|
||||
UserId = item.UserId,
|
||||
TaskId = item.TaskId
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<TaskShiftSDto> funcMain8(List<TaskShift> p27)
|
||||
{
|
||||
if (p27 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p27.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p27.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskShift item = p27[i];
|
||||
TaskShift item = p26[i];
|
||||
result.Add(item == null ? null : new TaskShiftSDto()
|
||||
{
|
||||
ShiftId = item.ShiftId,
|
||||
|
@ -476,99 +414,23 @@ namespace Brizco.Domain.Mappers
|
|||
|
||||
}
|
||||
|
||||
private static List<TaskRoleSDto> funcMain9(List<TaskRole> p28)
|
||||
private static List<TaskPositionSDto> funcMain8(List<TaskPosition> p28, List<TaskPositionSDto> p29)
|
||||
{
|
||||
if (p28 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskRoleSDto> result = new List<TaskRoleSDto>(p28.Count);
|
||||
List<TaskPositionSDto> result = new List<TaskPositionSDto>(p28.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p28.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskRole item = p28[i];
|
||||
result.Add(item == null ? null : new TaskRoleSDto()
|
||||
TaskPosition item = p28[i];
|
||||
result.Add(item == null ? null : new TaskPositionSDto()
|
||||
{
|
||||
RoleId = item.RoleId,
|
||||
TaskId = item.TaskId,
|
||||
Id = item.Id
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<TaskUserSDto> funcMain10(List<TaskUser> p31, List<TaskUserSDto> p32)
|
||||
{
|
||||
if (p31 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskUserSDto> result = new List<TaskUserSDto>(p31.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p31.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskUser item = p31[i];
|
||||
result.Add(item == null ? null : new TaskUserSDto()
|
||||
{
|
||||
UserId = item.UserId,
|
||||
TaskId = item.TaskId
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<TaskShiftSDto> funcMain11(List<TaskShift> p33, List<TaskShiftSDto> p34)
|
||||
{
|
||||
if (p33 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskShiftSDto> result = new List<TaskShiftSDto>(p33.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p33.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskShift item = p33[i];
|
||||
result.Add(item == null ? null : new TaskShiftSDto()
|
||||
{
|
||||
ShiftId = item.ShiftId,
|
||||
TaskId = item.TaskId
|
||||
});
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<TaskRoleSDto> funcMain12(List<TaskRole> p35, List<TaskRoleSDto> p36)
|
||||
{
|
||||
if (p35 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<TaskRoleSDto> result = new List<TaskRoleSDto>(p35.Count);
|
||||
|
||||
int i = 0;
|
||||
int len = p35.Count;
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
TaskRole item = p35[i];
|
||||
result.Add(item == null ? null : new TaskRoleSDto()
|
||||
{
|
||||
RoleId = item.RoleId,
|
||||
PositionId = item.PositionId,
|
||||
TaskId = item.TaskId,
|
||||
Id = item.Id
|
||||
});
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class TaskPositionMapper
|
||||
{
|
||||
public static TaskPosition AdaptToTaskPosition(this TaskPositionSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new TaskPosition()
|
||||
{
|
||||
PositionId = p1.PositionId,
|
||||
TaskId = p1.TaskId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static TaskPosition AdaptTo(this TaskPositionSDto p2, TaskPosition p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskPosition result = p3 ?? new TaskPosition();
|
||||
|
||||
result.PositionId = p2.PositionId;
|
||||
result.TaskId = p2.TaskId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskPositionSDto, TaskPosition>> ProjectToTaskPosition => p4 => new TaskPosition()
|
||||
{
|
||||
PositionId = p4.PositionId,
|
||||
TaskId = p4.TaskId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static TaskPositionSDto AdaptToSDto(this TaskPosition p5)
|
||||
{
|
||||
return p5 == null ? null : new TaskPositionSDto()
|
||||
{
|
||||
PositionId = p5.PositionId,
|
||||
TaskId = p5.TaskId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static TaskPositionSDto AdaptTo(this TaskPosition p6, TaskPositionSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskPositionSDto result = p7 ?? new TaskPositionSDto();
|
||||
|
||||
result.PositionId = p6.PositionId;
|
||||
result.TaskId = p6.TaskId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskPosition, TaskPositionSDto>> ProjectToSDto => p8 => new TaskPositionSDto()
|
||||
{
|
||||
PositionId = p8.PositionId,
|
||||
TaskId = p8.TaskId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class TaskRoleMapper
|
||||
{
|
||||
public static TaskRole AdaptToTaskRole(this TaskRoleSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new TaskRole()
|
||||
{
|
||||
RoleId = p1.RoleId,
|
||||
TaskId = p1.TaskId,
|
||||
Id = p1.Id
|
||||
};
|
||||
}
|
||||
public static TaskRole AdaptTo(this TaskRoleSDto p2, TaskRole p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskRole result = p3 ?? new TaskRole();
|
||||
|
||||
result.RoleId = p2.RoleId;
|
||||
result.TaskId = p2.TaskId;
|
||||
result.Id = p2.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskRoleSDto, TaskRole>> ProjectToTaskRole => p4 => new TaskRole()
|
||||
{
|
||||
RoleId = p4.RoleId,
|
||||
TaskId = p4.TaskId,
|
||||
Id = p4.Id
|
||||
};
|
||||
public static TaskRoleSDto AdaptToSDto(this TaskRole p5)
|
||||
{
|
||||
return p5 == null ? null : new TaskRoleSDto()
|
||||
{
|
||||
RoleId = p5.RoleId,
|
||||
TaskId = p5.TaskId,
|
||||
Id = p5.Id
|
||||
};
|
||||
}
|
||||
public static TaskRoleSDto AdaptTo(this TaskRole p6, TaskRoleSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskRoleSDto result = p7 ?? new TaskRoleSDto();
|
||||
|
||||
result.RoleId = p6.RoleId;
|
||||
result.TaskId = p6.TaskId;
|
||||
result.Id = p6.Id;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskRole, TaskRoleSDto>> ProjectToSDto => p8 => new TaskRoleSDto()
|
||||
{
|
||||
RoleId = p8.RoleId,
|
||||
TaskId = p8.TaskId,
|
||||
Id = p8.Id
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class TaskRoutineMapper
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Brizco.Domain.Dtos.SmallDtos;
|
||||
using Brizco.Domain.Entities.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
public static partial class TaskUserMapper
|
||||
{
|
||||
public static TaskUser AdaptToTaskUser(this TaskUserSDto p1)
|
||||
{
|
||||
return p1 == null ? null : new TaskUser()
|
||||
{
|
||||
UserId = p1.UserId,
|
||||
TaskId = p1.TaskId
|
||||
};
|
||||
}
|
||||
public static TaskUser AdaptTo(this TaskUserSDto p2, TaskUser p3)
|
||||
{
|
||||
if (p2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskUser result = p3 ?? new TaskUser();
|
||||
|
||||
result.UserId = p2.UserId;
|
||||
result.TaskId = p2.TaskId;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskUserSDto, TaskUser>> ProjectToTaskUser => p4 => new TaskUser()
|
||||
{
|
||||
UserId = p4.UserId,
|
||||
TaskId = p4.TaskId
|
||||
};
|
||||
public static TaskUserSDto AdaptToSDto(this TaskUser p5)
|
||||
{
|
||||
return p5 == null ? null : new TaskUserSDto()
|
||||
{
|
||||
UserId = p5.UserId,
|
||||
TaskId = p5.TaskId
|
||||
};
|
||||
}
|
||||
public static TaskUserSDto AdaptTo(this TaskUser p6, TaskUserSDto p7)
|
||||
{
|
||||
if (p6 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TaskUserSDto result = p7 ?? new TaskUserSDto();
|
||||
|
||||
result.UserId = p6.UserId;
|
||||
result.TaskId = p6.TaskId;
|
||||
return result;
|
||||
|
||||
}
|
||||
public static Expression<Func<TaskUser, TaskUserSDto>> ProjectToSDto => p8 => new TaskUserSDto()
|
||||
{
|
||||
UserId = p8.UserId,
|
||||
TaskId = p8.TaskId
|
||||
};
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ public class MapsterRegister : IRegister
|
|||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<Shift, ShiftSDto>()
|
||||
.Map("Days",o=>o.Days.Select(d=>d.DayOfWeek).ToList())
|
||||
.TwoWays();
|
||||
|
||||
|
||||
|
@ -16,6 +17,10 @@ public class MapsterRegister : IRegister
|
|||
.Map("RoleName", org => org.Role!.PersianName)
|
||||
.TwoWays();
|
||||
|
||||
config.NewConfig<Position, PositionLDto>()
|
||||
.Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty)
|
||||
.TwoWays();
|
||||
|
||||
config.NewConfig<ComplexUser, ComplexUserSDto>()
|
||||
.Map("ComplexName", o=>o.Complex!=null ? o.Complex.Name : string.Empty)
|
||||
.Map("FirstName", o=>o.User!=null ? o.User.FirstName : string.Empty)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<Using Include="Brizco.Domain.CommandQueries.Queries" />
|
||||
<Using Include="Brizco.Domain.Dtos.LargDtos" />
|
||||
<Using Include="Brizco.Domain.Dtos.SmallDtos" />
|
||||
<Using Include="Brizco.Domain.Entities.Complex" />
|
||||
<Using Include="Brizco.Repository.Abstracts" />
|
||||
<Using Include="MediatR" />
|
||||
<Using Include="Brizco.Common.Extensions" />
|
||||
|
|
|
@ -28,8 +28,6 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateActivityComman
|
|||
request.Title,
|
||||
request.Description,
|
||||
request.Type,
|
||||
request.IsRelatedToRole,
|
||||
request.IsRelatedToPerson,
|
||||
request.IsDisposable,
|
||||
request.SetFor,
|
||||
request.HasDisposed,
|
||||
|
@ -37,20 +35,17 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateActivityComman
|
|||
request.AmountType,
|
||||
complexId);
|
||||
|
||||
if (task.IsRelatedToPerson)
|
||||
{
|
||||
if (request.Users.Count == 0)
|
||||
throw new AppException("اگر فعالیت برای یک فرد انتخاب شده باشد باید لیست افراد را ارسال نمایید");
|
||||
task.AddUser(request.Users.ToArray());
|
||||
}
|
||||
|
||||
if (task.IsRelatedToRole)
|
||||
{
|
||||
if (request.Roles.Count == 0)
|
||||
throw new AppException(
|
||||
"اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید");
|
||||
task.AddShift(request.Roles.ToArray());
|
||||
}
|
||||
|
||||
if (request.Shifts.Count == 0)
|
||||
throw new AppException(
|
||||
"اگر فعالیت برای یک شیفت نقش انتخاب شده باشد باید لیست شیفت ها را ارسال نمایید");
|
||||
task.AddShift(request.Shifts.ToArray());
|
||||
|
||||
if (request.Positions.Count == 0)
|
||||
throw new AppException(
|
||||
"اگر فعالیت برای یک پوزیشن نقش انتخاب شده باشد باید لیست پوزیشن ها را ارسال نمایید");
|
||||
task.AddPosition(request.Positions.ToArray());
|
||||
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().Add(task);
|
||||
|
|
|
@ -3,14 +3,22 @@
|
|||
public class GetActivitiesQueryHandler : IRequestHandler<GetActivitiesQuery, List<ActivitySDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<ActivitySDto>> Handle(GetActivitiesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var tasks = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Activity>().TableNoTracking
|
||||
.Where(a=>a.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(ActivityMapper.ProjectToSDto)
|
||||
|
|
|
@ -32,8 +32,6 @@ public class UpdateActivityCommandHandler : IRequestHandler<UpdateActivityComman
|
|||
request.Title,
|
||||
request.Description,
|
||||
request.Type,
|
||||
request.IsRelatedToRole,
|
||||
request.IsRelatedToPerson,
|
||||
request.IsDisposable,
|
||||
request.SetFor,
|
||||
request.HasDisposed,
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class CreatePositionCommandHandler : IRequestHandler<CreatePositionCommand, PositionSDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CreatePositionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<PositionSDto> Handle(CreatePositionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
try
|
||||
{
|
||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||
var entity = Domain.Entities.Complex.Position
|
||||
.Create(request.Title,
|
||||
request.Description,
|
||||
complexId,
|
||||
request.SectionId);
|
||||
|
||||
//foreach (var userId in request.UserIds)
|
||||
// entity.AddUser(userId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>().Add(entity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return entity.AdaptToSDto();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using Brizco.Repository.Abstracts;
|
||||
|
||||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class CreatePositionUserCommandHandler : IRequestHandler<CreatePositionUserCommand,bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public CreatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(CreatePositionUserCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||
|
||||
|
||||
|
||||
var entity = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>().TableNoTracking
|
||||
.FirstOrDefaultAsync(p => p.Id == request.PositionId, cancellationToken);
|
||||
if (entity == null)
|
||||
throw new AppException("Position not found");
|
||||
entity.AddUser(request.UserId);
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>().Update(entity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class DeletePositionCommandHandler : IRequestHandler<DeletePositionCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public DeletePositionCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(DeletePositionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
||||
.Delete(shift);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class GetPositionQueryHandler : IRequestHandler<GetPositionQuery, PositionLDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public GetPositionQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<PositionLDto> Handle(GetPositionQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
||||
.TableNoTracking
|
||||
.Where(s => s.Id == request.Id)
|
||||
.Select(PositionMapper.ProjectToLDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (shift == null)
|
||||
throw new AppException("Position not found", ApiResultStatusCode.NotFound);
|
||||
return shift;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class GetPositionsQueryHandler : IRequestHandler<GetPositionsQuery, List<PositionSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetPositionsQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<PositionSDto>> Handle(GetPositionsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>().TableNoTracking
|
||||
.Where(p=>p.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(PositionMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
return shifts;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class UpdatePositionCommandHandler : IRequestHandler<UpdatePositionCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public UpdatePositionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(UpdatePositionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
||||
.TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var newPosition = Domain.Entities.Complex.Position.Create(request.Title,
|
||||
request.Description,
|
||||
complexId,
|
||||
request.SectionId);
|
||||
newPosition.Id = request.Id;
|
||||
|
||||
var users = await _repositoryWrapper.SetRepository<PositionUser>().TableNoTracking
|
||||
.Where(pu => pu.PositionId == newPosition.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
//foreach (var user in users)
|
||||
//{
|
||||
// if (!request.UserIds.Contains(user.ApplicationUserId))
|
||||
// {
|
||||
// _repositoryWrapper.SetRepository<PositionUser>()
|
||||
// .Delete(user);
|
||||
// await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
// }
|
||||
//}
|
||||
//foreach (var userId in request.UserIds)
|
||||
//{
|
||||
// if (users.FirstOrDefault(u => u.ApplicationUserId == userId) == null)
|
||||
// {
|
||||
// newPosition.AddUser(userId);
|
||||
// }
|
||||
//}
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Position>()
|
||||
.Update(newPosition);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using Brizco.Repository.Abstracts;
|
||||
|
||||
namespace Brizco.Repository.Handlers.Position;
|
||||
|
||||
public class UpdatePositionUserCommandHandler : IRequestHandler<UpdatePositionUserCommand,bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public UpdatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(UpdatePositionUserCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||
|
||||
var entity = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.PositionUser>().TableNoTracking
|
||||
.FirstOrDefaultAsync(p => p.ApplicationUserId == request.UserId , cancellationToken);
|
||||
if (entity == null)
|
||||
throw new AppException("PositionUser not found");
|
||||
var newEntity = PositionUser.Create(request.PositionId, request.UserId);
|
||||
newEntity.Id = entity.Id;
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.PositionUser>().Update(newEntity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
namespace Brizco.Repository.Handlers.Routine;
|
||||
|
||||
public class CreateRoutineCommandHandler : IRequestHandler<CreateRoutineCommand, RoutineSDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CreateRoutineCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<RoutineSDto> Handle(CreateRoutineCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
try
|
||||
{
|
||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||
var entity = Domain.Entities.Routine.Routine
|
||||
.Create(request.Title,request.Description,complexId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>().Add(entity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return entity.AdaptToSDto();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
namespace Brizco.Repository.Handlers.Routine;
|
||||
|
||||
public class DeleteRoutineCommandHandler : IRequestHandler<DeleteRoutineCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public DeleteRoutineCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(DeleteRoutineCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>()
|
||||
.Delete(shift);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace Brizco.Repository.Handlers.Routine;
|
||||
|
||||
public class GetRoutineQueryHandler : IRequestHandler<GetRoutineQuery, RoutineSDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public GetRoutineQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<RoutineSDto> Handle(GetRoutineQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>()
|
||||
.TableNoTracking
|
||||
.Where(s => s.Id == request.Id)
|
||||
.Select(RoutineMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (shift == null)
|
||||
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
||||
return shift;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
namespace Brizco.Repository.Handlers.Routine;
|
||||
|
||||
public class GetRoutinesQueryHandler : IRequestHandler<GetRoutinesQuery, List<RoutineSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetRoutinesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<RoutineSDto>> Handle(GetRoutinesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var entities = await _repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>().TableNoTracking
|
||||
.Where(p=>p.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(RoutineMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
namespace Brizco.Repository.Handlers.Routine;
|
||||
|
||||
public class UpdateRoutineCommandHandler : IRequestHandler<UpdateRoutineCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public UpdateRoutineCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(UpdateRoutineCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>()
|
||||
.TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Routine not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var newEntity = Domain.Entities.Routine.Routine.Create(request.Title,
|
||||
request.Description,
|
||||
complexId);
|
||||
newEntity.Id = request.Id;
|
||||
|
||||
var users = await _repositoryWrapper.SetRepository<PositionUser>().TableNoTracking
|
||||
.Where(pu => pu.PositionId == newEntity.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Routine.Routine>()
|
||||
.Update(newEntity);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
namespace Brizco.Repository.Handlers.Section;
|
||||
|
||||
public class CreateSectionCommandHandler : IRequestHandler<CreateSectionCommand, SectionSDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CreateSectionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<SectionSDto> Handle(CreateSectionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
try
|
||||
{
|
||||
await _repositoryWrapper.BeginTransaction(cancellationToken);
|
||||
var entity = Domain.Entities.Complex.Section
|
||||
.Create(request.Title,
|
||||
request.Description,
|
||||
complexId);
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>().Add(entity);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return entity.AdaptToSDto();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
namespace Brizco.Repository.Handlers.Section;
|
||||
|
||||
public class DeleteSectionCommandHandler : IRequestHandler<DeleteSectionCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public DeleteSectionCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<bool> Handle(DeleteSectionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var section = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>()
|
||||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (section == null)
|
||||
throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>()
|
||||
.Delete(section);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace Brizco.Repository.Handlers.Section;
|
||||
|
||||
public class GetSectionQueryHandler : IRequestHandler<GetSectionQuery, SectionLDto>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public GetSectionQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
public async Task<SectionLDto> Handle(GetSectionQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>()
|
||||
.TableNoTracking
|
||||
.Where(s => s.Id == request.Id)
|
||||
.Select(SectionMapper.ProjectToLDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (shift == null)
|
||||
throw new AppException("Section not found", ApiResultStatusCode.NotFound);
|
||||
return shift;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
namespace Brizco.Repository.Handlers.Section;
|
||||
|
||||
public class GetSectionsQueryHandler : IRequestHandler<GetSectionsQuery, List<SectionSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetSectionsQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<SectionSDto>> Handle(GetSectionsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>().TableNoTracking
|
||||
.Where(s=>s.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(SectionMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
||||
return shifts;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
namespace Brizco.Repository.Handlers.Section;
|
||||
|
||||
public class UpdateSectionCommandHandler : IRequestHandler<UpdateSectionCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public UpdateSectionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(UpdateSectionCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var shift = await _repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>()
|
||||
.TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Section not found", ApiResultStatusCode.NotFound);
|
||||
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var newSection = Domain.Entities.Complex.Section.Create(request.Title,
|
||||
request.Description,
|
||||
complexId);
|
||||
newSection.Id = request.Id;
|
||||
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Complex.Section>()
|
||||
.Update(newSection);
|
||||
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ public class CreateShiftCommandHandler : IRequestHandler<CreateShiftCommand, Shi
|
|||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public CreateShiftCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService)
|
||||
public CreateShiftCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
|
@ -28,12 +28,14 @@ public class CreateShiftCommandHandler : IRequestHandler<CreateShiftCommand, Shi
|
|||
request.EndAt,
|
||||
complexId);
|
||||
|
||||
request.DayOfWeeks.ForEach(d => shift.SetDay(d));
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().Add(shift);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
await _repositoryWrapper.CommitAsync(cancellationToken);
|
||||
return shift.AdaptToSDto();
|
||||
}
|
||||
catch (Exception )
|
||||
catch (Exception)
|
||||
{
|
||||
await _repositoryWrapper.RollBackAsync(cancellationToken);
|
||||
throw;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
namespace Brizco.Repository.Handlers.Shift;
|
||||
|
||||
public class DeleteShiftCommandHandler : IRequestHandler<DeleteShiftCommand, bool>
|
||||
public class DeletePositionCommandHandler : IRequestHandler<DeleteShiftCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
|
||||
public DeleteShiftCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public DeletePositionCommandHandler(IRepositoryWrapper repositoryWrapper)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class DeleteShiftCommandHandler : IRequestHandler<DeleteShiftCommand, boo
|
|||
.TableNoTracking
|
||||
.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
|
||||
if (shift == null)
|
||||
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("Routine not found", ApiResultStatusCode.NotFound);
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>()
|
||||
.Delete(shift);
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Brizco.Repository.Handlers.Shift;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
|
||||
namespace Brizco.Repository.Handlers.Shift;
|
||||
|
||||
public class GetShiftPlanQueryHandler : IRequestHandler<GetShiftQuery, ShiftSDto>
|
||||
{
|
||||
|
@ -15,8 +17,15 @@ public class GetShiftPlanQueryHandler : IRequestHandler<GetShiftQuery, ShiftSDto
|
|||
.Where(s => s.Id == request.id)
|
||||
.Select(ShiftMapper.ProjectToSDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
if (shift == null)
|
||||
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
||||
//var shiftDays = await _repositoryWrapper.SetRepository<ShiftDay>()
|
||||
// .TableNoTracking
|
||||
// .Where(sd => sd.ShiftId == request.id)
|
||||
// .ToListAsync(cancellationToken);
|
||||
//shift.Days = shiftDays.Select(s => s.DayOfWeek).ToList();
|
||||
|
||||
return shift;
|
||||
}
|
||||
}
|
|
@ -3,14 +3,22 @@
|
|||
public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftsQuery, List<ShiftSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<ShiftSDto>> Handle(GetShiftsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>().TableNoTracking
|
||||
.Where(s=>s.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.page * 15).Take(15)
|
||||
.Select(ShiftMapper.ProjectToSDto)
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
namespace Brizco.Repository.Handlers.Shift;
|
||||
using Brizco.Domain.Entities.Shift;
|
||||
|
||||
public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, bool>
|
||||
namespace Brizco.Repository.Handlers.Shift;
|
||||
|
||||
public class UpdatePositionCommandHandler : IRequestHandler<UpdateShiftCommand, bool>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
public UpdatePositionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
|
@ -29,7 +31,25 @@ public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, boo
|
|||
request.EndAt,
|
||||
complexId);
|
||||
newShift.Id = request.Id;
|
||||
|
||||
|
||||
var shiftDays = await _repositoryWrapper.SetRepository<ShiftDay>()
|
||||
.TableNoTracking.Where(sd => sd.ShiftId == request.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
foreach (var shiftDay in shiftDays.Where(shiftDay => !request.DayOfWeeks.Contains(shiftDay.DayOfWeek)))
|
||||
{
|
||||
_repositoryWrapper.SetRepository<ShiftDay>()
|
||||
.Delete(shiftDay);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
foreach (var dayOfWeek in request.DayOfWeeks)
|
||||
{
|
||||
var findDay = shiftDays.FirstOrDefault(sf => sf.DayOfWeek == dayOfWeek);
|
||||
if (findDay == null)
|
||||
newShift.SetDay(dayOfWeek);
|
||||
}
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>()
|
||||
.Update(newShift);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
|
|
@ -16,7 +16,7 @@ public class GetShiftPlanQueryHandler : IRequestHandler<GetShiftPlanQuery, Shift
|
|||
.Select(ShiftPlanMapper.ProjectToLDto)
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
if (shiftPlan == null)
|
||||
throw new AppException("Shift not found", ApiResultStatusCode.NotFound);
|
||||
throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound);
|
||||
return shiftPlan;
|
||||
}
|
||||
}
|
|
@ -3,13 +3,17 @@
|
|||
public class GetShiftPlansQueryHandler : IRequestHandler<GetShiftPlansQuery, List<ShiftPlanSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<ShiftPlanSDto>> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
var shifts = await _repositoryWrapper.SetRepository<Domain.Entities.Shift.ShiftPlan>().TableNoTracking
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
|
|
|
@ -20,9 +20,6 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateTaskCommand, T
|
|||
.Create(request.Title,
|
||||
request.Description,
|
||||
request.Type,
|
||||
request.IsRelatedToShift,
|
||||
request.IsRelatedToRole,
|
||||
request.IsRelatedToPerson,
|
||||
request.IsDisposable,
|
||||
request.SetFor,
|
||||
request.HasDisposed,
|
||||
|
@ -30,19 +27,15 @@ public class CreateActivityCommandHandler : IRequestHandler<CreateTaskCommand, T
|
|||
request.AmountType,
|
||||
complexId);
|
||||
|
||||
if (task.IsRelatedToPerson)
|
||||
{
|
||||
if (request.Users.Count == 0)
|
||||
throw new AppException("اگر فعالیت برای یک فرد انتخاب شده باشد باید لیست افراد را ارسال نمایید");
|
||||
task.AddUser(request.Users.ToArray());
|
||||
}
|
||||
|
||||
if (task.IsRelatedToRole)
|
||||
{
|
||||
if (request.Roles.Count == 0)
|
||||
throw new AppException("اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید");
|
||||
task.AddShift(request.Roles.ToArray());
|
||||
}
|
||||
|
||||
if (request.Shifts.Count == 0)
|
||||
throw new AppException("اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید");
|
||||
task.AddShift(request.Shifts.ToArray());
|
||||
|
||||
if (request.Positions.Count == 0)
|
||||
throw new AppException("اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید");
|
||||
task.AddShift(request.Positions.ToArray());
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Task.Task>().Add(task);
|
||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||
|
|
|
@ -3,14 +3,22 @@
|
|||
public class GetActivitiesQueryHandler : IRequestHandler<GetTasksQuery, List<TaskSDto>>
|
||||
{
|
||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper)
|
||||
public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_repositoryWrapper = repositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<List<TaskSDto>> Handle(GetTasksQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_currentUserService.ComplexId == null)
|
||||
throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound);
|
||||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound);
|
||||
|
||||
var tasks = await _repositoryWrapper.SetRepository<Domain.Entities.Task.Task>().TableNoTracking
|
||||
.Where(t=>t.ComplexId==complexId)
|
||||
.OrderByDescending(s => s.CreatedAt)
|
||||
.Skip(request.Page * 15).Take(15)
|
||||
.Select(TaskMapper.ProjectToSDto)
|
||||
|
|
|
@ -26,9 +26,6 @@ public class UpdateActivityCommandHandler : IRequestHandler<UpdateTaskCommand, b
|
|||
var newTask = Domain.Entities.Task.Task.Create(request.Title,
|
||||
request.Description,
|
||||
request.Type,
|
||||
request.IsRelatedToShift,
|
||||
request.IsRelatedToRole,
|
||||
request.IsRelatedToPerson,
|
||||
request.IsDisposable,
|
||||
request.SetFor,
|
||||
request.HasDisposed,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue