diff --git a/.version b/.version
index b8e6ed9..9d3e2f6 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-0.1.0.3
\ No newline at end of file
+0.1.1.0
\ No newline at end of file
diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj
index b04b535..70bd10b 100644
--- a/Brizco.Api/Brizco.Api.csproj
+++ b/Brizco.Api/Brizco.Api.csproj
@@ -6,8 +6,8 @@
enable
Linux
..\docker-compose.dcproj
- 0.1.0.3
- 0.1.0.3
+ 0.1.1.0
+ 0.1.1.0
diff --git a/Brizco.Api/Controllers/PositionController.cs b/Brizco.Api/Controllers/PositionController.cs
index 990ae53..557c35b 100644
--- a/Brizco.Api/Controllers/PositionController.cs
+++ b/Brizco.Api/Controllers/PositionController.cs
@@ -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 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 GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
+ => TypedResults.Ok(await sender.Send(new GetPositionQuery(id), cancellationToken));
+
+ // POST:Create Entity
+ public async Task Post([FromBody] CreatePositionCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // PUT:Update Entity
+ public async Task Put([FromBody] UpdatePositionCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // DELETE:Delete Entity
+ public async Task Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(new DeletePositionCommand(id), cancellationToken));
+
}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/RoleController.cs b/Brizco.Api/Controllers/RoleController.cs
index b620b14..e1f9351 100644
--- a/Brizco.Api/Controllers/RoleController.cs
+++ b/Brizco.Api/Controllers/RoleController.cs
@@ -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
diff --git a/Brizco.Api/Controllers/RoutineController.cs b/Brizco.Api/Controllers/RoutineController.cs
new file mode 100644
index 0000000..25b2a70
--- /dev/null
+++ b/Brizco.Api/Controllers/RoutineController.cs
@@ -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 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 GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
+ => TypedResults.Ok(await sender.Send(new GetRoutineQuery(id), cancellationToken));
+
+ // POST:Create Entity
+ public async Task Post([FromBody] CreateRoutineCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // PUT:Update Entity
+ public async Task Put([FromBody] UpdateRoutineCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // DELETE:Delete Entity
+ public async Task Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(new DeleteRoutineCommand(id), cancellationToken));
+}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/SectionController.cs b/Brizco.Api/Controllers/SectionController.cs
index d21f7ec..815e2c1 100644
--- a/Brizco.Api/Controllers/SectionController.cs
+++ b/Brizco.Api/Controllers/SectionController.cs
@@ -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 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 GetAsync(Guid id, ISender sender, CancellationToken cancellationToken)
+ => TypedResults.Ok(await sender.Send(new GetSectionQuery(id), cancellationToken));
+
+ // POST:Create Entity
+ public async Task Post([FromBody] CreateSectionCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // PUT:Update Entity
+ public async Task Put([FromBody] UpdateSectionCommand ent, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(ent, cancellationToken));
+
+ // DELETE:Delete Entity
+ public async Task Delete(Guid id, ISender mediator, CancellationToken cancellationToken)
+ => TypedResults.Ok(await mediator.Send(new DeleteSectionCommand(id), cancellationToken));
+
}
\ No newline at end of file
diff --git a/Brizco.Api/Controllers/ShiftController.cs b/Brizco.Api/Controllers/ShiftController.cs
index 64d6572..feeb88f 100644
--- a/Brizco.Api/Controllers/ShiftController.cs
+++ b/Brizco.Api/Controllers/ShiftController.cs
@@ -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
diff --git a/Brizco.Core/EntityServices/UserService.cs b/Brizco.Core/EntityServices/UserService.cs
index 923ec75..fdbe4df 100644
--- a/Brizco.Core/EntityServices/UserService.cs
+++ b/Brizco.Core/EntityServices/UserService.cs
@@ -115,6 +115,11 @@ public class UserService : IUserService
dto.RoleIds.Add(role.Id);
}
+ var positionUser = await _repositoryWrapper.SetRepository()
+ .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;
}
diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj
index b306b1d..2bab5f5 100644
--- a/Brizco.Domain/Brizco.Domain.csproj
+++ b/Brizco.Domain/Brizco.Domain.csproj
@@ -54,6 +54,7 @@
+
@@ -69,7 +70,6 @@
-
diff --git a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs
index 72975d2..1b1c933 100644
--- a/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs
+++ b/Brizco.Domain/CommandQueries/Commands/PositionCommands.cs
@@ -1,6 +1,16 @@
namespace Brizco.Domain.CommandQueries.Commands;
-public class PositionCommands
-{
-
-}
\ No newline at end of file
+public sealed record CreatePositionCommand(string Title, string Description, Guid SectionId)
+ : IRequest;
+
+public sealed record UpdatePositionCommand(Guid Id, string Title, string Description, Guid SectionId)
+ : IRequest;
+
+public sealed record DeletePositionCommand(Guid Id)
+ : IRequest;
+
+public sealed record CreatePositionUserCommand(Guid PositionId,Guid UserId)
+ : IRequest;
+
+public sealed record UpdatePositionUserCommand(Guid PositionId, Guid UserId)
+ : IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs b/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs
new file mode 100644
index 0000000..6257490
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Commands/RoutineCommands.cs
@@ -0,0 +1,11 @@
+namespace Brizco.Domain.CommandQueries.Commands;
+
+
+public sealed record CreateRoutineCommand(string Title, string Description)
+ : IRequest;
+
+public sealed record UpdateRoutineCommand(Guid Id, string Title, string Description)
+ : IRequest;
+
+public sealed record DeleteRoutineCommand(Guid Id)
+ : IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Commands/SectionCommand.cs b/Brizco.Domain/CommandQueries/Commands/SectionCommand.cs
deleted file mode 100644
index bc98557..0000000
--- a/Brizco.Domain/CommandQueries/Commands/SectionCommand.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Brizco.Domain.CommandQueries.Commands;
-
-public class SectionCommand
-{
-
-}
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Commands/SectionCommands.cs b/Brizco.Domain/CommandQueries/Commands/SectionCommands.cs
new file mode 100644
index 0000000..5e579d5
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Commands/SectionCommands.cs
@@ -0,0 +1,10 @@
+namespace Brizco.Domain.CommandQueries.Commands;
+
+public sealed record CreateSectionCommand(string Title, string Description)
+ : IRequest;
+
+public sealed record UpdateSectionCommand(Guid Id, string Title, string Description)
+ : IRequest;
+
+public sealed record DeleteSectionCommand(Guid Id)
+ : IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/PositionQueries.cs b/Brizco.Domain/CommandQueries/Queries/PositionQueries.cs
new file mode 100644
index 0000000..f651b30
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Queries/PositionQueries.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.CommandQueries.Queries;
+
+public sealed record GetPositionsQuery(int Page = 0) :
+ IRequest>;
+
+public sealed record GetPositionQuery(Guid Id) :
+ IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs b/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs
new file mode 100644
index 0000000..7d5e24e
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Queries/RoutineQueries.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.CommandQueries.Queries;
+
+public sealed record GetRoutinesQuery(int Page = 0) :
+ IRequest>;
+
+public sealed record GetRoutineQuery(Guid Id) :
+ IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/CommandQueries/Queries/SectionQueries.cs b/Brizco.Domain/CommandQueries/Queries/SectionQueries.cs
new file mode 100644
index 0000000..612258e
--- /dev/null
+++ b/Brizco.Domain/CommandQueries/Queries/SectionQueries.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.CommandQueries.Queries;
+
+public sealed record GetSectionsQuery(int Page = 0) :
+ IRequest>;
+
+public sealed record GetSectionQuery(Guid Id) :
+ IRequest;
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs b/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs
new file mode 100644
index 0000000..db3cf06
--- /dev/null
+++ b/Brizco.Domain/Dtos/LargDtos/PositionLDto.cs
@@ -0,0 +1,15 @@
+namespace Brizco.Domain.Dtos.LargDtos;
+
+public class PositionLDto : BaseDto
+{
+
+ 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 Users { get; set; } = new();
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/LargDtos/SectionLDto.cs b/Brizco.Domain/Dtos/LargDtos/SectionLDto.cs
new file mode 100644
index 0000000..84e06e8
--- /dev/null
+++ b/Brizco.Domain/Dtos/LargDtos/SectionLDto.cs
@@ -0,0 +1,12 @@
+namespace Brizco.Domain.Dtos.LargDtos;
+
+public class SectionLDto : BaseDto
+{
+
+ public string Name { get; internal set; } = string.Empty;
+ public string Description { get; internal set; } = string.Empty;
+
+ public Guid ComplexId { get; set; }
+
+ public List Positions { get; internal set; } = new();
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/LargDtos/ShiftLDto.cs b/Brizco.Domain/Dtos/LargDtos/ShiftLDto.cs
new file mode 100644
index 0000000..dfca844
--- /dev/null
+++ b/Brizco.Domain/Dtos/LargDtos/ShiftLDto.cs
@@ -0,0 +1,11 @@
+namespace Brizco.Domain.Dtos.LargDtos;
+
+public class ShiftLDto : BaseDto
+{
+ 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 Days { get; set; } = new();
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/RequestDtos/UserActionRequestDto.cs b/Brizco.Domain/Dtos/RequestDtos/UserActionRequestDto.cs
index dabb287..4a21d12 100644
--- a/Brizco.Domain/Dtos/RequestDtos/UserActionRequestDto.cs
+++ b/Brizco.Domain/Dtos/RequestDtos/UserActionRequestDto.cs
@@ -11,6 +11,7 @@ public class UserActionRequestDto
public string NationalId { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public List RoleIds { get; set; } = new();
+ public Guid PositionId { get; set; }
public string SelectedRoleName { get; set; } = string.Empty;
diff --git a/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs
index 49f80b4..f1684c1 100644
--- a/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs
@@ -15,5 +15,6 @@ public class ApplicationUserSDto : BaseDto
public string NationalId { get; set; } = string.Empty;
public List RoleIds { get; set; } = new();
+ public Guid PositionId { get; set; }
public long BirthDateTimeStamp => DateTimeExtensions.DateTimeToUnixTimeStamp(BirthDate);
}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/PositionSDto.cs b/Brizco.Domain/Dtos/SmallDtos/PositionSDto.cs
new file mode 100644
index 0000000..70b343c
--- /dev/null
+++ b/Brizco.Domain/Dtos/SmallDtos/PositionSDto.cs
@@ -0,0 +1,12 @@
+namespace Brizco.Domain.Dtos.SmallDtos;
+
+public class PositionSDto : BaseDto
+{
+
+ public string Name { get; set; } = string.Empty;
+ public string Description { get; set; } = string.Empty;
+
+ public Guid ComplexId { get; set; }
+
+ public Guid SectionId { get; set; }
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs
new file mode 100644
index 0000000..cd278c5
--- /dev/null
+++ b/Brizco.Domain/Dtos/SmallDtos/PositionUserSDto.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.Dtos.SmallDtos;
+
+public class PositionUserSDto : BaseDto
+{
+ public Guid ApplicationUserId { get; set; }
+ public Guid PositionId { get; set; }
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/RoutineSDto.cs b/Brizco.Domain/Dtos/SmallDtos/RoutineSDto.cs
new file mode 100644
index 0000000..863d389
--- /dev/null
+++ b/Brizco.Domain/Dtos/SmallDtos/RoutineSDto.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.Dtos.SmallDtos;
+
+public class RoutineSDto : BaseDto
+{
+ public string Name { get; internal set; } = string.Empty;
+ public string Description { get; internal set; } = string.Empty;
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/SectionSDto.cs b/Brizco.Domain/Dtos/SmallDtos/SectionSDto.cs
new file mode 100644
index 0000000..da12239
--- /dev/null
+++ b/Brizco.Domain/Dtos/SmallDtos/SectionSDto.cs
@@ -0,0 +1,10 @@
+namespace Brizco.Domain.Dtos.SmallDtos;
+
+public class SectionSDto : BaseDto
+{
+
+ public string Name { get; internal set; } = string.Empty;
+ public string Description { get; internal set; } = string.Empty;
+
+ public Guid ComplexId { get; set; }
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftDaySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftDaySDto.cs
new file mode 100644
index 0000000..ff2b1f3
--- /dev/null
+++ b/Brizco.Domain/Dtos/SmallDtos/ShiftDaySDto.cs
@@ -0,0 +1,7 @@
+namespace Brizco.Domain.Dtos.SmallDtos;
+
+public class ShiftDaySDto : BaseDto
+{
+ public DayOfWeek DayOfWeek { get; set; }
+ public Guid ShiftId { get; set; }
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs
index 4cb97df..bde623e 100644
--- a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs
+++ b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs
@@ -8,4 +8,5 @@ public class ShiftSDto : BaseDto
public TimeSpan StartAt { get; set; }
public TimeSpan EndAt { get; set; }
public Guid ComplexId { get; set; }
+ public List Days { get; set; } = new();
}
diff --git a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs
index 726387b..6e051d9 100644
--- a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs
+++ b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs
@@ -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);
+ }
+}
diff --git a/Brizco.Domain/Entities/Complex/Position.cs b/Brizco.Domain/Entities/Complex/Position.cs
index 9be9250..fdd8998 100644
--- a/Brizco.Domain/Entities/Complex/Position.cs
+++ b/Brizco.Domain/Entities/Complex/Position.cs
@@ -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
{
diff --git a/Brizco.Domain/Entities/Complex/PositionUser.cs b/Brizco.Domain/Entities/Complex/PositionUser.cs
index fa23878..190701f 100644
--- a/Brizco.Domain/Entities/Complex/PositionUser.cs
+++ b/Brizco.Domain/Entities/Complex/PositionUser.cs
@@ -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()
{
diff --git a/Brizco.Domain/Entities/Complex/Section.cs b/Brizco.Domain/Entities/Complex/Section.cs
index 6fa03ce..e9eb926 100644
--- a/Brizco.Domain/Entities/Complex/Section.cs
+++ b/Brizco.Domain/Entities/Complex/Section.cs
@@ -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
{
diff --git a/Brizco.Domain/Entities/Shift/Shift.cs b/Brizco.Domain/Entities/Shift/Shift.cs
index e1dd0ce..937d4fb 100644
--- a/Brizco.Domain/Entities/Shift/Shift.cs
+++ b/Brizco.Domain/Entities/Shift/Shift.cs
@@ -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
{
diff --git a/Brizco.Domain/Entities/Shift/ShiftDay.cs b/Brizco.Domain/Entities/Shift/ShiftDay.cs
index 4da281c..bb8c96c 100644
--- a/Brizco.Domain/Entities/Shift/ShiftDay.cs
+++ b/Brizco.Domain/Entities/Shift/ShiftDay.cs
@@ -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()
diff --git a/Brizco.Domain/Mappers/PositionMapper.g.cs b/Brizco.Domain/Mappers/PositionMapper.g.cs
index 571fca8..1dffcbf 100644
--- a/Brizco.Domain/Mappers/PositionMapper.g.cs
+++ b/Brizco.Domain/Mappers/PositionMapper.g.cs
@@ -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> 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> 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> 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(p20 => new PositionUser()
+ {
+ ApplicationUserId = p20.ApplicationUserId,
+ PositionId = p20.PositionId,
+ Id = p20.Id
+ }).ToList(),
+ 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> 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(p28 => new PositionUserSDto()
+ {
+ ApplicationUserId = p28.ApplicationUserId,
+ PositionId = p28.PositionId,
+ Id = p28.Id
+ }).ToList(),
+ Id = p27.Id
+ };
+
+ private static List funcMain1(List p10)
+ {
+ if (p10 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain4(List p17, List p18)
+ {
+ if (p17 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain5(List p22)
+ {
+ if (p22 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain6(List p25, List p26)
+ {
+ if (p25 == null)
+ {
+ return null;
+ }
+ List result = new List(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;
+
+ }
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/PositionUserMapper.g.cs b/Brizco.Domain/Mappers/PositionUserMapper.g.cs
index 073b042..9e54d73 100644
--- a/Brizco.Domain/Mappers/PositionUserMapper.g.cs
+++ b/Brizco.Domain/Mappers/PositionUserMapper.g.cs
@@ -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> 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> ProjectToSDto => p8 => new PositionUserSDto()
+ {
+ ApplicationUserId = p8.ApplicationUserId,
+ PositionId = p8.PositionId,
+ Id = p8.Id
+ };
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/RoutineMapper.g.cs b/Brizco.Domain/Mappers/RoutineMapper.g.cs
index dda5115..3b1b749 100644
--- a/Brizco.Domain/Mappers/RoutineMapper.g.cs
+++ b/Brizco.Domain/Mappers/RoutineMapper.g.cs
@@ -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> 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> ProjectToSDto => p8 => new RoutineSDto()
+ {
+ Name = p8.Name,
+ Description = p8.Description,
+ Id = p8.Id
+ };
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/SectionMapper.g.cs b/Brizco.Domain/Mappers/SectionMapper.g.cs
index 72484f3..4a57786 100644
--- a/Brizco.Domain/Mappers/SectionMapper.g.cs
+++ b/Brizco.Domain/Mappers/SectionMapper.g.cs
@@ -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> 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> 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> ProjectLDtoToSection => p15 => new Section()
+ {
+ Name = p15.Name,
+ Description = p15.Description,
+ ComplexId = p15.ComplexId,
+ Positions = p15.Positions.Select(p16 => new Position()
+ {
+ Name = p16.Name,
+ Description = p16.Description,
+ ComplexId = p16.ComplexId,
+ SectionId = p16.SectionId,
+ Id = p16.Id
+ }).ToList(),
+ 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> ProjectToLDto => p23 => new SectionLDto()
+ {
+ Name = p23.Name,
+ Description = p23.Description,
+ ComplexId = p23.ComplexId,
+ Positions = p23.Positions.Select(p24 => new PositionSDto()
+ {
+ Name = p24.Name,
+ Description = p24.Description,
+ ComplexId = p24.ComplexId,
+ SectionId = p24.SectionId,
+ Id = p24.Id
+ }).ToList(),
+ Id = p23.Id
+ };
+
+ private static List funcMain1(List p10)
+ {
+ if (p10 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain2(List p13, List p14)
+ {
+ if (p13 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain3(List p18)
+ {
+ if (p18 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain4(List p21, List p22)
+ {
+ if (p21 == null)
+ {
+ return null;
+ }
+ List result = new List(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;
+
+ }
}
}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/ShiftDayMapper.g.cs b/Brizco.Domain/Mappers/ShiftDayMapper.g.cs
new file mode 100644
index 0000000..57a0928
--- /dev/null
+++ b/Brizco.Domain/Mappers/ShiftDayMapper.g.cs
@@ -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> 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> ProjectToSDto => p8 => new ShiftDaySDto()
+ {
+ DayOfWeek = p8.DayOfWeek,
+ ShiftId = p8.ShiftId,
+ Id = p8.Id
+ };
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Domain/Mappers/ShiftMapper.g.cs b/Brizco.Domain/Mappers/ShiftMapper.g.cs
index b50ad31..682d9ec 100644
--- a/Brizco.Domain/Mappers/ShiftMapper.g.cs
+++ b/Brizco.Domain/Mappers/ShiftMapper.g.cs
@@ -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> 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(p10 => new ShiftDay() {}).ToList(),
+ 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(funcMain5).ToList()),
+ 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(funcMain5).ToList(), result.Days);
+ result.Id = p13.Id;
+ return result;
+
+ }
+ public static Expression> ProjectToSDto => p17 => new ShiftSDto()
+ {
+ Title = p17.Title,
+ Description = p17.Description,
+ StartAt = p17.StartAt,
+ EndAt = p17.EndAt,
+ ComplexId = p17.ComplexId,
+ Days = p17.Days.Select(d => d.DayOfWeek).ToList(),
+ 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> ProjectLDtoToShift => p24 => new Shift()
+ {
+ Title = p24.Title,
+ StartAt = p24.StartAt,
+ EndAt = p24.EndAt,
+ Description = p24.Description,
+ ComplexId = p24.ComplexId,
+ Days = p24.Days.Select(p25 => new ShiftDay()
+ {
+ DayOfWeek = p25.DayOfWeek,
+ ShiftId = p25.ShiftId,
+ Id = p25.Id
+ }).ToList(),
+ 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> ProjectToLDto => p32 => new ShiftLDto()
+ {
+ Title = p32.Title,
+ Description = p32.Description,
+ StartAt = p32.StartAt,
+ EndAt = p32.EndAt,
+ ComplexId = p32.ComplexId,
+ Days = p32.Days.Select(p33 => new ShiftDaySDto()
+ {
+ DayOfWeek = p33.DayOfWeek,
+ ShiftId = p33.ShiftId,
+ Id = p33.Id
+ }).ToList(),
+ Id = p32.Id
+ };
+
+ private static List funcMain1(List p2)
{
if (p2 == null)
{
return null;
}
- Shift result = p3 ?? new Shift();
+ List result = new List(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> 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 funcMain3(List p7, List p8)
{
- if (p8 == null)
+ if (p7 == null)
{
return null;
}
- ShiftSDto result = p9 ?? new ShiftSDto();
+ List result = new List(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> 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 funcMain4(List p12)
{
- Complex result = p5 ?? new Complex();
+ if (p12 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain6(List p15, List p16)
+ {
+ if (p15 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain7(List p19)
+ {
+ if (p19 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain8(List p22, List p23)
+ {
+ if (p22 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain9(List p27)
+ {
+ if (p27 == null)
+ {
+ return null;
+ }
+ List result = new List(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 funcMain10(List p30, List p31)
+ {
+ if (p30 == null)
+ {
+ return null;
+ }
+ List result = new List(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;
}
diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs
index c2784b5..13e11ba 100644
--- a/Brizco.Domain/MapsterRegister.cs
+++ b/Brizco.Domain/MapsterRegister.cs
@@ -9,6 +9,7 @@ public class MapsterRegister : IRegister
public void Register(TypeAdapterConfig config)
{
config.NewConfig()
+ .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()
+ .Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty)
+ .TwoWays();
+
config.NewConfig()
.Map("ComplexName", o=>o.Complex!=null ? o.Complex.Name : string.Empty)
.Map("FirstName", o=>o.User!=null ? o.User.FirstName : string.Empty)
diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj
index 1bcddfd..d9c19b5 100644
--- a/Brizco.Repository/Brizco.Repository.csproj
+++ b/Brizco.Repository/Brizco.Repository.csproj
@@ -44,6 +44,7 @@
+
diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
index 0d6742a..ae8cf9b 100644
--- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs
@@ -3,14 +3,22 @@
public class GetActivitiesQueryHandler : IRequestHandler>
{
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> 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().TableNoTracking
+ .Where(a=>a.ComplexId==complexId)
.OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15)
.Select(ActivityMapper.ProjectToSDto)
diff --git a/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs
new file mode 100644
index 0000000..d0662da
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs
@@ -0,0 +1,44 @@
+namespace Brizco.Repository.Handlers.Position;
+
+public class CreatePositionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public CreatePositionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task 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().Add(entity);
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await _repositoryWrapper.CommitAsync(cancellationToken);
+ return entity.AdaptToSDto();
+ }
+ catch (Exception)
+ {
+ await _repositoryWrapper.RollBackAsync(cancellationToken);
+ throw;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs b/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs
new file mode 100644
index 0000000..aad562b
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/CreatePositionUserCommandHandler.cs
@@ -0,0 +1,37 @@
+using Brizco.Repository.Abstracts;
+
+namespace Brizco.Repository.Handlers.Position;
+
+public class CreatePositionUserCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public CreatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(CreatePositionUserCommand request, CancellationToken cancellationToken)
+ {
+ try
+ {
+ await _repositoryWrapper.BeginTransaction(cancellationToken);
+
+
+
+ var entity = await _repositoryWrapper.SetRepository().TableNoTracking
+ .FirstOrDefaultAsync(p => p.Id == request.PositionId, cancellationToken);
+ if (entity == null)
+ throw new AppException("Position not found");
+ entity.AddUser(request.UserId);
+ _repositoryWrapper.SetRepository().Update(entity);
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await _repositoryWrapper.CommitAsync(cancellationToken);
+ return true;
+ }
+ catch (Exception)
+ {
+ await _repositoryWrapper.RollBackAsync(cancellationToken);
+ throw;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs
new file mode 100644
index 0000000..40b198c
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs
@@ -0,0 +1,24 @@
+namespace Brizco.Repository.Handlers.Position;
+
+public class DeletePositionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public DeletePositionCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(DeletePositionCommand request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
+ if (shift == null)
+ throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
+ _repositoryWrapper.SetRepository()
+ .Delete(shift);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs b/Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs
new file mode 100644
index 0000000..473f39c
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs
@@ -0,0 +1,23 @@
+namespace Brizco.Repository.Handlers.Position;
+
+public class GetPositionQueryHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public GetPositionQueryHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(GetPositionQuery request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs b/Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs
new file mode 100644
index 0000000..3b8debc
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs
@@ -0,0 +1,31 @@
+namespace Brizco.Repository.Handlers.Position;
+
+public class GetPositionsQueryHandler : IRequestHandler>
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public GetPositionsQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task> 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().TableNoTracking
+ .Where(p=>p.ComplexId==complexId)
+ .OrderByDescending(s => s.CreatedAt)
+ .Skip(request.Page * 15).Take(15)
+ .Select(PositionMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+
+ return shifts;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs
new file mode 100644
index 0000000..22c4908
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs
@@ -0,0 +1,60 @@
+namespace Brizco.Repository.Handlers.Position;
+
+public class UpdatePositionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public UpdatePositionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+
+ public async Task Handle(UpdatePositionCommand request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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().TableNoTracking
+ .Where(pu => pu.PositionId == newPosition.Id)
+ .ToListAsync(cancellationToken);
+
+ //foreach (var user in users)
+ //{
+ // if (!request.UserIds.Contains(user.ApplicationUserId))
+ // {
+ // _repositoryWrapper.SetRepository()
+ // .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()
+ .Update(newPosition);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs b/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs
new file mode 100644
index 0000000..7c8c2bc
--- /dev/null
+++ b/Brizco.Repository/Handlers/Position/UpdatePositionUserCommandHandler.cs
@@ -0,0 +1,37 @@
+using Brizco.Repository.Abstracts;
+
+namespace Brizco.Repository.Handlers.Position;
+
+public class UpdatePositionUserCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public UpdatePositionUserCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(UpdatePositionUserCommand request, CancellationToken cancellationToken)
+ {
+ try
+ {
+ await _repositoryWrapper.BeginTransaction(cancellationToken);
+
+ var entity = await _repositoryWrapper.SetRepository().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().Update(newEntity);
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await _repositoryWrapper.CommitAsync(cancellationToken);
+ return true;
+ }
+ catch (Exception)
+ {
+ await _repositoryWrapper.RollBackAsync(cancellationToken);
+ throw;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs
new file mode 100644
index 0000000..f70242d
--- /dev/null
+++ b/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs
@@ -0,0 +1,38 @@
+namespace Brizco.Repository.Handlers.Routine;
+
+public class CreateRoutineCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public CreateRoutineCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task 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().Add(entity);
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await _repositoryWrapper.CommitAsync(cancellationToken);
+ return entity.AdaptToSDto();
+ }
+ catch (Exception)
+ {
+ await _repositoryWrapper.RollBackAsync(cancellationToken);
+ throw;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs
new file mode 100644
index 0000000..3405ace
--- /dev/null
+++ b/Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs
@@ -0,0 +1,24 @@
+namespace Brizco.Repository.Handlers.Routine;
+
+public class DeleteRoutineCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public DeleteRoutineCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(DeleteRoutineCommand request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
+ if (shift == null)
+ throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
+ _repositoryWrapper.SetRepository()
+ .Delete(shift);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs b/Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs
new file mode 100644
index 0000000..2bc8b32
--- /dev/null
+++ b/Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs
@@ -0,0 +1,23 @@
+namespace Brizco.Repository.Handlers.Routine;
+
+public class GetRoutineQueryHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public GetRoutineQueryHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(GetRoutineQuery request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs b/Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs
new file mode 100644
index 0000000..4fc9407
--- /dev/null
+++ b/Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs
@@ -0,0 +1,31 @@
+namespace Brizco.Repository.Handlers.Routine;
+
+public class GetRoutinesQueryHandler : IRequestHandler>
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public GetRoutinesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task> 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().TableNoTracking
+ .Where(p=>p.ComplexId==complexId)
+ .OrderByDescending(s => s.CreatedAt)
+ .Skip(request.Page * 15).Take(15)
+ .Select(RoutineMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+
+ return entities;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs
new file mode 100644
index 0000000..2ffb4b8
--- /dev/null
+++ b/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs
@@ -0,0 +1,43 @@
+namespace Brizco.Repository.Handlers.Routine;
+
+public class UpdateRoutineCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public UpdateRoutineCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+
+ public async Task Handle(UpdateRoutineCommand request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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().TableNoTracking
+ .Where(pu => pu.PositionId == newEntity.Id)
+ .ToListAsync(cancellationToken);
+
+
+ _repositoryWrapper.SetRepository()
+ .Update(newEntity);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs b/Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs
new file mode 100644
index 0000000..7b236cd
--- /dev/null
+++ b/Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs
@@ -0,0 +1,40 @@
+namespace Brizco.Repository.Handlers.Section;
+
+public class CreateSectionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public CreateSectionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task 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().Add(entity);
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ await _repositoryWrapper.CommitAsync(cancellationToken);
+ return entity.AdaptToSDto();
+ }
+ catch (Exception)
+ {
+ await _repositoryWrapper.RollBackAsync(cancellationToken);
+ throw;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs b/Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs
new file mode 100644
index 0000000..1b9f27a
--- /dev/null
+++ b/Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs
@@ -0,0 +1,24 @@
+namespace Brizco.Repository.Handlers.Section;
+
+public class DeleteSectionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public DeleteSectionCommandHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(DeleteSectionCommand request, CancellationToken cancellationToken)
+ {
+ var section = await _repositoryWrapper.SetRepository()
+ .TableNoTracking
+ .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken);
+ if (section == null)
+ throw new AppException("Postion not found", ApiResultStatusCode.NotFound);
+ _repositoryWrapper.SetRepository()
+ .Delete(section);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs b/Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs
new file mode 100644
index 0000000..bd4d3ab
--- /dev/null
+++ b/Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs
@@ -0,0 +1,23 @@
+namespace Brizco.Repository.Handlers.Section;
+
+public class GetSectionQueryHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+
+ public GetSectionQueryHandler(IRepositoryWrapper repositoryWrapper)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ }
+ public async Task Handle(GetSectionQuery request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs b/Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs
new file mode 100644
index 0000000..7199f03
--- /dev/null
+++ b/Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs
@@ -0,0 +1,30 @@
+namespace Brizco.Repository.Handlers.Section;
+
+public class GetSectionsQueryHandler : IRequestHandler>
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public GetSectionsQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+ public async Task> 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().TableNoTracking
+ .Where(s=>s.ComplexId==complexId)
+ .OrderByDescending(s => s.CreatedAt)
+ .Skip(request.Page * 15).Take(15)
+ .Select(SectionMapper.ProjectToSDto)
+ .ToListAsync(cancellationToken);
+
+
+ return shifts;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs b/Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs
new file mode 100644
index 0000000..7e6d05f
--- /dev/null
+++ b/Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs
@@ -0,0 +1,39 @@
+namespace Brizco.Repository.Handlers.Section;
+
+public class UpdateSectionCommandHandler : IRequestHandler
+{
+ private readonly IRepositoryWrapper _repositoryWrapper;
+ private readonly ICurrentUserService _currentUserService;
+
+ public UpdateSectionCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService)
+ {
+ _repositoryWrapper = repositoryWrapper;
+ _currentUserService = currentUserService;
+ }
+
+ public async Task Handle(UpdateSectionCommand request, CancellationToken cancellationToken)
+ {
+ var shift = await _repositoryWrapper.SetRepository()
+ .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()
+ .Update(newSection);
+
+ await _repositoryWrapper.SaveChangesAsync(cancellationToken);
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs
index 265f885..e39de57 100644
--- a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs
+++ b/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs
@@ -5,7 +5,7 @@ public class CreateShiftCommandHandler : IRequestHandler
+public class DeletePositionCommandHandler : IRequestHandler
{
private readonly IRepositoryWrapper _repositoryWrapper;
- public DeleteShiftCommandHandler(IRepositoryWrapper repositoryWrapper)
+ public DeletePositionCommandHandler(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
@@ -14,7 +14,7 @@ public class DeleteShiftCommandHandler : IRequestHandler 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()
.Delete(shift);
diff --git a/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs b/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs
index 5ccbedb..a220582 100644
--- a/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs
@@ -1,4 +1,6 @@
-namespace Brizco.Repository.Handlers.Shift;
+using Brizco.Domain.Entities.Shift;
+
+namespace Brizco.Repository.Handlers.Shift;
public class GetShiftPlanQueryHandler : IRequestHandler
{
@@ -18,6 +20,12 @@ public class GetShiftPlanQueryHandler : IRequestHandler()
+ // .TableNoTracking
+ // .Where(sd => sd.ShiftId == request.id)
+ // .ToListAsync(cancellationToken);
+ //shift.Days = shiftDays.Select(s => s.DayOfWeek).ToList();
+
return shift;
}
}
\ No newline at end of file
diff --git a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs
index c0e47ed..d894dd2 100644
--- a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs
@@ -3,14 +3,22 @@
public class GetShiftPlansQueryHandler : IRequestHandler>
{
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> 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().TableNoTracking
+ .Where(s=>s.ComplexId==complexId)
.OrderByDescending(s => s.CreatedAt)
.Skip(request.page * 15).Take(15)
.Select(ShiftMapper.ProjectToSDto)
diff --git a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs
index 83e2e26..b45e36c 100644
--- a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs
+++ b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs
@@ -2,12 +2,12 @@
namespace Brizco.Repository.Handlers.Shift;
-public class UpdateShiftCommandHandler : IRequestHandler
+public class UpdatePositionCommandHandler : IRequestHandler
{
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 sf.DayOfWeek == dayOfWeek);
- if (findDay != null)
- shift.SetDay(dayOfWeek);
+ if (findDay == null)
+ newShift.SetDay(dayOfWeek);
}
_repositoryWrapper.SetRepository()
diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs
index 9c631bb..55d93c5 100644
--- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs
+++ b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs
@@ -16,7 +16,7 @@ public class GetShiftPlanQueryHandler : IRequestHandler>
{
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> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken)
{
+ throw new NotImplementedException();
+
var shifts = await _repositoryWrapper.SetRepository().TableNoTracking
.OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15)
diff --git a/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs b/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs
index 180d5ec..581e371 100644
--- a/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs
+++ b/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs
@@ -3,14 +3,22 @@
public class GetActivitiesQueryHandler : IRequestHandler>
{
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> 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().TableNoTracking
+ .Where(t=>t.ComplexId==complexId)
.OrderByDescending(s => s.CreatedAt)
.Skip(request.Page * 15).Take(15)
.Select(TaskMapper.ProjectToSDto)