From 034b5270bbbaf19fdd9b168757396fd7719c7d6a Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Mon, 18 Sep 2023 15:41:41 +0330 Subject: [PATCH] feat : complete cqrs , change db change db and identityt , complete cqrs , add complex controller --- Berizco.Api/Brizco.Api.csproj | 1 + Berizco.Api/Controllers/ComplexController.cs | 48 + Berizco.Api/Controllers/ShiftController.cs | 11 +- Berizco.Api/Controllers/TaskController.cs | 6 +- Berizco.Api/Services/CurrentUserService.cs | 18 + .../Abstracts/ICurrentUserService.cs | 9 + Berizco.Repository/Brizco.Repository.csproj | 2 + .../Activity/CreateActivityCommandHandler.cs | 17 +- .../Activity/DeleteActivityCommandHandler.cs | 2 +- .../Activity/UpdateActivityCommandHandler.cs | 11 +- .../Complex/CreateComplexCommandHandler.cs | 21 + .../Complex/DeleteComplexCommandHandler.cs | 24 + .../Complex/GetComplexQueryHandler.cs | 23 + .../Complex/GetComplexesQueryHandler.cs | 21 + .../Complex/UpdateActivityCommandHandler.cs | 50 + .../Shift/CreateShiftCommandHandler.cs | 14 +- .../Handlers/Shift/GetShiftQueryHandler.cs | 4 +- .../Handlers/Shift/GetShiftsQueryHandler.cs | 4 +- .../Shift/UpdateShiftCommandHandler.cs | 15 +- .../CreateShiftPlanCommandHandler.cs | 30 + .../DeleteShiftPlanCommandHandler.cs | 26 + .../ShiftPlan/GetShiftPlanQueryHandler.cs | 22 + .../ShiftPlan/GetShiftPlansQueryHandler.cs | 21 + .../UpdateShiftPlanCommandHandler.cs | 55 ++ .../Handlers/Task/CreateTaskCommandHandler.cs | 16 +- .../Handlers/Task/UpdateTaskCommandHandler.cs | 12 +- .../20230912124533_init.Designer.cs | 871 ---------------- ...0230912132807_addShiftPlanUser.Designer.cs | 935 ------------------ .../20230912132807_addShiftPlanUser.cs | 64 -- .../Migrations/20230917141849_editTask.cs | 208 ---- ...ner.cs => 20230918112118_Init.Designer.cs} | 112 ++- ...2124533_init.cs => 20230918112118_Init.cs} | 504 ++++++---- .../ApplicationContextModelSnapshot.cs | 108 +- .../Models/ApplicationContext.cs | 17 + Brizco.Domain/Brizco.Domain.csproj | 2 + .../Commands/ActivityCommands.cs | 2 +- .../Commands/ComplexCommands.cs | 13 + .../CommandQueries/Commands/ShiftCommands.cs | 4 +- .../Commands/ShiftPlanCommands.cs | 10 + .../CommandQueries/Commands/TaskCommands.cs | 4 +- .../CommandQueries/Queries/ActivityQueries.cs | 4 +- .../CommandQueries/Queries/ComplexQueries.cs | 7 + .../Queries/ShiftPlanQueries.cs | 7 + .../CommandQueries/Queries/TaskQueries.cs | 4 +- Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs | 11 + .../Dtos/SmallDtos/ComplexUserSDto.cs | 2 - Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs | 11 + .../Dtos/SmallDtos/ShiftPlanUserSDto.cs | 9 + Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs | 1 + Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs | 1 + .../Entities/Complex/Aggregate.Complex.cs | 9 + Brizco.Domain/Entities/Complex/Complex.cs | 25 +- Brizco.Domain/Entities/Complex/ComplexUser.cs | 1 - .../Entities/Shift/Aggregate.Shift.cs | 6 +- Brizco.Domain/Entities/Shift/Shift.cs | 12 +- Brizco.Domain/Entities/Shift/ShiftPlan.cs | 14 +- Brizco.Domain/Entities/Shift/ShiftPlanUser.cs | 10 +- Brizco.Domain/Entities/Task/Activity.cs | 6 +- Brizco.Domain/Entities/Task/Aggregate.Task.cs | 12 +- Brizco.Domain/Entities/Task/Task.cs | 7 +- .../Entities/User/ApplicationRole.cs | 3 + Brizco.Domain/Mappers/ActivityMapper.g.cs | 66 ++ Brizco.Domain/Mappers/ComplexUserMapper.g.cs | 6 - Brizco.Domain/Mappers/ShiftMapper.g.cs | 116 ++- Brizco.Domain/Mappers/ShiftPlanMapper.g.cs | 265 +++++ .../Mappers/ShiftPlanUserMapper.g.cs | 69 ++ Brizco.Domain/Mappers/TaskMapper.g.cs | 6 + 67 files changed, 1609 insertions(+), 2418 deletions(-) create mode 100644 Berizco.Api/Controllers/ComplexController.cs create mode 100644 Berizco.Api/Services/CurrentUserService.cs create mode 100644 Berizco.Repository/Abstracts/ICurrentUserService.cs create mode 100644 Berizco.Repository/Handlers/Complex/CreateComplexCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Complex/UpdateActivityCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs delete mode 100644 Berizco.Repository/Migrations/20230912124533_init.Designer.cs delete mode 100644 Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.Designer.cs delete mode 100644 Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.cs delete mode 100644 Berizco.Repository/Migrations/20230917141849_editTask.cs rename Berizco.Repository/Migrations/{20230917141849_editTask.Designer.cs => 20230918112118_Init.Designer.cs} (90%) rename Berizco.Repository/Migrations/{20230912124533_init.cs => 20230918112118_Init.cs} (72%) create mode 100644 Brizco.Domain/CommandQueries/Commands/ComplexCommands.cs create mode 100644 Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs create mode 100644 Brizco.Domain/CommandQueries/Queries/ComplexQueries.cs create mode 100644 Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs create mode 100644 Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs create mode 100644 Brizco.Domain/Entities/Complex/Aggregate.Complex.cs create mode 100644 Brizco.Domain/Mappers/ShiftPlanMapper.g.cs create mode 100644 Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs diff --git a/Berizco.Api/Brizco.Api.csproj b/Berizco.Api/Brizco.Api.csproj index 8604108..5e1f5ca 100644 --- a/Berizco.Api/Brizco.Api.csproj +++ b/Berizco.Api/Brizco.Api.csproj @@ -89,6 +89,7 @@ + diff --git a/Berizco.Api/Controllers/ComplexController.cs b/Berizco.Api/Controllers/ComplexController.cs new file mode 100644 index 0000000..bbf7480 --- /dev/null +++ b/Berizco.Api/Controllers/ComplexController.cs @@ -0,0 +1,48 @@ +namespace Brizco.Api.Controllers; + +public class ComplexController : ICarterModule +{ + + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Complex").MapGroup($"api/complex"); + + group.MapGet("{page}", GetAllAsync) + .WithDisplayName("GetAllComplex") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetOneComplex") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public async Task GetAllAsync(int page,ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetComplexesQuery(page), cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetComplexQuery(id))); + + // POST:Create Entity + public async Task Post([FromBody] CreateComplexCommand ent, ISender mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(ent, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateComplexCommand 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 DeleteComplexCommand(id), cancellationToken)); + +} \ No newline at end of file diff --git a/Berizco.Api/Controllers/ShiftController.cs b/Berizco.Api/Controllers/ShiftController.cs index 5bd86ac..92270aa 100644 --- a/Berizco.Api/Controllers/ShiftController.cs +++ b/Berizco.Api/Controllers/ShiftController.cs @@ -8,7 +8,7 @@ public class ShiftController : ICarterModule { var group = app.NewVersionedApi("Shift").MapGroup($"api/shift"); - group.MapGet("", GetAllAsync) + group.MapGet("{page}", GetAllAsync) .WithDisplayName("GetAllShift") .HasApiVersion(1.0); @@ -24,11 +24,16 @@ public class ShiftController : ICarterModule group.MapDelete("", Delete) .HasApiVersion(1.0); + + + group.MapPost("/plan", Post) + .WithDisplayName("AddNewPlan") + .HasApiVersion(1.0); } // GET:Get All Entity - public async Task GetAllAsync(ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetShiftsQuery(), cancellationToken)); + public async Task GetAllAsync(int page,ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetShiftsQuery(page), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) diff --git a/Berizco.Api/Controllers/TaskController.cs b/Berizco.Api/Controllers/TaskController.cs index 16e65ee..01c22c1 100644 --- a/Berizco.Api/Controllers/TaskController.cs +++ b/Berizco.Api/Controllers/TaskController.cs @@ -9,7 +9,7 @@ public class TaskController : ICarterModule { var group = app.NewVersionedApi("Task").MapGroup($"api/task"); - group.MapGet("", GetAllAsync) + group.MapGet("{page}", GetAllAsync) .WithDisplayName("GetAllTask") .HasApiVersion(1.0); @@ -28,8 +28,8 @@ public class TaskController : ICarterModule } // GET:Get All Entity - public async Task GetAllAsync(ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetTasksQuery(), cancellationToken)); + public async Task GetAllAsync(int page,ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetTasksQuery(page), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) diff --git a/Berizco.Api/Services/CurrentUserService.cs b/Berizco.Api/Services/CurrentUserService.cs new file mode 100644 index 0000000..b491e9c --- /dev/null +++ b/Berizco.Api/Services/CurrentUserService.cs @@ -0,0 +1,18 @@ +using Brizco.Repository.Abstracts; + +namespace Brizco.Api.Services; + +public class CurrentUserService : ICurrentUserService +{ + private readonly IHttpContextAccessor _httpContextAccessor; + + public CurrentUserService(IHttpContextAccessor httpContextAccessor) + { + _httpContextAccessor = httpContextAccessor; + } + + public string? UserId => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier); + public string? RoleName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role); + public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name); + public string? ComplexId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("ComplexId"); +} \ No newline at end of file diff --git a/Berizco.Repository/Abstracts/ICurrentUserService.cs b/Berizco.Repository/Abstracts/ICurrentUserService.cs new file mode 100644 index 0000000..a53ba6d --- /dev/null +++ b/Berizco.Repository/Abstracts/ICurrentUserService.cs @@ -0,0 +1,9 @@ +namespace Brizco.Repository.Abstracts; + +public interface ICurrentUserService : IScopedDependency +{ + string? UserId { get; } + string? RoleName { get; } + string? ComplexId { get; } + string? UserName { get; } +} \ No newline at end of file diff --git a/Berizco.Repository/Brizco.Repository.csproj b/Berizco.Repository/Brizco.Repository.csproj index 65f38ea..7f2feeb 100644 --- a/Berizco.Repository/Brizco.Repository.csproj +++ b/Berizco.Repository/Brizco.Repository.csproj @@ -44,7 +44,9 @@ + + diff --git a/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs b/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs index f94fdc9..41bb5b8 100644 --- a/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs +++ b/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs @@ -1,17 +1,23 @@ -using Brizco.Domain.Dtos.LargDtos; - -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activity; public class CreateActivityCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; - public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + private readonly ICurrentUserService _currentUserService; + + public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(CreateActivityCommand 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 task = Domain.Entities.Task.Activity .Create( request.Status, @@ -27,7 +33,8 @@ public class CreateActivityCommandHandler : IRequestHandler() .TableNoTracking - .FirstOrDefaultAsync(s => s.Id == request.id, cancellationToken); + .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (task == null) throw new AppException("Task not found", ApiResultStatusCode.NotFound); _repositoryWrapper.SetRepository() diff --git a/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs b/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs index 519021a..9871f4f 100644 --- a/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs +++ b/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs @@ -3,10 +3,12 @@ public class UpdateActivityCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; - public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(UpdateActivityCommand request, CancellationToken cancellationToken) @@ -15,6 +17,10 @@ public class UpdateActivityCommandHandler : IRequestHandler s.Id == request.Id,cancellationToken); if (task == null) throw new AppException("Task 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 newTask = Domain.Entities.Task.Activity.Create( request.Status, @@ -30,7 +36,8 @@ public class UpdateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + + public CreateComplexCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + } + + public async Task Handle(CreateComplexCommand request, CancellationToken cancellationToken) + { + var complex = Domain.Entities.Complex.Complex.Create(request.Name, request.Address, request.SupportPhone); + _repositoryWrapper.SetRepository().Add(complex); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return complex.AdaptToSDto(); + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs b/Berizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs new file mode 100644 index 0000000..2dec095 --- /dev/null +++ b/Berizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs @@ -0,0 +1,24 @@ +namespace Brizco.Repository.Handlers.Complex; + +public class DeleteComplexCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteComplexCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteComplexCommand request, CancellationToken cancellationToken) + { + var task = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); + if (task == null) + throw new AppException("Task not found", ApiResultStatusCode.NotFound); + _repositoryWrapper.SetRepository() + .Delete(task); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs b/Berizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs new file mode 100644 index 0000000..cd5b59b --- /dev/null +++ b/Berizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs @@ -0,0 +1,23 @@ +namespace Brizco.Repository.Handlers.Complex; + +public class GetComplexQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetComplexQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(GetComplexQuery request, CancellationToken cancellationToken) + { + var complex = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == request.Id) + .Select(ComplexMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (complex == null) + throw new AppException("Complex not found", ApiResultStatusCode.NotFound); + return complex; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs b/Berizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs new file mode 100644 index 0000000..8958889 --- /dev/null +++ b/Berizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs @@ -0,0 +1,21 @@ +namespace Brizco.Repository.Handlers.Complex; + +public class GetComplexesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetComplexesQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetComplexesQuery request, CancellationToken cancellationToken) + { + var tasks = await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ComplexMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return tasks; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Complex/UpdateActivityCommandHandler.cs b/Berizco.Repository/Handlers/Complex/UpdateActivityCommandHandler.cs new file mode 100644 index 0000000..a17e9cb --- /dev/null +++ b/Berizco.Repository/Handlers/Complex/UpdateActivityCommandHandler.cs @@ -0,0 +1,50 @@ +namespace Brizco.Repository.Handlers.Complex; + +public class UpdateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; + + public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) + { + _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; + } + + public async Task Handle(UpdateActivityCommand request, CancellationToken cancellationToken) + { + var task = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken); + if (task == null) + throw new AppException("Task 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 newTask = Domain.Entities.Task.Activity.Create( + request.Status, + request.DoneAt, + request.PerformanceDescription, + request.Title, + request.Description, + request.Type, + request.IsRelatedToShift, + request.IsRelatedToRole, + request.IsRelatedToPerson, + request.IsDisposable, + request.SetFor, + request.HasDisposed, + request.Amount, + request.AmountType, + complexId); + + newTask.Id = request.Id; + + _repositoryWrapper.SetRepository() + .Update(newTask); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs b/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs index ca3a47a..f56b0c0 100644 --- a/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs +++ b/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs @@ -3,17 +3,27 @@ public class CreateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; - public CreateShiftCommandHandler(IRepositoryWrapper repositoryWrapper) + private readonly ICurrentUserService _currentUserService; + + public CreateShiftCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(CreateShiftCommand 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 shift = Domain.Entities.Shift.Shift .Create(request.Title, request.Description, request.StartAt, - request.EndAt); + request.EndAt, + complexId); request.DayOfWeeks.ForEach(d => shift.SetDay(d)); diff --git a/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs b/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs index 6f44db2..bd787a4 100644 --- a/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs +++ b/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs @@ -1,10 +1,10 @@ namespace Brizco.Repository.Handlers.Shift; -public class GetShiftQueryHandler : IRequestHandler +public class GetShiftPlanQueryHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; - public GetShiftQueryHandler(IRepositoryWrapper repositoryWrapper) + public GetShiftPlanQueryHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } diff --git a/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs index 5e10aba..679393a 100644 --- a/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs @@ -1,10 +1,10 @@ namespace Brizco.Repository.Handlers.Shift; -public class GetShiftsQueryHandler : IRequestHandler> +public class GetShiftPlansQueryHandler : IRequestHandler> { private readonly IRepositoryWrapper _repositoryWrapper; - public GetShiftsQueryHandler(IRepositoryWrapper repositoryWrapper) + public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } diff --git a/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs index 13138aa..5d8c6cd 100644 --- a/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs +++ b/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs @@ -3,10 +3,12 @@ public class UpdateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; - public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper) + public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(UpdateShiftCommand request, CancellationToken cancellationToken) @@ -16,7 +18,16 @@ public class UpdateShiftCommandHandler : IRequestHandler() .Update(newShift); diff --git a/Berizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Berizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs new file mode 100644 index 0000000..23b80dc --- /dev/null +++ b/Berizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs @@ -0,0 +1,30 @@ +namespace Brizco.Repository.Handlers.ShiftPlan; + +public class CreateShiftPlanCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + public CreateShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateShiftPlanCommand request, CancellationToken cancellationToken) + { + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.ShiftId, cancellationToken); + + if (shift == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + + var shiftPlan = shift.AddPlan(request.StartAt, request.EndAt); + + if (request.UserIds.Count == 0) + throw new AppException("شیفت بندی مورد نظر باید حداقل متشکل از یک فرد باشد", ApiResultStatusCode.BadRequest); + + request.UserIds.ForEach(i=>shiftPlan.AddUser(i)); + + _repositoryWrapper.SetRepository().Add(shiftPlan); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return shiftPlan.AdaptToLDto(); + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs b/Berizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs new file mode 100644 index 0000000..160d56c --- /dev/null +++ b/Berizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs @@ -0,0 +1,26 @@ +namespace Brizco.Repository.Handlers.ShiftPlan; + +public class DeleteShiftPlanCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken) + { + var shiftPlan = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id); + + if (shiftPlan == null) + throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); + + _repositoryWrapper.SetRepository() + .Delete(shiftPlan); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs b/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs new file mode 100644 index 0000000..9c631bb --- /dev/null +++ b/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs @@ -0,0 +1,22 @@ +namespace Brizco.Repository.Handlers.ShiftPlan; + +public class GetShiftPlanQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetShiftPlanQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetShiftPlanQuery request, CancellationToken cancellationToken) + { + var shiftPlan = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == request.Id) + .Select(ShiftPlanMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (shiftPlan == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + return shiftPlan; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs b/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs new file mode 100644 index 0000000..d8ba3ab --- /dev/null +++ b/Berizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs @@ -0,0 +1,21 @@ +namespace Brizco.Repository.Handlers.ShiftPlan; + +public class GetShiftPlansQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken) + { + var shifts = await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return shifts; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs b/Berizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs new file mode 100644 index 0000000..538fdf3 --- /dev/null +++ b/Berizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs @@ -0,0 +1,55 @@ +namespace Brizco.Repository.Handlers.ShiftPlan; + +public class UpdateShiftPlanCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(UpdateShiftPlanCommand request, CancellationToken cancellationToken) + { + var shiftPlan = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken); + + if (shiftPlan == null) + throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); + + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.ShiftId, cancellationToken); + + if (shift == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + + + var newPlan = shift.AddPlan(request.StartAt, request.EndAt); + newPlan.Id = request.Id; + + + var shiftPlanUsers = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.ShiftPlanId == newPlan.Id) + .ToListAsync(cancellationToken); + + foreach (var shiftPlanUser in shiftPlanUsers) + { + if (request.UserIds.Contains(shiftPlanUser.Id)) + request.UserIds.Remove(shiftPlanUser.Id); + else + _repositoryWrapper.SetRepository() + .Delete(shiftPlanUser); + } + + foreach (var userId in request.UserIds) + newPlan.AddUser(userId); + + _repositoryWrapper.SetRepository() + .Update(newPlan); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + + return true; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs b/Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs index cdc36c8..71a756d 100644 --- a/Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs +++ b/Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs @@ -1,16 +1,21 @@ -using Brizco.Domain.Dtos.LargDtos; - -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Task; public class CreateActivityCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; - public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + private readonly ICurrentUserService _currentUserService; + + public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(CreateTaskCommand 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 task = Domain.Entities.Task.Task .Create(request.Title, request.Description, @@ -22,7 +27,8 @@ public class CreateActivityCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; + private readonly ICurrentUserService _currentUserService; - public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(UpdateTaskCommand request, CancellationToken cancellationToken) @@ -16,6 +18,11 @@ public class UpdateActivityCommandHandler : IRequestHandler() diff --git a/Berizco.Repository/Migrations/20230912124533_init.Designer.cs b/Berizco.Repository/Migrations/20230912124533_init.Designer.cs deleted file mode 100644 index c4231f3..0000000 --- a/Berizco.Repository/Migrations/20230912124533_init.Designer.cs +++ /dev/null @@ -1,871 +0,0 @@ -// -using System; -using Brizco.Repository.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Brizco.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20230912124533_init")] - partial class init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Brizco.Domain.Entities.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("Gender") - .HasColumnType("integer"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Complex", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SupportPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Complexes"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ComplexUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ComplexId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ComplexId"); - - b.HasIndex("UserId"); - - b.ToTable("ComplexUsers"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("EndAt") - .HasColumnType("interval"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("StartAt") - .HasColumnType("interval"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Shifts"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DayOfWeek") - .HasColumnType("integer"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.ToTable("ShiftDays"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("EndAt") - .HasColumnType("timestamp without time zone"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.Property("StartAt") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.ToTable("ShiftPlans"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Amount") - .HasColumnType("integer"); - - b.Property("AmountType") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - - b.Property("HasDisposed") - .HasColumnType("boolean"); - - b.Property("IsDisposable") - .HasColumnType("boolean"); - - b.Property("IsRelatedToPerson") - .HasColumnType("boolean"); - - b.Property("IsRelatedToRole") - .HasColumnType("boolean"); - - b.Property("IsRelatedToShift") - .HasColumnType("boolean"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SetFor") - .HasColumnType("timestamp without time zone"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tasks"); - - b.HasDiscriminator("Discriminator").HasValue("Task"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.HasIndex("TaskId"); - - b.ToTable("TaskRoles"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.HasIndex("TaskId"); - - b.ToTable("TaskShifts"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("TaskId"); - - b.HasIndex("UserId"); - - b.ToTable("TaskUsers"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Activity", b => - { - b.HasBaseType("Brizco.Domain.Entities.Task"); - - b.Property("DoneAt") - .HasColumnType("timestamp without time zone"); - - b.Property("PerformanceDescription") - .IsRequired() - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue("Activity"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.SubTask", b => - { - b.HasBaseType("Brizco.Domain.Entities.Task"); - - b.HasDiscriminator().HasValue("SubTask"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ComplexUser", b => - { - b.HasOne("Brizco.Domain.Entities.Complex", "Complex") - .WithMany() - .HasForeignKey("ComplexId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Complex"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskRoles") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Role"); - - b.Navigation("Task"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskShifts") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - - b.Navigation("Task"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => - { - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskUsers") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Task"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => - { - b.Navigation("TaskRoles"); - - b.Navigation("TaskShifts"); - - b.Navigation("TaskUsers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.Designer.cs b/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.Designer.cs deleted file mode 100644 index 474d31e..0000000 --- a/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.Designer.cs +++ /dev/null @@ -1,935 +0,0 @@ -// -using System; -using Brizco.Repository.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Brizco.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20230912132807_addShiftPlanUser")] - partial class addShiftPlanUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Brizco.Domain.Entities.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("Gender") - .HasColumnType("integer"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Complex", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SupportPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Complexes"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ComplexUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ComplexId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ComplexId"); - - b.HasIndex("UserId"); - - b.ToTable("ComplexUsers"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("EndAt") - .HasColumnType("interval"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("StartAt") - .HasColumnType("interval"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Shifts"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DayOfWeek") - .HasColumnType("integer"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.ToTable("ShiftDays"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("EndAt") - .HasColumnType("timestamp without time zone"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.Property("StartAt") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.ToTable("ShiftPlans"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlanUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftPlanId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("ShiftPlanId"); - - b.ToTable("ShiftPlanUsers"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Amount") - .HasColumnType("integer"); - - b.Property("AmountType") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("Discriminator") - .IsRequired() - .HasColumnType("text"); - - b.Property("HasDisposed") - .HasColumnType("boolean"); - - b.Property("IsDisposable") - .HasColumnType("boolean"); - - b.Property("IsRelatedToPerson") - .HasColumnType("boolean"); - - b.Property("IsRelatedToRole") - .HasColumnType("boolean"); - - b.Property("IsRelatedToShift") - .HasColumnType("boolean"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SetFor") - .HasColumnType("timestamp without time zone"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tasks"); - - b.HasDiscriminator("Discriminator").HasValue("Task"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.HasIndex("TaskId"); - - b.ToTable("TaskRoles"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ShiftId"); - - b.HasIndex("TaskId"); - - b.ToTable("TaskShifts"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("TaskId") - .HasColumnType("uuid"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("TaskId"); - - b.HasIndex("UserId"); - - b.ToTable("TaskUsers"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid"); - - b.Property("RoleId") - .HasColumnType("uuid"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Activity", b => - { - b.HasBaseType("Brizco.Domain.Entities.Task"); - - b.Property("DoneAt") - .HasColumnType("timestamp without time zone"); - - b.Property("PerformanceDescription") - .IsRequired() - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue("Activity"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.SubTask", b => - { - b.HasBaseType("Brizco.Domain.Entities.Task"); - - b.HasDiscriminator().HasValue("SubTask"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ComplexUser", b => - { - b.HasOne("Brizco.Domain.Entities.Complex", "Complex") - .WithMany() - .HasForeignKey("ComplexId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Complex"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlanUser", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ShiftPlan", "ShiftPlan") - .WithMany() - .HasForeignKey("ShiftPlanId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("ShiftPlan"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", "Role") - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskRoles") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Role"); - - b.Navigation("Task"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => - { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskShifts") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Shift"); - - b.Navigation("Task"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => - { - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskUsers") - .HasForeignKey("TaskId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Task"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => - { - b.Navigation("TaskRoles"); - - b.Navigation("TaskShifts"); - - b.Navigation("TaskUsers"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.cs b/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.cs deleted file mode 100644 index 9c15620..0000000 --- a/Berizco.Repository/Migrations/20230912132807_addShiftPlanUser.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Brizco.Repository.Migrations -{ - /// - public partial class addShiftPlanUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ShiftPlanUsers", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - ShiftPlanId = table.Column(type: "uuid", nullable: false), - ApplicationUserId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ShiftPlanUsers", x => x.Id); - table.ForeignKey( - name: "FK_ShiftPlanUsers_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ShiftPlanUsers_ShiftPlans_ShiftPlanId", - column: x => x.ShiftPlanId, - principalTable: "ShiftPlans", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateIndex( - name: "IX_ShiftPlanUsers_ApplicationUserId", - table: "ShiftPlanUsers", - column: "ApplicationUserId"); - - migrationBuilder.CreateIndex( - name: "IX_ShiftPlanUsers_ShiftPlanId", - table: "ShiftPlanUsers", - column: "ShiftPlanId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ShiftPlanUsers"); - } - } -} diff --git a/Berizco.Repository/Migrations/20230917141849_editTask.cs b/Berizco.Repository/Migrations/20230917141849_editTask.cs deleted file mode 100644 index be93d01..0000000 --- a/Berizco.Repository/Migrations/20230917141849_editTask.cs +++ /dev/null @@ -1,208 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Brizco.Repository.Migrations -{ - /// - public partial class editTask : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Title", - table: "Tasks", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Tasks", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AddColumn( - name: "IsDone", - table: "Tasks", - type: "boolean", - nullable: true); - - migrationBuilder.AlterColumn( - name: "Title", - table: "Shifts", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Shifts", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "SupportPhone", - table: "Complexes", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Complexes", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Complexes", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "AspNetUsers", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "AspNetUsers", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - - migrationBuilder.AlterColumn( - name: "Description", - table: "AspNetRoles", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "text"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsDone", - table: "Tasks"); - - migrationBuilder.AlterColumn( - name: "Title", - table: "Tasks", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Tasks", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Title", - table: "Shifts", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "Shifts", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "SupportPhone", - table: "Complexes", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Name", - table: "Complexes", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Complexes", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "AspNetUsers", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "AspNetUsers", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "AspNetRoles", - type: "text", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - } - } -} diff --git a/Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs b/Berizco.Repository/Migrations/20230918112118_Init.Designer.cs similarity index 90% rename from Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs rename to Berizco.Repository/Migrations/20230918112118_Init.Designer.cs index e12d1c5..6ba96a8 100644 --- a/Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs +++ b/Berizco.Repository/Migrations/20230918112118_Init.Designer.cs @@ -12,14 +12,15 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Brizco.Repository.Migrations { [DbContext(typeof(ApplicationContext))] - [Migration("20230917141849_editTask")] - partial class editTask + [Migration("20230918112118_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder + .HasDefaultSchema("public") .HasAnnotation("ProductVersion", "7.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 63); @@ -32,6 +33,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("uuid"); b.Property("Address") + .IsRequired() .HasColumnType("text"); b.Property("CreatedAt") @@ -52,6 +54,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.Property("RemovedAt") @@ -62,11 +65,12 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("SupportPhone") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Complexes"); + b.ToTable("Complexes", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => @@ -102,9 +106,6 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); - b.Property("RoleId") - .HasColumnType("uuid"); - b.Property("UserId") .HasColumnType("uuid"); @@ -114,7 +115,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("ComplexUsers"); + b.ToTable("ComplexUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => @@ -123,6 +124,9 @@ namespace Brizco.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -131,6 +135,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("EndAt") @@ -157,11 +162,14 @@ namespace Brizco.Repository.Migrations .HasColumnType("interval"); b.Property("Title") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Shifts"); + b.HasIndex("ComplexId"); + + b.ToTable("Shifts", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => @@ -204,7 +212,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftId"); - b.ToTable("ShiftDays"); + b.ToTable("ShiftDays", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => @@ -250,7 +258,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftId"); - b.ToTable("ShiftPlans"); + b.ToTable("ShiftPlans", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => @@ -295,7 +303,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftPlanId"); - b.ToTable("ShiftPlanUsers"); + b.ToTable("ShiftPlanUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => @@ -310,6 +318,9 @@ namespace Brizco.Repository.Migrations b.Property("AmountType") .HasColumnType("integer"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -318,6 +329,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -360,6 +372,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("Title") + .IsRequired() .HasColumnType("text"); b.Property("Type") @@ -367,7 +380,9 @@ namespace Brizco.Repository.Migrations b.HasKey("Id"); - b.ToTable("Tasks"); + b.HasIndex("ComplexId"); + + b.ToTable("Tasks", "public"); b.HasDiscriminator("Discriminator").HasValue("Task"); @@ -416,7 +431,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("TaskId"); - b.ToTable("TaskRoles"); + b.ToTable("TaskRoles", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => @@ -461,7 +476,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("TaskId"); - b.ToTable("TaskShifts"); + b.ToTable("TaskShifts", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => @@ -506,7 +521,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("TaskUsers"); + b.ToTable("TaskUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => @@ -515,11 +530,15 @@ namespace Brizco.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -532,11 +551,13 @@ namespace Brizco.Repository.Migrations b.HasKey("Id"); + b.HasIndex("ComplexId"); + b.HasIndex("NormalizedName") .IsUnique() .HasDatabaseName("RoleNameIndex"); - b.ToTable("AspNetRoles", (string)null); + b.ToTable("Roles", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b => @@ -563,12 +584,14 @@ namespace Brizco.Repository.Migrations .HasColumnType("boolean"); b.Property("FirstName") + .IsRequired() .HasColumnType("text"); b.Property("Gender") .HasColumnType("integer"); b.Property("LastName") + .IsRequired() .HasColumnType("text"); b.Property("LockoutEnabled") @@ -613,7 +636,7 @@ namespace Brizco.Repository.Migrations .IsUnique() .HasDatabaseName("UserNameIndex"); - b.ToTable("AspNetUsers", (string)null); + b.ToTable("Users", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -637,7 +660,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims", (string)null); + b.ToTable("RoleClaims", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -661,7 +684,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims", (string)null); + b.ToTable("Claims", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => @@ -682,7 +705,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins", (string)null); + b.ToTable("Logins", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => @@ -697,7 +720,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles", (string)null); + b.ToTable("UserRoles", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -716,7 +739,7 @@ namespace Brizco.Repository.Migrations b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens", (string)null); + b.ToTable("Tokens", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => @@ -730,6 +753,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("boolean"); b.Property("PerformanceDescription") + .IsRequired() .HasColumnType("text"); b.Property("Status") @@ -741,7 +765,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => { b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") - .WithMany() + .WithMany("Users") .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -757,6 +781,17 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => { b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") @@ -798,6 +833,17 @@ namespace Brizco.Repository.Migrations b.Navigation("ShiftPlan"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b => { b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") @@ -855,6 +901,15 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) @@ -906,6 +961,17 @@ namespace Brizco.Repository.Migrations .IsRequired(); }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => { b.Navigation("Days"); diff --git a/Berizco.Repository/Migrations/20230912124533_init.cs b/Berizco.Repository/Migrations/20230918112118_Init.cs similarity index 72% rename from Berizco.Repository/Migrations/20230912124533_init.cs rename to Berizco.Repository/Migrations/20230918112118_Init.cs index 8101a90..b702314 100644 --- a/Berizco.Repository/Migrations/20230912124533_init.cs +++ b/Berizco.Repository/Migrations/20230918112118_Init.cs @@ -7,28 +7,39 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Brizco.Repository.Migrations { /// - public partial class init : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.EnsureSchema( + name: "public"); + migrationBuilder.CreateTable( - name: "AspNetRoles", + name: "Complexes", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), - Description = table.Column(type: "text", nullable: false), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) + Name = table.Column(type: "text", nullable: false), + Address = table.Column(type: "text", nullable: false), + SupportPhone = table.Column(type: "text", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); + table.PrimaryKey("PK_Complexes", x => x.Id); }); migrationBuilder.CreateTable( - name: "AspNetUsers", + name: "Users", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -53,32 +64,35 @@ namespace Brizco.Repository.Migrations }, constraints: table => { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); + table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( - name: "Complexes", + name: "Roles", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), - Name = table.Column(type: "text", nullable: false), - Address = table.Column(type: "text", nullable: false), - SupportPhone = table.Column(type: "text", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) + Description = table.Column(type: "text", nullable: false), + ComplexId = table.Column(type: "uuid", nullable: true), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Complexes", x => x.Id); + table.PrimaryKey("PK_Roles", x => x.Id); + table.ForeignKey( + name: "FK_Roles_Complexes_ComplexId", + column: x => x.ComplexId, + principalSchema: "public", + principalTable: "Complexes", + principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Shifts", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -86,6 +100,7 @@ namespace Brizco.Repository.Migrations StartAt = table.Column(type: "interval", nullable: false), EndAt = table.Column(type: "interval", nullable: false), Description = table.Column(type: "text", nullable: false), + ComplexId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), @@ -97,10 +112,18 @@ namespace Brizco.Repository.Migrations constraints: table => { table.PrimaryKey("PK_Shifts", x => x.Id); + table.ForeignKey( + name: "FK_Shifts_Complexes_ComplexId", + column: x => x.ComplexId, + principalSchema: "public", + principalTable: "Complexes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Tasks", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -113,11 +136,13 @@ namespace Brizco.Repository.Migrations IsDisposable = table.Column(type: "boolean", nullable: false), SetFor = table.Column(type: "timestamp without time zone", nullable: false), HasDisposed = table.Column(type: "boolean", nullable: false), + ComplexId = table.Column(type: "uuid", nullable: false), Amount = table.Column(type: "integer", nullable: false), AmountType = table.Column(type: "integer", nullable: false), Discriminator = table.Column(type: "text", nullable: false), Status = table.Column(type: "integer", nullable: true), DoneAt = table.Column(type: "timestamp without time zone", nullable: true), + IsDone = table.Column(type: "boolean", nullable: true), PerformanceDescription = table.Column(type: "text", nullable: true), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), @@ -130,31 +155,18 @@ namespace Brizco.Repository.Migrations constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "uuid", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", + name: "FK_Tasks_Complexes_ComplexId", + column: x => x.ComplexId, + principalSchema: "public", + principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( - name: "AspNetUserClaims", + name: "Claims", + schema: "public", columns: table => new { Id = table.Column(type: "integer", nullable: false) @@ -165,87 +177,24 @@ namespace Brizco.Repository.Migrations }, constraints: table => { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.PrimaryKey("PK_Claims", x => x.Id); table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", + name: "FK_Claims_Users_UserId", column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "text", nullable: false), - ProviderKey = table.Column(type: "text", nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "uuid", nullable: false), - RoleId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "uuid", nullable: false), - LoginProvider = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", + principalSchema: "public", + principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ComplexUsers", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), ComplexId = table.Column(type: "uuid", nullable: false), - RoleId = table.Column(type: "uuid", nullable: false), RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), CreatedBy = table.Column(type: "text", nullable: false), @@ -258,21 +207,118 @@ namespace Brizco.Repository.Migrations { table.PrimaryKey("PK_ComplexUsers", x => x.Id); table.ForeignKey( - name: "FK_ComplexUsers_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", + name: "FK_ComplexUsers_Complexes_ComplexId", + column: x => x.ComplexId, + principalSchema: "public", + principalTable: "Complexes", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_ComplexUsers_Complexes_ComplexId", - column: x => x.ComplexId, - principalTable: "Complexes", + name: "FK_ComplexUsers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Logins", + schema: "public", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_Logins_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Tokens", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_Tokens_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "RoleClaims", + schema: "public", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_RoleClaims_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "UserRoles", + schema: "public", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_UserRoles_Roles_RoleId", + column: x => x.RoleId, + principalSchema: "public", + principalTable: "Roles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_UserRoles_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ShiftDays", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -292,6 +338,7 @@ namespace Brizco.Repository.Migrations table.ForeignKey( name: "FK_ShiftDays_Shifts_ShiftId", column: x => x.ShiftId, + principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); @@ -299,6 +346,7 @@ namespace Brizco.Repository.Migrations migrationBuilder.CreateTable( name: "ShiftPlans", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -319,6 +367,7 @@ namespace Brizco.Repository.Migrations table.ForeignKey( name: "FK_ShiftPlans_Shifts_ShiftId", column: x => x.ShiftId, + principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); @@ -326,6 +375,7 @@ namespace Brizco.Repository.Migrations migrationBuilder.CreateTable( name: "TaskRoles", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -343,14 +393,16 @@ namespace Brizco.Repository.Migrations { table.PrimaryKey("PK_TaskRoles", x => x.Id); table.ForeignKey( - name: "FK_TaskRoles_AspNetRoles_RoleId", + name: "FK_TaskRoles_Roles_RoleId", column: x => x.RoleId, - principalTable: "AspNetRoles", + principalSchema: "public", + principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TaskRoles_Tasks_TaskId", column: x => x.TaskId, + principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); @@ -358,6 +410,7 @@ namespace Brizco.Repository.Migrations migrationBuilder.CreateTable( name: "TaskShifts", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -377,12 +430,14 @@ namespace Brizco.Repository.Migrations table.ForeignKey( name: "FK_TaskShifts_Shifts_ShiftId", column: x => x.ShiftId, + principalSchema: "public", principalTable: "Shifts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TaskShifts_Tasks_TaskId", column: x => x.TaskId, + principalSchema: "public", principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); @@ -390,6 +445,7 @@ namespace Brizco.Repository.Migrations migrationBuilder.CreateTable( name: "TaskUsers", + schema: "public", columns: table => new { Id = table.Column(type: "uuid", nullable: false), @@ -407,157 +463,261 @@ namespace Brizco.Repository.Migrations { table.PrimaryKey("PK_TaskUsers", x => x.Id); table.ForeignKey( - name: "FK_TaskUsers_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", + name: "FK_TaskUsers_Tasks_TaskId", + column: x => x.TaskId, + principalSchema: "public", + principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( - name: "FK_TaskUsers_Tasks_TaskId", - column: x => x.TaskId, - principalTable: "Tasks", + name: "FK_TaskUsers_Users_UserId", + column: x => x.UserId, + principalSchema: "public", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "ShiftPlanUsers", + schema: "public", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ShiftPlanId = table.Column(type: "uuid", nullable: false), + ApplicationUserId = table.Column(type: "uuid", nullable: false), + RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), + CreatedBy = table.Column(type: "text", nullable: false), + IsRemoved = table.Column(type: "boolean", nullable: false), + RemovedBy = table.Column(type: "text", nullable: false), + ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), + ModifiedBy = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShiftPlanUsers", x => x.Id); + table.ForeignKey( + name: "FK_ShiftPlanUsers_ShiftPlans_ShiftPlanId", + column: x => x.ShiftPlanId, + principalSchema: "public", + principalTable: "ShiftPlans", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ShiftPlanUsers_Users_ApplicationUserId", + column: x => x.ApplicationUserId, + principalSchema: "public", + principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", + name: "IX_Claims_UserId", + schema: "public", + table: "Claims", column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - migrationBuilder.CreateIndex( name: "IX_ComplexUsers_ComplexId", + schema: "public", table: "ComplexUsers", column: "ComplexId"); migrationBuilder.CreateIndex( name: "IX_ComplexUsers_UserId", + schema: "public", table: "ComplexUsers", column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_Logins_UserId", + schema: "public", + table: "Logins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleClaims_RoleId", + schema: "public", + table: "RoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_Roles_ComplexId", + schema: "public", + table: "Roles", + column: "ComplexId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + schema: "public", + table: "Roles", + column: "NormalizedName", + unique: true); + migrationBuilder.CreateIndex( name: "IX_ShiftDays_ShiftId", + schema: "public", table: "ShiftDays", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_ShiftPlans_ShiftId", + schema: "public", table: "ShiftPlans", column: "ShiftId"); + migrationBuilder.CreateIndex( + name: "IX_ShiftPlanUsers_ApplicationUserId", + schema: "public", + table: "ShiftPlanUsers", + column: "ApplicationUserId"); + + migrationBuilder.CreateIndex( + name: "IX_ShiftPlanUsers_ShiftPlanId", + schema: "public", + table: "ShiftPlanUsers", + column: "ShiftPlanId"); + + migrationBuilder.CreateIndex( + name: "IX_Shifts_ComplexId", + schema: "public", + table: "Shifts", + column: "ComplexId"); + migrationBuilder.CreateIndex( name: "IX_TaskRoles_RoleId", + schema: "public", table: "TaskRoles", column: "RoleId"); migrationBuilder.CreateIndex( name: "IX_TaskRoles_TaskId", + schema: "public", table: "TaskRoles", column: "TaskId"); + migrationBuilder.CreateIndex( + name: "IX_Tasks_ComplexId", + schema: "public", + table: "Tasks", + column: "ComplexId"); + migrationBuilder.CreateIndex( name: "IX_TaskShifts_ShiftId", + schema: "public", table: "TaskShifts", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_TaskShifts_TaskId", + schema: "public", table: "TaskShifts", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_TaskUsers_TaskId", + schema: "public", table: "TaskUsers", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_TaskUsers_UserId", + schema: "public", table: "TaskUsers", column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserRoles_RoleId", + schema: "public", + table: "UserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + schema: "public", + table: "Users", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + schema: "public", + table: "Users", + column: "NormalizedUserName", + unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "AspNetRoleClaims"); + name: "Claims", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetUserClaims"); + name: "ComplexUsers", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetUserLogins"); + name: "Logins", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetUserRoles"); + name: "RoleClaims", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetUserTokens"); + name: "ShiftDays", + schema: "public"); migrationBuilder.DropTable( - name: "ComplexUsers"); + name: "ShiftPlanUsers", + schema: "public"); migrationBuilder.DropTable( - name: "ShiftDays"); + name: "TaskRoles", + schema: "public"); migrationBuilder.DropTable( - name: "ShiftPlans"); + name: "TaskShifts", + schema: "public"); migrationBuilder.DropTable( - name: "TaskRoles"); + name: "TaskUsers", + schema: "public"); migrationBuilder.DropTable( - name: "TaskShifts"); + name: "Tokens", + schema: "public"); migrationBuilder.DropTable( - name: "TaskUsers"); + name: "UserRoles", + schema: "public"); migrationBuilder.DropTable( - name: "Complexes"); + name: "ShiftPlans", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetRoles"); + name: "Tasks", + schema: "public"); migrationBuilder.DropTable( - name: "Shifts"); + name: "Roles", + schema: "public"); migrationBuilder.DropTable( - name: "AspNetUsers"); + name: "Users", + schema: "public"); migrationBuilder.DropTable( - name: "Tasks"); + name: "Shifts", + schema: "public"); + + migrationBuilder.DropTable( + name: "Complexes", + schema: "public"); } } } diff --git a/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index dd0eb07..c6f4de3 100644 --- a/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -17,6 +17,7 @@ namespace Brizco.Repository.Migrations { #pragma warning disable 612, 618 modelBuilder + .HasDefaultSchema("public") .HasAnnotation("ProductVersion", "7.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 63); @@ -29,6 +30,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("uuid"); b.Property("Address") + .IsRequired() .HasColumnType("text"); b.Property("CreatedAt") @@ -49,6 +51,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.Property("RemovedAt") @@ -59,11 +62,12 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("SupportPhone") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Complexes"); + b.ToTable("Complexes", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => @@ -99,9 +103,6 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); - b.Property("RoleId") - .HasColumnType("uuid"); - b.Property("UserId") .HasColumnType("uuid"); @@ -111,7 +112,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("ComplexUsers"); + b.ToTable("ComplexUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => @@ -120,6 +121,9 @@ namespace Brizco.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -128,6 +132,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("EndAt") @@ -154,11 +159,14 @@ namespace Brizco.Repository.Migrations .HasColumnType("interval"); b.Property("Title") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); - b.ToTable("Shifts"); + b.HasIndex("ComplexId"); + + b.ToTable("Shifts", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => @@ -201,7 +209,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftId"); - b.ToTable("ShiftDays"); + b.ToTable("ShiftDays", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => @@ -247,7 +255,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftId"); - b.ToTable("ShiftPlans"); + b.ToTable("ShiftPlans", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => @@ -292,7 +300,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("ShiftPlanId"); - b.ToTable("ShiftPlanUsers"); + b.ToTable("ShiftPlanUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => @@ -307,6 +315,9 @@ namespace Brizco.Repository.Migrations b.Property("AmountType") .HasColumnType("integer"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("CreatedAt") .HasColumnType("timestamp without time zone"); @@ -315,6 +326,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -357,6 +369,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("Title") + .IsRequired() .HasColumnType("text"); b.Property("Type") @@ -364,7 +377,9 @@ namespace Brizco.Repository.Migrations b.HasKey("Id"); - b.ToTable("Tasks"); + b.HasIndex("ComplexId"); + + b.ToTable("Tasks", "public"); b.HasDiscriminator("Discriminator").HasValue("Task"); @@ -413,7 +428,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("TaskId"); - b.ToTable("TaskRoles"); + b.ToTable("TaskRoles", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => @@ -458,7 +473,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("TaskId"); - b.ToTable("TaskShifts"); + b.ToTable("TaskShifts", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => @@ -503,7 +518,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("TaskUsers"); + b.ToTable("TaskUsers", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => @@ -512,11 +527,15 @@ namespace Brizco.Repository.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ComplexId") + .HasColumnType("uuid"); + b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasColumnType("text"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Name") @@ -529,11 +548,13 @@ namespace Brizco.Repository.Migrations b.HasKey("Id"); + b.HasIndex("ComplexId"); + b.HasIndex("NormalizedName") .IsUnique() .HasDatabaseName("RoleNameIndex"); - b.ToTable("AspNetRoles", (string)null); + b.ToTable("Roles", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b => @@ -560,12 +581,14 @@ namespace Brizco.Repository.Migrations .HasColumnType("boolean"); b.Property("FirstName") + .IsRequired() .HasColumnType("text"); b.Property("Gender") .HasColumnType("integer"); b.Property("LastName") + .IsRequired() .HasColumnType("text"); b.Property("LockoutEnabled") @@ -610,7 +633,7 @@ namespace Brizco.Repository.Migrations .IsUnique() .HasDatabaseName("UserNameIndex"); - b.ToTable("AspNetUsers", (string)null); + b.ToTable("Users", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -634,7 +657,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims", (string)null); + b.ToTable("RoleClaims", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => @@ -658,7 +681,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims", (string)null); + b.ToTable("Claims", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => @@ -679,7 +702,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins", (string)null); + b.ToTable("Logins", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => @@ -694,7 +717,7 @@ namespace Brizco.Repository.Migrations b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles", (string)null); + b.ToTable("UserRoles", "public"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -713,7 +736,7 @@ namespace Brizco.Repository.Migrations b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens", (string)null); + b.ToTable("Tokens", "public"); }); modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => @@ -727,6 +750,7 @@ namespace Brizco.Repository.Migrations .HasColumnType("boolean"); b.Property("PerformanceDescription") + .IsRequired() .HasColumnType("text"); b.Property("Status") @@ -738,7 +762,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => { b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") - .WithMany() + .WithMany("Users") .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -754,6 +778,17 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => { b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") @@ -795,6 +830,17 @@ namespace Brizco.Repository.Migrations b.Navigation("ShiftPlan"); }); + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b => { b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") @@ -852,6 +898,15 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) @@ -903,6 +958,17 @@ namespace Brizco.Repository.Migrations .IsRequired(); }); + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => { b.Navigation("Days"); diff --git a/Berizco.Repository/Models/ApplicationContext.cs b/Berizco.Repository/Models/ApplicationContext.cs index ad62f03..d832776 100644 --- a/Berizco.Repository/Models/ApplicationContext.cs +++ b/Berizco.Repository/Models/ApplicationContext.cs @@ -1,5 +1,7 @@ using Brizco.Domain.Entities.User; using Brizco.Repository.Extensions; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; namespace Brizco.Repository.Models; @@ -26,9 +28,24 @@ public class ApplicationContext : IdentityDbContext().ToTable("Users"); + builder.Entity().ToTable("Roles"); + builder.Entity>().ToTable("RoleClaims"); + builder.Entity>().ToTable("UserRoles"); + builder.Entity>().ToTable("Claims"); + builder.Entity>().ToTable("Logins"); + builder.Entity>().ToTable("Tokens"); + + } } \ No newline at end of file diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index 90904c9..559318b 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -19,6 +19,7 @@ net5.0 10 enable + enable @@ -28,6 +29,7 @@ + diff --git a/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs index 9efa582..b46a811 100644 --- a/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs @@ -39,5 +39,5 @@ public sealed record UpdateActivityCommand(Guid Id, List Roles) : IRequest; -public sealed record DeleteActivityCommand(Guid id) +public sealed record DeleteActivityCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/ComplexCommands.cs b/Brizco.Domain/CommandQueries/Commands/ComplexCommands.cs new file mode 100644 index 0000000..7f77bba --- /dev/null +++ b/Brizco.Domain/CommandQueries/Commands/ComplexCommands.cs @@ -0,0 +1,13 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.CommandQueries.Commands; + +public sealed record CreateComplexCommand(string Name, string Address, string SupportPhone) + : IRequest; + +public sealed record UpdateComplexCommand(Guid Id, string Name, string Address, string SupportPhone) + : IRequest; + + +public sealed record DeleteComplexCommand(Guid Id) + : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs index 0514ef8..75873b6 100644 --- a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs @@ -5,8 +5,8 @@ namespace Brizco.Domain.CommandQueries.Commands; public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description , List DayOfWeeks) : IRequest; -public sealed record UpdateShiftCommand(Guid id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List DayOfWeeks) +public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List DayOfWeeks) : IRequest; -public sealed record DeleteShiftCommand(Guid id) +public sealed record DeleteShiftCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs new file mode 100644 index 0000000..3bf2ad6 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Commands/ShiftPlanCommands.cs @@ -0,0 +1,10 @@ +namespace Brizco.Domain.CommandQueries.Commands; + +public record CreateShiftPlanCommand(DateTime StartAt, DateTime EndAt,Guid ShiftId,List UserIds) + :IRequest; + +public record UpdateShiftPlanCommand(Guid Id,DateTime StartAt, DateTime EndAt, Guid ShiftId, List UserIds) + : IRequest; + +public record DeleteShiftPlanCommand(Guid Id, DateTime StartAt, DateTime EndAt, Guid ShiftId, List UserIds) + : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs b/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs index 5dc0b19..0bc5216 100644 --- a/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs @@ -17,7 +17,7 @@ List Users, List Shifts, List Roles) : IRequest; -public sealed record UpdateTaskCommand(Guid id, +public sealed record UpdateTaskCommand(Guid Id, TaskType Type, string Title, string Description, @@ -34,5 +34,5 @@ public sealed record UpdateTaskCommand(Guid id, List Roles) : IRequest; -public sealed record DeleteTaskCommand(Guid id) +public sealed record DeleteTaskCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs index 01ca640..a1a0d5f 100644 --- a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs @@ -1,7 +1,7 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetActivitiesQuery(int page = 0) : +public sealed record GetActivitiesQuery(int Page = 0) : IRequest>; -public sealed record GetActivityQuery(Guid id) : +public sealed record GetActivityQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/ComplexQueries.cs b/Brizco.Domain/CommandQueries/Queries/ComplexQueries.cs new file mode 100644 index 0000000..1ba24a7 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/ComplexQueries.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public sealed record GetComplexesQuery(int Page = 0) : + IRequest>; + +public sealed record GetComplexQuery(Guid Id) : + IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs b/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs new file mode 100644 index 0000000..56c69f6 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public sealed record GetShiftPlansQuery(int Page = 0) : + IRequest>; + +public sealed record GetShiftPlanQuery(Guid Id) : + IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/TaskQueries.cs b/Brizco.Domain/CommandQueries/Queries/TaskQueries.cs index 34147d7..3d9aef6 100644 --- a/Brizco.Domain/CommandQueries/Queries/TaskQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/TaskQueries.cs @@ -1,7 +1,7 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetTasksQuery(int page = 0) : +public sealed record GetTasksQuery(int Page = 0) : IRequest>; -public sealed record GetTaskQuery(Guid id) : +public sealed record GetTaskQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs new file mode 100644 index 0000000..8a4288a --- /dev/null +++ b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs @@ -0,0 +1,11 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.Dtos.LargDtos; + +public class ShiftPlanLDto : BaseDto +{ + public DateTime StartAt { get; set; } + public DateTime EndAt { get; set; } + public Guid ShiftId { get; set; } + public List Users { get; internal set; } = new(); +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs index 4372fdd..64c6ed3 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs @@ -6,6 +6,4 @@ public class ComplexUserSDto : BaseDto { public Guid UserId { get; set; } public Guid ComplexId { get; set; } - - public Guid RoleId { get; set; } } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs new file mode 100644 index 0000000..6358f58 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -0,0 +1,11 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.Dtos.SmallDtos; + +public class ShiftPlanSDto : BaseDto +{ + public DateTime StartAt { get; set; } + public DateTime EndAt { get; set; } + public Guid ShiftId { get; set; } + public string ShiftTitle { get; internal set; } = string.Empty; +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs new file mode 100644 index 0000000..d77fa54 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs @@ -0,0 +1,9 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.Dtos.SmallDtos; + +public class ShiftPlanUserSDto : BaseDto +{ + public Guid ShiftPlanId { get; set; } + public Guid ApplicationUserId { 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 495eb3a..fcc9791 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 List Days { get; set; } = new(); + public Guid ComplexId { get; set; } } diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs index ba3e0d5..dc7980c 100644 --- a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs @@ -11,6 +11,7 @@ public class TaskSDto : BaseDto public bool IsDisposable { get; set; } public DateTime SetFor { get; set; } public bool HasDisposed { get; set; } + public Guid ComplexId { get; set; } public int Amount { get; set; } diff --git a/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs new file mode 100644 index 0000000..14c9116 --- /dev/null +++ b/Brizco.Domain/Entities/Complex/Aggregate.Complex.cs @@ -0,0 +1,9 @@ +namespace Brizco.Domain.Entities.Complex; + +public partial class Complex +{ + public static Complex Create(string name, string address, string supportPhone) + { + return new Complex(name,address,supportPhone); + } +} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Complex/Complex.cs b/Brizco.Domain/Entities/Complex/Complex.cs index 9f594dd..f947d12 100644 --- a/Brizco.Domain/Entities/Complex/Complex.cs +++ b/Brizco.Domain/Entities/Complex/Complex.cs @@ -1,11 +1,30 @@ -namespace Brizco.Domain.Entities.Complex; +using Brizco.Domain.Entities.User; + +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 class Complex : ApiEntity +public partial class Complex : ApiEntity { + public Complex() + { + + } + + public Complex(string name , string address,string supportPhone) + { + Name = name; + Address = address; + SupportPhone = supportPhone; + } public string Name { get; internal set; } = string.Empty; public string Address { get; internal set; } = string.Empty; public string SupportPhone { get; internal set; } = string.Empty; -} \ No newline at end of file + + public List Roles { get; set; } = new(); + public List Tasks { get; set; } = new(); + public List Shifts { get; set; } = new(); + public List Users { get; set; } = new(); +} + diff --git a/Brizco.Domain/Entities/Complex/ComplexUser.cs b/Brizco.Domain/Entities/Complex/ComplexUser.cs index 8924036..b8d2355 100644 --- a/Brizco.Domain/Entities/Complex/ComplexUser.cs +++ b/Brizco.Domain/Entities/Complex/ComplexUser.cs @@ -7,7 +7,6 @@ public class ComplexUser : ApiEntity { public Guid UserId { get; internal set; } public Guid ComplexId { get; internal set; } - public Guid RoleId { get; internal set; } public ApplicationUser? User { get; internal set; } public Complex? Complex { get; internal set; } diff --git a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs index 0201fee..d3e311e 100644 --- a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs +++ b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs @@ -3,9 +3,9 @@ namespace Brizco.Domain.Entities.Shift; public partial class Shift { - public static Shift Create(string title, string description, TimeSpan startAt, TimeSpan endAt) + public static Shift Create(string title, string description, TimeSpan startAt, TimeSpan endAt,Guid complexId) { - return new Shift(title, description, startAt, endAt); + return new Shift(title, description, startAt, endAt,complexId); } public ShiftDay SetDay(DayOfWeek dayOfWeek) @@ -28,7 +28,7 @@ public partial class ShiftPlan public ShiftPlanUser AddUser(Guid userId) { var planUser = new ShiftPlanUser(Id , userId); - ShiftPlanUsers.Add(planUser); + Users.Add(planUser); return planUser; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/Shift.cs b/Brizco.Domain/Entities/Shift/Shift.cs index 2a0e379..12a25c0 100644 --- a/Brizco.Domain/Entities/Shift/Shift.cs +++ b/Brizco.Domain/Entities/Shift/Shift.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using Mapster; - -namespace Brizco.Domain.Entities.Shift; +namespace Brizco.Domain.Entities.Shift; [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] @@ -10,12 +6,13 @@ public partial class Shift : ApiEntity { public Shift() { } - internal Shift(string title, string description, TimeSpan startAt, TimeSpan endAt) + internal Shift(string title, string description, TimeSpan startAt, TimeSpan endAt,Guid complexId) { Title = title; Description = description; StartAt = startAt; EndAt = endAt; + ComplexId = complexId; } public string Title { get; internal set; } = string.Empty; @@ -23,6 +20,9 @@ public partial class Shift : ApiEntity public TimeSpan EndAt { get; internal set; } public string Description { get; internal set; } = string.Empty; + public Guid ComplexId { get; set; } + public Complex.Complex? Complex { get; set; } + public List Days { get; internal set; } = new(); public List Plans { get; internal set; } = new(); diff --git a/Brizco.Domain/Entities/Shift/ShiftPlan.cs b/Brizco.Domain/Entities/Shift/ShiftPlan.cs index 6371abc..59ef8b8 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlan.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlan.cs @@ -1,5 +1,8 @@ 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 ShiftPlan : ApiEntity { public ShiftPlan() @@ -12,12 +15,11 @@ public partial class ShiftPlan : ApiEntity StartAt = startAt; EndAt = endAt; } - public DateTime StartAt { get; private set; } - public DateTime EndAt { get; private set; } + public DateTime StartAt { get; internal set; } + public DateTime EndAt { get; internal set; } - public Guid ShiftId { get; private set; } - public virtual Shift? Shift { get; private set; } + public Guid ShiftId { get; internal set; } + public virtual Shift? Shift { get; internal set; } - public IReadOnlyCollection? Users => ShiftPlanUsers; - internal List? ShiftPlanUsers { get; private set; } = new(); + public List Users { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs b/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs index c382611..0ef78b0 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlanUser.cs @@ -2,6 +2,8 @@ namespace Brizco.Domain.Entities.Shift; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public class ShiftPlanUser : ApiEntity { public ShiftPlanUser() @@ -14,9 +16,9 @@ public class ShiftPlanUser : ApiEntity ShiftPlanId = shiftPlanId; ApplicationUserId = applicationUserId; } - public Guid ShiftPlanId { get; private set; } - public ShiftPlan? ShiftPlan { get; private set; } + public Guid ShiftPlanId { get; internal set; } + public ShiftPlan? ShiftPlan { get; internal set; } - public Guid ApplicationUserId { get; private set; } - public ApplicationUser? ApplicationUser { get; private set; } + public Guid ApplicationUserId { get; internal set; } + public ApplicationUser? ApplicationUser { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/Activity.cs b/Brizco.Domain/Entities/Task/Activity.cs index c489636..fe7c87a 100644 --- a/Brizco.Domain/Entities/Task/Activity.cs +++ b/Brizco.Domain/Entities/Task/Activity.cs @@ -24,7 +24,8 @@ public partial class Activity : Task int amount, PurchaseAmountType amountType, string title, - string description) : base(type, + string description, + Guid complexId) : base(type, isRelatedToShift, isRelatedToRole, isRelatedToPerson, @@ -34,7 +35,8 @@ public partial class Activity : Task amount, amountType, title, - description) + description, + complexId) { Status = status; DoneAt = doneAt; diff --git a/Brizco.Domain/Entities/Task/Aggregate.Task.cs b/Brizco.Domain/Entities/Task/Aggregate.Task.cs index fe3418a..7aa6db3 100644 --- a/Brizco.Domain/Entities/Task/Aggregate.Task.cs +++ b/Brizco.Domain/Entities/Task/Aggregate.Task.cs @@ -15,7 +15,8 @@ public partial class Task DateTime setFor, bool hasDisposed, int amount, - PurchaseAmountType amountType) + PurchaseAmountType amountType, + Guid complexId) { return new Task(type, isRelatedToShift, @@ -27,7 +28,8 @@ public partial class Task amount, amountType, title, - description); + description, + complexId); } public void AddShift(params Guid[] shiftIds) @@ -93,7 +95,8 @@ public partial class Activity DateTime setFor, bool hasDisposed, int amount, - PurchaseAmountType amountType) + PurchaseAmountType amountType, + Guid complexId) { return new Activity( status, @@ -109,7 +112,8 @@ public partial class Activity amount, amountType, title, - description); + description, + complexId); } public void DoneActivity() diff --git a/Brizco.Domain/Entities/Task/Task.cs b/Brizco.Domain/Entities/Task/Task.cs index fb616ab..9a9b8a3 100644 --- a/Brizco.Domain/Entities/Task/Task.cs +++ b/Brizco.Domain/Entities/Task/Task.cs @@ -21,7 +21,8 @@ public partial class Task : ApiEntity int amount, PurchaseAmountType amountType, string title, - string description) + string description, + Guid complexId) { Type = type; IsRelatedToShift = isRelatedToShift; @@ -34,6 +35,7 @@ public partial class Task : ApiEntity AmountType = amountType; Title = title; Description = description; + ComplexId = complexId; } public TaskType Type { get; internal set; } @@ -46,6 +48,9 @@ public partial class Task : ApiEntity public DateTime SetFor { get; internal set; } public bool HasDisposed { get; internal set; } + public Guid ComplexId { get; set; } + public Complex.Complex? Complex { get; set; } + public int Amount { get; internal set; } public PurchaseAmountType AmountType { get; internal set; } diff --git a/Brizco.Domain/Entities/User/ApplicationRole.cs b/Brizco.Domain/Entities/User/ApplicationRole.cs index 3badf10..8f6deb6 100644 --- a/Brizco.Domain/Entities/User/ApplicationRole.cs +++ b/Brizco.Domain/Entities/User/ApplicationRole.cs @@ -3,4 +3,7 @@ public class ApplicationRole : IdentityRole { public string Description { get; set; } = string.Empty; + + public Guid? ComplexId { get; set; } + public Complex.Complex? Complex { get; set; } } \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs index 2b5e639..a36a293 100644 --- a/Brizco.Domain/Mappers/ActivityMapper.g.cs +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -16,6 +16,17 @@ namespace Brizco.Domain.Mappers DoneAt = p1.DoneAt, IsDone = p1.IsDone, PerformanceDescription = p1.PerformanceDescription, + Type = p1.Type, + Title = p1.Title, + Description = p1.Description, + IsRelatedToShift = p1.IsRelatedToShift, + IsRelatedToRole = p1.IsRelatedToRole, + IsRelatedToPerson = p1.IsRelatedToPerson, + IsDisposable = p1.IsDisposable, + SetFor = p1.SetFor, + HasDisposed = p1.HasDisposed, + Amount = p1.Amount, + AmountType = p1.AmountType, Id = p1.Id }; } @@ -31,6 +42,17 @@ namespace Brizco.Domain.Mappers result.DoneAt = p2.DoneAt; result.IsDone = p2.IsDone; result.PerformanceDescription = p2.PerformanceDescription; + result.Type = p2.Type; + result.Title = p2.Title; + result.Description = p2.Description; + result.IsRelatedToShift = p2.IsRelatedToShift; + result.IsRelatedToRole = p2.IsRelatedToRole; + result.IsRelatedToPerson = p2.IsRelatedToPerson; + result.IsDisposable = p2.IsDisposable; + result.SetFor = p2.SetFor; + result.HasDisposed = p2.HasDisposed; + result.Amount = p2.Amount; + result.AmountType = p2.AmountType; result.Id = p2.Id; return result; @@ -41,6 +63,17 @@ namespace Brizco.Domain.Mappers DoneAt = p4.DoneAt, IsDone = p4.IsDone, PerformanceDescription = p4.PerformanceDescription, + Type = p4.Type, + Title = p4.Title, + Description = p4.Description, + IsRelatedToShift = p4.IsRelatedToShift, + IsRelatedToRole = p4.IsRelatedToRole, + IsRelatedToPerson = p4.IsRelatedToPerson, + IsDisposable = p4.IsDisposable, + SetFor = p4.SetFor, + HasDisposed = p4.HasDisposed, + Amount = p4.Amount, + AmountType = p4.AmountType, Id = p4.Id }; public static ActivitySDto AdaptToSDto(this Activity p5) @@ -119,6 +152,17 @@ namespace Brizco.Domain.Mappers DoneAt = p9.DoneAt, IsDone = p9.IsDone, PerformanceDescription = p9.PerformanceDescription, + Type = p9.Type, + Title = p9.Title, + Description = p9.Description, + IsRelatedToShift = p9.IsRelatedToShift, + IsRelatedToRole = p9.IsRelatedToRole, + IsRelatedToPerson = p9.IsRelatedToPerson, + IsDisposable = p9.IsDisposable, + SetFor = p9.SetFor, + HasDisposed = p9.HasDisposed, + Amount = p9.Amount, + AmountType = p9.AmountType, Id = p9.Id }; } @@ -134,6 +178,17 @@ namespace Brizco.Domain.Mappers result.DoneAt = p10.DoneAt; result.IsDone = p10.IsDone; result.PerformanceDescription = p10.PerformanceDescription; + result.Type = p10.Type; + result.Title = p10.Title; + result.Description = p10.Description; + result.IsRelatedToShift = p10.IsRelatedToShift; + result.IsRelatedToRole = p10.IsRelatedToRole; + result.IsRelatedToPerson = p10.IsRelatedToPerson; + result.IsDisposable = p10.IsDisposable; + result.SetFor = p10.SetFor; + result.HasDisposed = p10.HasDisposed; + result.Amount = p10.Amount; + result.AmountType = p10.AmountType; result.Id = p10.Id; return result; @@ -144,6 +199,17 @@ namespace Brizco.Domain.Mappers DoneAt = p12.DoneAt, IsDone = p12.IsDone, PerformanceDescription = p12.PerformanceDescription, + Type = p12.Type, + Title = p12.Title, + Description = p12.Description, + IsRelatedToShift = p12.IsRelatedToShift, + IsRelatedToRole = p12.IsRelatedToRole, + IsRelatedToPerson = p12.IsRelatedToPerson, + IsDisposable = p12.IsDisposable, + SetFor = p12.SetFor, + HasDisposed = p12.HasDisposed, + Amount = p12.Amount, + AmountType = p12.AmountType, Id = p12.Id }; public static ActivityLDto AdaptToLDto(this Activity p13) diff --git a/Brizco.Domain/Mappers/ComplexUserMapper.g.cs b/Brizco.Domain/Mappers/ComplexUserMapper.g.cs index a4383cf..75d7544 100644 --- a/Brizco.Domain/Mappers/ComplexUserMapper.g.cs +++ b/Brizco.Domain/Mappers/ComplexUserMapper.g.cs @@ -13,7 +13,6 @@ namespace Brizco.Domain.Mappers { UserId = p1.UserId, ComplexId = p1.ComplexId, - RoleId = p1.RoleId, Id = p1.Id }; } @@ -27,7 +26,6 @@ namespace Brizco.Domain.Mappers result.UserId = p2.UserId; result.ComplexId = p2.ComplexId; - result.RoleId = p2.RoleId; result.Id = p2.Id; return result; @@ -36,7 +34,6 @@ namespace Brizco.Domain.Mappers { UserId = p4.UserId, ComplexId = p4.ComplexId, - RoleId = p4.RoleId, Id = p4.Id }; public static ComplexUserSDto AdaptToSDto(this ComplexUser p5) @@ -45,7 +42,6 @@ namespace Brizco.Domain.Mappers { UserId = p5.UserId, ComplexId = p5.ComplexId, - RoleId = p5.RoleId, Id = p5.Id }; } @@ -59,7 +55,6 @@ namespace Brizco.Domain.Mappers result.UserId = p6.UserId; result.ComplexId = p6.ComplexId; - result.RoleId = p6.RoleId; result.Id = p6.Id; return result; @@ -68,7 +63,6 @@ namespace Brizco.Domain.Mappers { UserId = p8.UserId, ComplexId = p8.ComplexId, - RoleId = p8.RoleId, Id = p8.Id }; } diff --git a/Brizco.Domain/Mappers/ShiftMapper.g.cs b/Brizco.Domain/Mappers/ShiftMapper.g.cs index 5769120..b27f6f6 100644 --- a/Brizco.Domain/Mappers/ShiftMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftMapper.g.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Complex; using Brizco.Domain.Entities.Shift; +using Mapster.Models; namespace Brizco.Domain.Mappers { @@ -17,6 +19,8 @@ namespace Brizco.Domain.Mappers StartAt = p1.StartAt, EndAt = p1.EndAt, Description = p1.Description, + ComplexId = p1.ComplexId, + Complex = new Complex() {Id = p1.ComplexId}, Days = funcMain1(p1.Days), Id = p1.Id }; @@ -33,57 +37,64 @@ namespace Brizco.Domain.Mappers result.StartAt = p3.StartAt; result.EndAt = p3.EndAt; result.Description = p3.Description; - result.Days = funcMain2(p3.Days, result.Days); + 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 => p7 => new Shift() + public static Expression> ProjectToShift => p9 => new Shift() { - Title = p7.Title, - StartAt = p7.StartAt, - EndAt = p7.EndAt, - Description = p7.Description, - Days = p7.Days.Select(p8 => new ShiftDay() {}).ToList(), - Id = p7.Id + 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 p9) + public static ShiftSDto AdaptToSDto(this Shift p11) { - return p9 == null ? null : new ShiftSDto() + return p11 == null ? null : new ShiftSDto() { - Title = p9.Title, - Description = p9.Description, - StartAt = p9.StartAt, - EndAt = p9.EndAt, - Days = funcMain3(p9.Days != null ? p9.Days.Select(funcMain4).ToList() : new List()), - Id = p9.Id + Title = p11.Title, + Description = p11.Description, + StartAt = p11.StartAt, + EndAt = p11.EndAt, + Days = funcMain4(p11.Days != null ? p11.Days.Select(funcMain5).ToList() : new List()), + ComplexId = p11.ComplexId, + Id = p11.Id }; } - public static ShiftSDto AdaptTo(this Shift p11, ShiftSDto p12) + public static ShiftSDto AdaptTo(this Shift p13, ShiftSDto p14) { - if (p11 == null) + if (p13 == null) { return null; } - ShiftSDto result = p12 ?? new ShiftSDto(); + ShiftSDto result = p14 ?? new ShiftSDto(); - result.Title = p11.Title; - result.Description = p11.Description; - result.StartAt = p11.StartAt; - result.EndAt = p11.EndAt; - result.Days = funcMain5(p11.Days != null ? p11.Days.Select(funcMain4).ToList() : new List(), result.Days); - result.Id = p11.Id; + result.Title = p13.Title; + result.Description = p13.Description; + result.StartAt = p13.StartAt; + result.EndAt = p13.EndAt; + result.Days = funcMain6(p13.Days != null ? p13.Days.Select(funcMain5).ToList() : new List(), result.Days); + result.ComplexId = p13.ComplexId; + result.Id = p13.Id; return result; } - public static Expression> ProjectToSDto => p15 => new ShiftSDto() + public static Expression> ProjectToSDto => p17 => new ShiftSDto() { - Title = p15.Title, - Description = p15.Description, - StartAt = p15.StartAt, - EndAt = p15.EndAt, - Days = p15.Days != null ? p15.Days.Select(d => d.DayOfWeek).ToList() : new List(), - Id = p15.Id + Title = p17.Title, + Description = p17.Description, + StartAt = p17.StartAt, + EndAt = p17.EndAt, + Days = p17.Days != null ? p17.Days.Select(d => d.DayOfWeek).ToList() : new List(), + ComplexId = p17.ComplexId, + Id = p17.Id }; private static List funcMain1(List p2) @@ -107,20 +118,29 @@ namespace Brizco.Domain.Mappers } - private static List funcMain2(List p5, List p6) + private static Complex funcMain2(Never p5, Complex p6, ShiftSDto p3) { - if (p5 == null) + Complex result = p6 ?? new Complex(); + + result.Id = p3.ComplexId; + return result; + + } + + private static List funcMain3(List p7, List p8) + { + if (p7 == null) { return null; } - List result = new List(p5.Count); + List result = new List(p7.Count); int i = 0; - int len = p5.Count; + int len = p7.Count; while (i < len) { - DayOfWeek item = p5[i]; + DayOfWeek item = p7[i]; result.Add(new ShiftDay() {}); i++; } @@ -128,20 +148,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain3(List p10) + private static List funcMain4(List p12) { - if (p10 == null) + if (p12 == null) { return null; } - List result = new List(p10.Count); + List result = new List(p12.Count); int i = 0; - int len = p10.Count; + int len = p12.Count; while (i < len) { - DayOfWeek item = p10[i]; + DayOfWeek item = p12[i]; result.Add(item); i++; } @@ -149,25 +169,25 @@ namespace Brizco.Domain.Mappers } - private static DayOfWeek funcMain4(ShiftDay d) + private static DayOfWeek funcMain5(ShiftDay d) { return d.DayOfWeek; } - private static List funcMain5(List p13, List p14) + private static List funcMain6(List p15, List p16) { - if (p13 == null) + if (p15 == null) { return null; } - List result = new List(p13.Count); + List result = new List(p15.Count); int i = 0; - int len = p13.Count; + int len = p15.Count; while (i < len) { - DayOfWeek item = p13[i]; + DayOfWeek item = p15[i]; result.Add(item); i++; } diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs new file mode 100644 index 0000000..be7a2cd --- /dev/null +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -0,0 +1,265 @@ +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.Shift; + +namespace Brizco.Domain.Mappers +{ + public static partial class ShiftPlanMapper + { + public static ShiftPlan AdaptToShiftPlan(this ShiftPlanSDto p1) + { + return p1 == null ? null : new ShiftPlan() + { + StartAt = p1.StartAt, + EndAt = p1.EndAt, + ShiftId = p1.ShiftId, + Id = p1.Id + }; + } + public static ShiftPlan AdaptTo(this ShiftPlanSDto p2, ShiftPlan p3) + { + if (p2 == null) + { + return null; + } + ShiftPlan result = p3 ?? new ShiftPlan(); + + result.StartAt = p2.StartAt; + result.EndAt = p2.EndAt; + result.ShiftId = p2.ShiftId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToShiftPlan => p4 => new ShiftPlan() + { + StartAt = p4.StartAt, + EndAt = p4.EndAt, + ShiftId = p4.ShiftId, + Id = p4.Id + }; + public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p5) + { + return p5 == null ? null : new ShiftPlanSDto() + { + StartAt = p5.StartAt, + EndAt = p5.EndAt, + ShiftId = p5.ShiftId, + ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, + Id = p5.Id + }; + } + public static ShiftPlanSDto AdaptTo(this ShiftPlan p6, ShiftPlanSDto p7) + { + if (p6 == null) + { + return null; + } + ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); + + result.StartAt = p6.StartAt; + result.EndAt = p6.EndAt; + result.ShiftId = p6.ShiftId; + result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new ShiftPlanSDto() + { + StartAt = p8.StartAt, + EndAt = p8.EndAt, + ShiftId = p8.ShiftId, + ShiftTitle = p8.Shift.Title, + Id = p8.Id + }; + public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p9) + { + return p9 == null ? null : new ShiftPlan() + { + StartAt = p9.StartAt, + EndAt = p9.EndAt, + ShiftId = p9.ShiftId, + Users = funcMain1(p9.Users), + Id = p9.Id + }; + } + public static ShiftPlan AdaptTo(this ShiftPlanLDto p11, ShiftPlan p12) + { + if (p11 == null) + { + return null; + } + ShiftPlan result = p12 ?? new ShiftPlan(); + + result.StartAt = p11.StartAt; + result.EndAt = p11.EndAt; + result.ShiftId = p11.ShiftId; + result.Users = funcMain2(p11.Users, result.Users); + result.Id = p11.Id; + return result; + + } + public static Expression> ProjectLDtoToShiftPlan => p15 => new ShiftPlan() + { + StartAt = p15.StartAt, + EndAt = p15.EndAt, + ShiftId = p15.ShiftId, + Users = p15.Users.Select(p16 => new ShiftPlanUser() + { + ShiftPlanId = p16.ShiftPlanId, + ApplicationUserId = p16.ApplicationUserId, + Id = p16.Id + }).ToList(), + Id = p15.Id + }; + public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p17) + { + return p17 == null ? null : new ShiftPlanLDto() + { + StartAt = p17.StartAt, + EndAt = p17.EndAt, + ShiftId = p17.ShiftId, + Users = funcMain3(p17.Users), + Id = p17.Id + }; + } + public static ShiftPlanLDto AdaptTo(this ShiftPlan p19, ShiftPlanLDto p20) + { + if (p19 == null) + { + return null; + } + ShiftPlanLDto result = p20 ?? new ShiftPlanLDto(); + + result.StartAt = p19.StartAt; + result.EndAt = p19.EndAt; + result.ShiftId = p19.ShiftId; + result.Users = funcMain4(p19.Users, result.Users); + result.Id = p19.Id; + return result; + + } + public static Expression> ProjectToLDto => p23 => new ShiftPlanLDto() + { + StartAt = p23.StartAt, + EndAt = p23.EndAt, + ShiftId = p23.ShiftId, + Users = p23.Users.Select(p24 => new ShiftPlanUserSDto() + { + ShiftPlanId = p24.ShiftPlanId, + ApplicationUserId = p24.ApplicationUserId, + 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) + { + ShiftPlanUserSDto item = p10[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ApplicationUserId = item.ApplicationUserId, + 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) + { + ShiftPlanUserSDto item = p13[i]; + result.Add(item == null ? null : new ShiftPlanUser() + { + ShiftPlanId = item.ShiftPlanId, + ApplicationUserId = item.ApplicationUserId, + 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) + { + ShiftPlanUser item = p18[i]; + result.Add(item == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = item.ShiftPlanId, + ApplicationUserId = item.ApplicationUserId, + 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) + { + ShiftPlanUser item = p21[i]; + result.Add(item == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = item.ShiftPlanId, + ApplicationUserId = item.ApplicationUserId, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs new file mode 100644 index 0000000..1b45ad6 --- /dev/null +++ b/Brizco.Domain/Mappers/ShiftPlanUserMapper.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 ShiftPlanUserMapper + { + public static ShiftPlanUser AdaptToShiftPlanUser(this ShiftPlanUserSDto p1) + { + return p1 == null ? null : new ShiftPlanUser() + { + ShiftPlanId = p1.ShiftPlanId, + ApplicationUserId = p1.ApplicationUserId, + Id = p1.Id + }; + } + public static ShiftPlanUser AdaptTo(this ShiftPlanUserSDto p2, ShiftPlanUser p3) + { + if (p2 == null) + { + return null; + } + ShiftPlanUser result = p3 ?? new ShiftPlanUser(); + + result.ShiftPlanId = p2.ShiftPlanId; + result.ApplicationUserId = p2.ApplicationUserId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToShiftPlanUser => p4 => new ShiftPlanUser() + { + ShiftPlanId = p4.ShiftPlanId, + ApplicationUserId = p4.ApplicationUserId, + Id = p4.Id + }; + public static ShiftPlanUserSDto AdaptToSDto(this ShiftPlanUser p5) + { + return p5 == null ? null : new ShiftPlanUserSDto() + { + ShiftPlanId = p5.ShiftPlanId, + ApplicationUserId = p5.ApplicationUserId, + Id = p5.Id + }; + } + public static ShiftPlanUserSDto AdaptTo(this ShiftPlanUser p6, ShiftPlanUserSDto p7) + { + if (p6 == null) + { + return null; + } + ShiftPlanUserSDto result = p7 ?? new ShiftPlanUserSDto(); + + result.ShiftPlanId = p6.ShiftPlanId; + result.ApplicationUserId = p6.ApplicationUserId; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new ShiftPlanUserSDto() + { + ShiftPlanId = p8.ShiftPlanId, + ApplicationUserId = p8.ApplicationUserId, + Id = p8.Id + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs index 2cd6217..993e866 100644 --- a/Brizco.Domain/Mappers/TaskMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -24,6 +24,7 @@ namespace Brizco.Domain.Mappers IsDisposable = p1.IsDisposable, SetFor = p1.SetFor, HasDisposed = p1.HasDisposed, + ComplexId = p1.ComplexId, Amount = p1.Amount, AmountType = p1.AmountType, Id = p1.Id @@ -46,6 +47,7 @@ namespace Brizco.Domain.Mappers result.IsDisposable = p2.IsDisposable; result.SetFor = p2.SetFor; result.HasDisposed = p2.HasDisposed; + result.ComplexId = p2.ComplexId; result.Amount = p2.Amount; result.AmountType = p2.AmountType; result.Id = p2.Id; @@ -63,6 +65,7 @@ namespace Brizco.Domain.Mappers IsDisposable = p4.IsDisposable, SetFor = p4.SetFor, HasDisposed = p4.HasDisposed, + ComplexId = p4.ComplexId, Amount = p4.Amount, AmountType = p4.AmountType, Id = p4.Id @@ -80,6 +83,7 @@ namespace Brizco.Domain.Mappers IsDisposable = p5.IsDisposable, SetFor = p5.SetFor, HasDisposed = p5.HasDisposed, + ComplexId = p5.ComplexId, Amount = p5.Amount, AmountType = p5.AmountType, Id = p5.Id @@ -102,6 +106,7 @@ namespace Brizco.Domain.Mappers result.IsDisposable = p6.IsDisposable; result.SetFor = p6.SetFor; result.HasDisposed = p6.HasDisposed; + result.ComplexId = p6.ComplexId; result.Amount = p6.Amount; result.AmountType = p6.AmountType; result.Id = p6.Id; @@ -119,6 +124,7 @@ namespace Brizco.Domain.Mappers IsDisposable = p8.IsDisposable, SetFor = p8.SetFor, HasDisposed = p8.HasDisposed, + ComplexId = p8.ComplexId, Amount = p8.Amount, AmountType = p8.AmountType, Id = p8.Id