complete version 0.1.1.0
parent
574e3eae62
commit
ab133ed004
|
@ -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>
|
||||
|
|
|
@ -1,6 +1,50 @@
|
|||
namespace Brizco.Api.Controllers;
|
||||
|
||||
public class PositionController
|
||||
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));
|
||||
}
|
|
@ -1,6 +1,50 @@
|
|||
namespace Brizco.Api.Controllers;
|
||||
|
||||
public class SectionController
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
<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" />
|
||||
|
@ -69,7 +70,6 @@
|
|||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Dtos\LargDtos\" />
|
||||
<Folder Include="Dtos\RequestDtos\" />
|
||||
<Folder Include="Models\Settings\" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
public class PositionCommands
|
||||
{
|
||||
|
||||
}
|
||||
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>;
|
|
@ -1,6 +0,0 @@
|
|||
namespace Brizco.Domain.CommandQueries.Commands;
|
||||
|
||||
public class SectionCommand
|
||||
{
|
||||
|
||||
}
|
|
@ -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>;
|
|
@ -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>;
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -53,8 +53,16 @@ public partial class Position
|
|||
|
||||
public PositionUser AddUser(Guid userId)
|
||||
{
|
||||
var positionUser = new PositionUser(this.Id, 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Brizco.Domain.Entities.Complex;
|
||||
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
|
||||
[GenerateMapper]
|
||||
public class PositionUser : ApiEntity
|
||||
public partial class PositionUser : ApiEntity
|
||||
{
|
||||
public PositionUser()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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()
|
||||
|
|
|
@ -1,6 +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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +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
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,6 +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
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,6 +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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
@ -35,7 +35,7 @@ public class CreateShiftCommandHandler : IRequestHandler<CreateShiftCommand, Shi
|
|||
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>
|
||||
{
|
||||
|
@ -18,6 +20,12 @@ public class GetShiftPlanQueryHandler : IRequestHandler<GetShiftQuery, ShiftSDto
|
|||
|
||||
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)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace Brizco.Repository.Handlers.Shift;
|
||||
|
||||
public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, bool>
|
||||
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;
|
||||
|
@ -46,8 +46,8 @@ public class UpdateShiftCommandHandler : IRequestHandler<UpdateShiftCommand, boo
|
|||
foreach (var dayOfWeek in request.DayOfWeeks)
|
||||
{
|
||||
var findDay = shiftDays.FirstOrDefault(sf => sf.DayOfWeek == dayOfWeek);
|
||||
if (findDay != null)
|
||||
shift.SetDay(dayOfWeek);
|
||||
if (findDay == null)
|
||||
newShift.SetDay(dayOfWeek);
|
||||
}
|
||||
|
||||
_repositoryWrapper.SetRepository<Domain.Entities.Shift.Shift>()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue