From 24c4a23079a0c4b8ade358e4a5a1eef9f701efa9 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Mon, 18 Sep 2023 09:45:02 +0330 Subject: [PATCH] feat : add cqrs and endpoints add models , dtos , cqrs and endpoint --- .config/dotnet-tools.json | 12 + Berizco.Api/Brizco.Api.csproj | 3 +- Berizco.Api/Controllers/ShiftController.cs | 12 +- Berizco.Api/Controllers/TaskController.cs | 51 + Berizco.Repository/Brizco.Repository.csproj | 5 +- .../Activity/CreateActivityCommandHandler.cs | 57 ++ .../Activity/DeleteActivityCommandHandler.cs | 24 + .../Activity/GetActivitiesQueryHandler.cs | 21 + .../Activity/GetActivityQueryHandler.cs | 25 + .../Activity/UpdateActivityCommandHandler.cs | 43 + .../Shift/CreateShiftCommandHandler.cs | 4 +- .../Shift/DeleteShiftCommandHandler.cs | 24 + .../Handlers/Shift/GetShiftQueryHandler.cs | 22 + .../Handlers/Shift/GetShiftsQueryHandler.cs | 5 +- .../Shift/UpdateShiftCommandHandler.cs | 27 + .../Handlers/Task/CreateTaskCommandHandler.cs | 52 + .../Handlers/Task/DeleteTaskCommandHandler.cs | 24 + .../Handlers/Task/GetTaskQueryHandler.cs | 25 + .../Handlers/Task/GetTasksQueryHandler.cs | 21 + .../Handlers/Task/UpdateTaskCommandHandler.cs | 38 + .../20230917141849_editTask.Designer.cs | 932 ++++++++++++++++++ .../Migrations/20230917141849_editTask.cs | 208 ++++ .../ApplicationContextModelSnapshot.cs | 343 ++++--- Brizco.Common/Brizco.Common.csproj | 3 +- Brizco.Common/Models/Entity/IApiEntity.cs | 14 +- Brizco.Common/Models/Mapper/BaseDto.cs | 2 +- Brizco.Common/Models/Mapper/IBaseDto.cs | 2 +- Brizco.Domain/Brizco.Domain.csproj | 29 +- .../Commands/ActivityCommands.cs | 43 + .../CommandQueries/Commands/ShiftCommands.cs | 7 +- .../CommandQueries/Commands/TaskCommands.cs | 38 + .../CommandQueries/Queries/ActivityQueries.cs | 7 + .../CommandQueries/Queries/ShiftQueries.cs | 7 +- .../CommandQueries/Queries/TaskQueries.cs | 7 + Brizco.Domain/Dtos/LargDtos/ActivityLDto.cs | 24 + Brizco.Domain/Dtos/LargDtos/ComplexLDto.cs | 11 + Brizco.Domain/Dtos/LargDtos/TaskLDto.cs | 27 + Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs | 24 + Brizco.Domain/Dtos/SmallDtos/ComplexSDto.cs | 11 + .../Dtos/SmallDtos/ComplexUserSDto.cs | 11 + Brizco.Domain/Dtos/SmallDtos/TaskRoleSDto.cs | 9 + Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs | 18 + Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs | 7 + Brizco.Domain/Dtos/SmallDtos/TaskUserSDto.cs | 7 + Brizco.Domain/Entities/Complex/Complex.cs | 9 +- Brizco.Domain/Entities/Complex/ComplexUser.cs | 13 +- .../Entities/Shift/Aggregate.Shift.cs | 8 +- Brizco.Domain/Entities/Shift/Shift.cs | 22 +- Brizco.Domain/Entities/Task/Activity.cs | 49 +- Brizco.Domain/Entities/Task/Aggregate.Task.cs | 120 +++ Brizco.Domain/Entities/Task/SubTask.cs | 5 - Brizco.Domain/Entities/Task/Task.cs | 66 +- Brizco.Domain/Entities/Task/TaskRole.cs | 20 +- Brizco.Domain/Entities/Task/TaskShift.cs | 20 +- Brizco.Domain/Entities/Task/TaskUser.cs | 20 +- Brizco.Domain/Mappers/ActivityMapper.g.cs | 218 ++++ Brizco.Domain/Mappers/ComplexMapper.g.cs | 140 +++ Brizco.Domain/Mappers/ComplexUserMapper.g.cs | 75 ++ Brizco.Domain/Mappers/ShiftMapper.g.cs | 178 ++++ Brizco.Domain/Mappers/TaskMapper.g.cs | 587 +++++++++++ Brizco.Domain/Mappers/TaskRoleMapper.g.cs | 69 ++ Brizco.Domain/Mappers/TaskShiftMapper.g.cs | 63 ++ Brizco.Domain/Mappers/TaskUserMapper.g.cs | 63 ++ Brizco.Domain/MapsterRegister.cs | 15 + global.json | 5 + 65 files changed, 3761 insertions(+), 290 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 Berizco.Api/Controllers/TaskController.cs create mode 100644 Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs create mode 100644 Berizco.Repository/Handlers/Task/GetTaskQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Task/GetTasksQueryHandler.cs create mode 100644 Berizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs create mode 100644 Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs create mode 100644 Berizco.Repository/Migrations/20230917141849_editTask.cs create mode 100644 Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs create mode 100644 Brizco.Domain/CommandQueries/Commands/TaskCommands.cs create mode 100644 Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs create mode 100644 Brizco.Domain/CommandQueries/Queries/TaskQueries.cs create mode 100644 Brizco.Domain/Dtos/LargDtos/ActivityLDto.cs create mode 100644 Brizco.Domain/Dtos/LargDtos/ComplexLDto.cs create mode 100644 Brizco.Domain/Dtos/LargDtos/TaskLDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/ComplexSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/TaskRoleSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs create mode 100644 Brizco.Domain/Dtos/SmallDtos/TaskUserSDto.cs create mode 100644 Brizco.Domain/Entities/Task/Aggregate.Task.cs delete mode 100644 Brizco.Domain/Entities/Task/SubTask.cs create mode 100644 Brizco.Domain/Mappers/ActivityMapper.g.cs create mode 100644 Brizco.Domain/Mappers/ComplexMapper.g.cs create mode 100644 Brizco.Domain/Mappers/ComplexUserMapper.g.cs create mode 100644 Brizco.Domain/Mappers/ShiftMapper.g.cs create mode 100644 Brizco.Domain/Mappers/TaskMapper.g.cs create mode 100644 Brizco.Domain/Mappers/TaskRoleMapper.g.cs create mode 100644 Brizco.Domain/Mappers/TaskShiftMapper.g.cs create mode 100644 Brizco.Domain/Mappers/TaskUserMapper.g.cs create mode 100644 Brizco.Domain/MapsterRegister.cs create mode 100644 global.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..0c61f2d --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "mapster.tool": { + "version": "8.3.0", + "commands": [ + "dotnet-mapster" + ] + } + } +} \ No newline at end of file diff --git a/Berizco.Api/Brizco.Api.csproj b/Berizco.Api/Brizco.Api.csproj index 876110f..8604108 100644 --- a/Berizco.Api/Brizco.Api.csproj +++ b/Berizco.Api/Brizco.Api.csproj @@ -57,7 +57,8 @@ - + + diff --git a/Berizco.Api/Controllers/ShiftController.cs b/Berizco.Api/Controllers/ShiftController.cs index 74289d2..5bd86ac 100644 --- a/Berizco.Api/Controllers/ShiftController.cs +++ b/Berizco.Api/Controllers/ShiftController.cs @@ -1,6 +1,4 @@ -using MediatR; - -namespace Brizco.Api.Controllers; +namespace Brizco.Api.Controllers; public class ShiftController : ICarterModule { public ShiftController() @@ -11,11 +9,11 @@ public class ShiftController : ICarterModule var group = app.NewVersionedApi("Shift").MapGroup($"api/shift"); group.MapGet("", GetAllAsync) - .WithDisplayName("GetAll") + .WithDisplayName("GetAllShift") .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) - .WithName("GetOne") + .WithDisplayName("GetOneShift") .HasApiVersion(1.0); group.MapPost("", Post) @@ -30,11 +28,11 @@ public class ShiftController : ICarterModule // GET:Get All Entity public async Task GetAllAsync(ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(Activator.CreateInstance(), cancellationToken)); + => TypedResults.Ok(await sender.Send(new GetShiftsQuery(), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(Activator.CreateInstance())); + => TypedResults.Ok(await sender.Send(new GetShiftQuery(id))); // POST:Create Entity public async Task Post([FromBody] CreateShiftCommand ent, ISender mediator, CancellationToken cancellationToken) diff --git a/Berizco.Api/Controllers/TaskController.cs b/Berizco.Api/Controllers/TaskController.cs new file mode 100644 index 0000000..16e65ee --- /dev/null +++ b/Berizco.Api/Controllers/TaskController.cs @@ -0,0 +1,51 @@ +namespace Brizco.Api.Controllers; + +public class TaskController : ICarterModule +{ + public TaskController() + { + } + public virtual void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Task").MapGroup($"api/task"); + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAllTask") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetOneTask") + .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(ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetTasksQuery(), cancellationToken)); + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetTaskQuery(id))); + + // POST:Create Entity + public async Task Post([FromBody] CreateTaskCommand ent, ISender mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(ent, cancellationToken)); + + // PUT:Update Entity + public async Task Put([FromBody] UpdateTaskCommand 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 DeleteTaskCommand(id), cancellationToken)); + +} + diff --git a/Berizco.Repository/Brizco.Repository.csproj b/Berizco.Repository/Brizco.Repository.csproj index 5f35afe..65f38ea 100644 --- a/Berizco.Repository/Brizco.Repository.csproj +++ b/Berizco.Repository/Brizco.Repository.csproj @@ -27,7 +27,6 @@ - @@ -41,9 +40,10 @@ + + - @@ -66,5 +66,6 @@ + diff --git a/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs b/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs new file mode 100644 index 0000000..f94fdc9 --- /dev/null +++ b/Berizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs @@ -0,0 +1,57 @@ +using Brizco.Domain.Dtos.LargDtos; + +namespace Brizco.Repository.Handlers.Activity; + +public class CreateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(CreateActivityCommand request, CancellationToken cancellationToken) + { + var task = 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); + + if (task.IsRelatedToPerson) + { + if (request.Users.Count == 0) + throw new AppException("اگر فعالیت برای یک فرد انتخاب شده باشد باید لیست افراد را ارسال نمایید"); + task.AddUser(request.Users.ToArray()); + } + + if (task.IsRelatedToRole) + { + if (request.Roles.Count == 0) + throw new AppException("اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید"); + task.AddShift(request.Roles.ToArray()); + } + + if (task.IsRelatedToShift) + { + if (request.Shifts.Count == 0) + throw new AppException("اگر فعالیت برای یک شیفت انتخاب شده باشد باید لیست شیفت ها را ارسال نمایید"); + task.AddRole(request.Shifts.ToArray()); + } + + _repositoryWrapper.SetRepository().Add(task); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return task.AdaptToLDto(); + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs b/Berizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs new file mode 100644 index 0000000..3800b33 --- /dev/null +++ b/Berizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs @@ -0,0 +1,24 @@ +namespace Brizco.Repository.Handlers.Activity; + +public class DeleteActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteActivityCommand 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/Activity/GetActivitiesQueryHandler.cs b/Berizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs new file mode 100644 index 0000000..284384f --- /dev/null +++ b/Berizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs @@ -0,0 +1,21 @@ +namespace Brizco.Repository.Handlers.Activity; + +public class GetActivitiesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetActivitiesQuery request, CancellationToken cancellationToken) + { + var tasks = await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Skip(request.page * 15).Take(15) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return tasks; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs b/Berizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs new file mode 100644 index 0000000..9293b98 --- /dev/null +++ b/Berizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs @@ -0,0 +1,25 @@ +using Brizco.Domain.Dtos.LargDtos; + +namespace Brizco.Repository.Handlers.Activity; + +public class GetActivityQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetActivityQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(GetActivityQuery request, CancellationToken cancellationToken) + { + var task = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == request.id) + .Select(ActivityMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (task == null) + throw new AppException("Task not found", ApiResultStatusCode.NotFound); + return task; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs b/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs new file mode 100644 index 0000000..519021a --- /dev/null +++ b/Berizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs @@ -0,0 +1,43 @@ +namespace Brizco.Repository.Handlers.Activity; + +public class UpdateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + 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); + + 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); + + 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 c1ca70b..ca3a47a 100644 --- a/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs +++ b/Berizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs @@ -1,6 +1,6 @@ namespace Brizco.Repository.Handlers.Shift; -public class CreateShiftCommandHandler : IRequestHandler +public class CreateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; public CreateShiftCommandHandler(IRepositoryWrapper repositoryWrapper) @@ -15,7 +15,7 @@ public class CreateShiftCommandHandler : IRequestHandlershift.SetDay(d)); + request.DayOfWeeks.ForEach(d => shift.SetDay(d)); _repositoryWrapper.SetRepository().Add(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Berizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs b/Berizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs new file mode 100644 index 0000000..e4622cd --- /dev/null +++ b/Berizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs @@ -0,0 +1,24 @@ +namespace Brizco.Repository.Handlers.Shift; + +public class DeleteShiftCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteShiftCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteShiftCommand request, CancellationToken cancellationToken) + { + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.Id == request.id, cancellationToken); + if (shift == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + _repositoryWrapper.SetRepository() + .Delete(shift); + + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs b/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs new file mode 100644 index 0000000..6f44db2 --- /dev/null +++ b/Berizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs @@ -0,0 +1,22 @@ +namespace Brizco.Repository.Handlers.Shift; + +public class GetShiftQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetShiftQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(GetShiftQuery request, CancellationToken cancellationToken) + { + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == request.id) + .Select(ShiftMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (shift == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + return shift; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs index 5c0c2ce..5e10aba 100644 --- a/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Berizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs @@ -1,6 +1,6 @@ namespace Brizco.Repository.Handlers.Shift; -public class GetShiftsQueryHandler : IRequestHandler> +public class GetShiftsQueryHandler : IRequestHandler> { private readonly IRepositoryWrapper _repositoryWrapper; @@ -11,8 +11,9 @@ public class GetShiftsQueryHandler : IRequestHandler> Handle(GetShiftsQuery request, CancellationToken cancellationToken) { var shifts = await _repositoryWrapper.SetRepository().TableNoTracking - .Skip(request.page * 15).Take(15) .OrderByDescending(s => s.CreatedAt) + .Skip(request.page * 15).Take(15) + .Select(ShiftMapper.ProjectToSDto) .ToListAsync(cancellationToken); return shifts; diff --git a/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs new file mode 100644 index 0000000..13138aa --- /dev/null +++ b/Berizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs @@ -0,0 +1,27 @@ +namespace Brizco.Repository.Handlers.Shift; + +public class UpdateShiftCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(UpdateShiftCommand request, CancellationToken cancellationToken) + { + var shift = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.id); + if (shift == null) + throw new AppException("Shift not found", ApiResultStatusCode.NotFound); + + var newShift = Domain.Entities.Shift.Shift.Create(request.Title, request.Description, request.StartAt, request.EndAt); + newShift.Id = request.id; + _repositoryWrapper.SetRepository() + .Update(newShift); + 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 new file mode 100644 index 0000000..cdc36c8 --- /dev/null +++ b/Berizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs @@ -0,0 +1,52 @@ +using Brizco.Domain.Dtos.LargDtos; + +namespace Brizco.Repository.Handlers.Task; + +public class CreateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + public CreateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(CreateTaskCommand request, CancellationToken cancellationToken) + { + var task = Domain.Entities.Task.Task + .Create(request.Title, + request.Description, + request.Type, + request.IsRelatedToShift, + request.IsRelatedToRole, + request.IsRelatedToPerson, + request.IsDisposable, + request.SetFor, + request.HasDisposed, + request.Amount, + request.AmountType); + + if (task.IsRelatedToPerson) + { + if (request.Users.Count == 0) + throw new AppException("اگر فعالیت برای یک فرد انتخاب شده باشد باید لیست افراد را ارسال نمایید"); + task.AddUser(request.Users.ToArray()); + } + + if (task.IsRelatedToRole) + { + if (request.Roles.Count == 0) + throw new AppException("اگر فعالیت برای یک گروه نقش انتخاب شده باشد باید لیست نقش ها را ارسال نمایید"); + task.AddShift(request.Roles.ToArray()); + } + + if (task.IsRelatedToShift) + { + if (request.Shifts.Count == 0) + throw new AppException("اگر فعالیت برای یک شیفت انتخاب شده باشد باید لیست شیفت ها را ارسال نمایید"); + task.AddRole(request.Shifts.ToArray()); + } + + _repositoryWrapper.SetRepository().Add(task); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + return task.AdaptToLDto(); + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs b/Berizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs new file mode 100644 index 0000000..fcaaa3e --- /dev/null +++ b/Berizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs @@ -0,0 +1,24 @@ +namespace Brizco.Repository.Handlers.Task; + +public class DeleteActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public DeleteActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task Handle(DeleteTaskCommand 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/Task/GetTaskQueryHandler.cs b/Berizco.Repository/Handlers/Task/GetTaskQueryHandler.cs new file mode 100644 index 0000000..cd7e3af --- /dev/null +++ b/Berizco.Repository/Handlers/Task/GetTaskQueryHandler.cs @@ -0,0 +1,25 @@ +using Brizco.Domain.Dtos.LargDtos; + +namespace Brizco.Repository.Handlers.Task; + +public class GetActivityQueryHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetActivityQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(GetTaskQuery request, CancellationToken cancellationToken) + { + var task = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.Id == request.id) + .Select(TaskMapper.ProjectToLDto) + .FirstOrDefaultAsync(cancellationToken); + if (task == null) + throw new AppException("Task not found", ApiResultStatusCode.NotFound); + return task; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Task/GetTasksQueryHandler.cs b/Berizco.Repository/Handlers/Task/GetTasksQueryHandler.cs new file mode 100644 index 0000000..9c59add --- /dev/null +++ b/Berizco.Repository/Handlers/Task/GetTasksQueryHandler.cs @@ -0,0 +1,21 @@ +namespace Brizco.Repository.Handlers.Task; + +public class GetActivitiesQueryHandler : IRequestHandler> +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + public async Task> Handle(GetTasksQuery request, CancellationToken cancellationToken) + { + var tasks = await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Skip(request.page * 15).Take(15) + .Select(TaskMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return tasks; + } +} \ No newline at end of file diff --git a/Berizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs b/Berizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs new file mode 100644 index 0000000..457161b --- /dev/null +++ b/Berizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs @@ -0,0 +1,38 @@ +namespace Brizco.Repository.Handlers.Task; + +public class UpdateActivityCommandHandler : IRequestHandler +{ + private readonly IRepositoryWrapper _repositoryWrapper; + + public UpdateActivityCommandHandler(IRepositoryWrapper repositoryWrapper) + { + _repositoryWrapper = repositoryWrapper; + } + + public async Task Handle(UpdateTaskCommand 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); + + var newTask = Domain.Entities.Task.Task.Create(request.Title, + request.Description, + request.Type, + request.IsRelatedToShift, + request.IsRelatedToRole, + request.IsRelatedToPerson, + request.IsDisposable, + request.SetFor, + request.HasDisposed, + request.Amount, + request.AmountType); + 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/Migrations/20230917141849_editTask.Designer.cs b/Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs new file mode 100644 index 0000000..e12d1c5 --- /dev/null +++ b/Berizco.Repository/Migrations/20230917141849_editTask.Designer.cs @@ -0,0 +1,932 @@ +// +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("20230917141849_editTask")] + partial class editTask + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .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") + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupportPhone") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Complexes"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.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.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") + .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") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Shifts"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.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.Shift.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.Shift.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.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") + .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") + .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.Task.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.Task.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.Task.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("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .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.User.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") + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .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("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.Task.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("ShiftPlan"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Roles") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Users") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.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.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Berizco.Repository/Migrations/20230917141849_editTask.cs b/Berizco.Repository/Migrations/20230917141849_editTask.cs new file mode 100644 index 0000000..be93d01 --- /dev/null +++ b/Berizco.Repository/Migrations/20230917141849_editTask.cs @@ -0,0 +1,208 @@ +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/ApplicationContextModelSnapshot.cs b/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index 808fab9..dd0eb07 100644 --- a/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Berizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -17,129 +17,18 @@ namespace Brizco.Repository.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.10") + .HasAnnotation("ProductVersion", "7.0.11") .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 => + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); b.Property("Address") - .IsRequired() .HasColumnType("text"); b.Property("CreatedAt") @@ -160,7 +49,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Name") - .IsRequired() .HasColumnType("text"); b.Property("RemovedAt") @@ -171,7 +59,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("SupportPhone") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -179,7 +66,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Complexes"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ComplexUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -227,7 +114,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ComplexUsers"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -241,7 +128,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") - .IsRequired() .HasColumnType("text"); b.Property("EndAt") @@ -268,7 +154,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("interval"); b.Property("Title") - .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -276,7 +161,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Shifts"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -319,7 +204,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ShiftDays"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -365,7 +250,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ShiftPlans"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlanUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -410,7 +295,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ShiftPlanUsers"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -430,7 +315,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("text"); b.Property("Description") - .IsRequired() .HasColumnType("text"); b.Property("Discriminator") @@ -473,7 +357,6 @@ namespace Brizco.Repository.Migrations .HasColumnType("timestamp without time zone"); b.Property("Title") - .IsRequired() .HasColumnType("text"); b.Property("Type") @@ -488,7 +371,7 @@ namespace Brizco.Repository.Migrations b.UseTphMappingStrategy(); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -533,7 +416,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskRoles"); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -578,7 +461,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskShifts"); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -623,6 +506,113 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskUsers"); }); + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .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.User.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") + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .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("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") @@ -726,15 +716,17 @@ namespace Brizco.Repository.Migrations b.ToTable("AspNetUserTokens", (string)null); }); - modelBuilder.Entity("Brizco.Domain.Entities.Activity", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => { - b.HasBaseType("Brizco.Domain.Entities.Task"); + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); b.Property("DoneAt") .HasColumnType("timestamp without time zone"); + b.Property("IsDone") + .HasColumnType("boolean"); + b.Property("PerformanceDescription") - .IsRequired() .HasColumnType("text"); b.Property("Status") @@ -743,22 +735,15 @@ namespace Brizco.Repository.Migrations b.HasDiscriminator().HasValue("Activity"); }); - modelBuilder.Entity("Brizco.Domain.Entities.SubTask", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", 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") + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") .WithMany() .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) @@ -769,10 +754,10 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftDay", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -780,10 +765,10 @@ namespace Brizco.Repository.Migrations b.Navigation("Shift"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlan", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") - .WithMany() + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -791,16 +776,16 @@ namespace Brizco.Repository.Migrations b.Navigation("Shift"); }); - modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlanUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "ApplicationUser") + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") .WithMany() .HasForeignKey("ApplicationUserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.ShiftPlan", "ShiftPlan") - .WithMany() + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") .HasForeignKey("ShiftPlanId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -810,16 +795,16 @@ namespace Brizco.Repository.Migrations b.Navigation("ShiftPlan"); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRole", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", "Role") + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskRoles") + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Roles") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -829,16 +814,16 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskShift", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => { - b.HasOne("Brizco.Domain.Entities.Shift", "Shift") + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") .WithMany() .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskShifts") + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -848,15 +833,15 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.TaskUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => { - b.HasOne("Brizco.Domain.Entities.Task", "Task") - .WithMany("TaskUsers") + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Users") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.ApplicationUser", "User") + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) @@ -869,7 +854,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict) @@ -878,7 +863,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) @@ -887,7 +872,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) @@ -896,13 +881,13 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationRole", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) @@ -911,20 +896,32 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("Brizco.Domain.Entities.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => { - b.Navigation("TaskRoles"); + b.Navigation("Days"); - b.Navigation("TaskShifts"); + b.Navigation("Plans"); + }); - b.Navigation("TaskUsers"); + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Users"); }); #pragma warning restore 612, 618 } diff --git a/Brizco.Common/Brizco.Common.csproj b/Brizco.Common/Brizco.Common.csproj index 356b02e..1041f6a 100644 --- a/Brizco.Common/Brizco.Common.csproj +++ b/Brizco.Common/Brizco.Common.csproj @@ -1,7 +1,8 @@  - net7.0 + net5.0 + 10 enable enable diff --git a/Brizco.Common/Models/Entity/IApiEntity.cs b/Brizco.Common/Models/Entity/IApiEntity.cs index 2f6ccf6..dbbd793 100644 --- a/Brizco.Common/Models/Entity/IApiEntity.cs +++ b/Brizco.Common/Models/Entity/IApiEntity.cs @@ -2,12 +2,12 @@ { public interface IApiEntity { - string CreatedBy { get; set; } - string ModifiedBy { get; set; } - string RemovedBy { get; set; } - bool IsRemoved { get; set; } - DateTime CreatedAt { get; set; } - DateTime RemovedAt { get; set; } - DateTime ModifiedAt { get; set; } + string CreatedBy { get; } + string ModifiedBy { get; } + string RemovedBy { get; } + bool IsRemoved { get; } + DateTime CreatedAt { get; } + DateTime RemovedAt { get; } + DateTime ModifiedAt { get; } } } \ No newline at end of file diff --git a/Brizco.Common/Models/Mapper/BaseDto.cs b/Brizco.Common/Models/Mapper/BaseDto.cs index f155583..1b43a8a 100644 --- a/Brizco.Common/Models/Mapper/BaseDto.cs +++ b/Brizco.Common/Models/Mapper/BaseDto.cs @@ -12,7 +12,7 @@ namespace Brizco.Common.Models.Mapper /// Type of Entity Class public abstract class BaseDto : INotifyPropertyChanged, IBaseDto where TEntity : class where TDto : class { - public int Id { get; set; } + public Guid Id { get; set; } public static Expression> ProjectToDto { get => GetProjectToDto(); diff --git a/Brizco.Common/Models/Mapper/IBaseDto.cs b/Brizco.Common/Models/Mapper/IBaseDto.cs index 083106b..9fe413c 100644 --- a/Brizco.Common/Models/Mapper/IBaseDto.cs +++ b/Brizco.Common/Models/Mapper/IBaseDto.cs @@ -4,7 +4,7 @@ namespace Brizco.Common.Models.Mapper { public interface IBaseDto { - int Id { get; set; } + Guid Id { get; set; } bool Compare(object obj); static Expression> ProjectToDto; } diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index e03983c..90904c9 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -1,10 +1,25 @@  - + + + + + net5.0 + 10 + enable + @@ -12,11 +27,17 @@ - + - + + + + + + + @@ -27,8 +48,10 @@ + + diff --git a/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs new file mode 100644 index 0000000..9efa582 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Commands/ActivityCommands.cs @@ -0,0 +1,43 @@ +namespace Brizco.Domain.CommandQueries.Commands; + +public sealed record CreateActivityCommand( + ActivityStatus Status, + DateTime DoneAt, + string PerformanceDescription, + TaskType Type, + string Title, + string Description, + bool IsRelatedToShift, + bool IsRelatedToRole, + bool IsRelatedToPerson, + bool IsDisposable, + DateTime SetFor, + bool HasDisposed, + int Amount, + PurchaseAmountType AmountType, + List Users, + List Shifts, + List Roles) : IRequest; + +public sealed record UpdateActivityCommand(Guid Id, + ActivityStatus Status, + DateTime DoneAt, + string PerformanceDescription, + TaskType Type, + string Title, + string Description, + bool IsRelatedToShift, + bool IsRelatedToRole, + bool IsRelatedToPerson, + bool IsDisposable, + DateTime SetFor, + bool HasDisposed, + int Amount, + PurchaseAmountType AmountType, + List Users, + List Shifts, + List Roles) : IRequest; + + +public sealed record DeleteActivityCommand(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 75fbe4c..0514ef8 100644 --- a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs @@ -5,7 +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(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) + : IRequest; -public sealed record DeleteShiftCommand(Guid id) : IRequest; \ No newline at end of file +public sealed record DeleteShiftCommand(Guid id) + : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs b/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs new file mode 100644 index 0000000..5dc0b19 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Commands/TaskCommands.cs @@ -0,0 +1,38 @@ +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.CommandQueries.Commands; + +public sealed record CreateTaskCommand(TaskType Type, +string Title, +string Description, +bool IsRelatedToShift, +bool IsRelatedToRole, +bool IsRelatedToPerson, +bool IsDisposable, +DateTime SetFor, +bool HasDisposed, +int Amount, +PurchaseAmountType AmountType, +List Users, +List Shifts, +List Roles) : IRequest; + +public sealed record UpdateTaskCommand(Guid id, + TaskType Type, + string Title, + string Description, + bool IsRelatedToShift, + bool IsRelatedToRole, + bool IsRelatedToPerson, + bool IsDisposable, + DateTime SetFor, + bool HasDisposed, + int Amount, + PurchaseAmountType AmountType, + List Users, + List Shifts, + List Roles) : IRequest; + + +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 new file mode 100644 index 0000000..01ca640 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public sealed record GetActivitiesQuery(int page = 0) : + IRequest>; + +public sealed record GetActivityQuery(Guid id) : + IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs b/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs index dcd01b3..4c4abde 100644 --- a/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs @@ -1,4 +1,7 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetShiftsQuery(int page = 0) : IRequest>; -public sealed record GetShiftQuery(Guid id) : IRequest; \ No newline at end of file +public sealed record GetShiftsQuery(int page = 0) : + IRequest>; + +public sealed record GetShiftQuery(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 new file mode 100644 index 0000000..34147d7 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/TaskQueries.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public sealed record GetTasksQuery(int page = 0) : + IRequest>; + +public sealed record GetTaskQuery(Guid id) : + IRequest; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/ActivityLDto.cs b/Brizco.Domain/Dtos/LargDtos/ActivityLDto.cs new file mode 100644 index 0000000..079d6f3 --- /dev/null +++ b/Brizco.Domain/Dtos/LargDtos/ActivityLDto.cs @@ -0,0 +1,24 @@ +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Dtos.LargDtos; + +public class ActivityLDto : BaseDto +{ + public TaskType Type { get; set; } + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool IsRelatedToShift { get; set; } + public bool IsRelatedToRole { get; set; } + public bool IsRelatedToPerson { get; set; } + public bool IsDisposable { get; set; } + public DateTime SetFor { get; set; } + public bool HasDisposed { get; set; } + public ActivityStatus Status { get; set; } + public DateTime DoneAt { get; set; } + public bool IsDone { get; set; } + public string PerformanceDescription { get; set; } = string.Empty; + + + public int Amount { get; set; } + public PurchaseAmountType AmountType { get; set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/ComplexLDto.cs b/Brizco.Domain/Dtos/LargDtos/ComplexLDto.cs new file mode 100644 index 0000000..4ca46d3 --- /dev/null +++ b/Brizco.Domain/Dtos/LargDtos/ComplexLDto.cs @@ -0,0 +1,11 @@ +using Brizco.Domain.Entities.Complex; + +namespace Brizco.Domain.Dtos.LargDtos; + +public class ComplexLDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Address { get; set; } = string.Empty; + public string SupportPhone { get; set; } = string.Empty; + public List Users { get; set; } = new(); +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs b/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs new file mode 100644 index 0000000..aa42e0f --- /dev/null +++ b/Brizco.Domain/Dtos/LargDtos/TaskLDto.cs @@ -0,0 +1,27 @@ +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Dtos.LargDtos; + +public class TaskLDto : BaseDto +{ + public TaskType Type { get; set; } + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool IsRelatedToShift { get; set; } + public bool IsRelatedToRole { get; set; } + public bool IsRelatedToPerson { get; set; } + public bool IsDisposable { get; set; } + public DateTime SetFor { get; set; } + public bool HasDisposed { get; set; } + + + public int Amount { get; set; } + public PurchaseAmountType AmountType { get; set; } + + + public List Users { get; set; } = new(); + + public List Shifts { get; set; } = new(); + + public List Roles { get; set; } = new(); +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs new file mode 100644 index 0000000..7ff5438 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs @@ -0,0 +1,24 @@ +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Dtos.SmallDtos; + +public class ActivitySDto : BaseDto +{ + public TaskType Type { get; internal set; } + public string Title { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public bool IsRelatedToShift { get; internal set; } + public bool IsRelatedToRole { get; internal set; } + public bool IsRelatedToPerson { get; internal set; } + public bool IsDisposable { get; internal set; } + public DateTime SetFor { get; internal set; } + public bool HasDisposed { get; internal set; } + public ActivityStatus Status { get; internal set; } + public DateTime DoneAt { get; internal set; } + public bool IsDone { get; set; } + public string PerformanceDescription { get; internal set; } = string.Empty; + + + public int Amount { get; internal set; } + public PurchaseAmountType AmountType { get; internal set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ComplexSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ComplexSDto.cs new file mode 100644 index 0000000..3b19098 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/ComplexSDto.cs @@ -0,0 +1,11 @@ +using Brizco.Domain.Entities.Complex; + +namespace Brizco.Domain.Dtos.SmallDtos; + +public class ComplexSDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Address { get; set; } = string.Empty; + public string SupportPhone { get; set; } = string.Empty; + +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs new file mode 100644 index 0000000..4372fdd --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/ComplexUserSDto.cs @@ -0,0 +1,11 @@ +using Brizco.Domain.Entities.Complex; + +namespace Brizco.Domain.Dtos.SmallDtos; + +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/TaskRoleSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskRoleSDto.cs new file mode 100644 index 0000000..5013ade --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/TaskRoleSDto.cs @@ -0,0 +1,9 @@ +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Dtos.SmallDtos; + +public class TaskRoleSDto : BaseDto +{ + public Guid RoleId { get; set; } + public Guid TaskId { get; set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs new file mode 100644 index 0000000..ba3e0d5 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/TaskSDto.cs @@ -0,0 +1,18 @@ +namespace Brizco.Domain.Dtos.SmallDtos; + +public class TaskSDto : BaseDto +{ + public TaskType Type { get; set; } + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public bool IsRelatedToShift { get; set; } + public bool IsRelatedToRole { get; set; } + public bool IsRelatedToPerson { get; set; } + public bool IsDisposable { get; set; } + public DateTime SetFor { get; set; } + public bool HasDisposed { get; set; } + + + public int Amount { get; set; } + public PurchaseAmountType AmountType { get; set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs new file mode 100644 index 0000000..3bf410a --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/TaskShiftSDto.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.Dtos.SmallDtos; + +public class TaskShiftSDto +{ + public Guid ShiftId { get; set; } + public Guid TaskId { get; set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/TaskUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/TaskUserSDto.cs new file mode 100644 index 0000000..d528f99 --- /dev/null +++ b/Brizco.Domain/Dtos/SmallDtos/TaskUserSDto.cs @@ -0,0 +1,7 @@ +namespace Brizco.Domain.Dtos.SmallDtos; + +public class TaskUserSDto +{ + public Guid UserId { get; set; } + public Guid TaskId { get; set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Complex/Complex.cs b/Brizco.Domain/Entities/Complex/Complex.cs index 944191d..9f594dd 100644 --- a/Brizco.Domain/Entities/Complex/Complex.cs +++ b/Brizco.Domain/Entities/Complex/Complex.cs @@ -1,8 +1,11 @@ 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 string Name { get; private set; } = string.Empty; - public string Address { get; private set; } = string.Empty; - public string SupportPhone { get; private set; } = string.Empty; + 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 diff --git a/Brizco.Domain/Entities/Complex/ComplexUser.cs b/Brizco.Domain/Entities/Complex/ComplexUser.cs index 45b41e7..8924036 100644 --- a/Brizco.Domain/Entities/Complex/ComplexUser.cs +++ b/Brizco.Domain/Entities/Complex/ComplexUser.cs @@ -1,13 +1,14 @@ using Brizco.Domain.Entities.User; namespace Brizco.Domain.Entities.Complex; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public class ComplexUser : ApiEntity { - public Guid UserId { get; private set; } - public Guid ComplexId { get; private set; } + public Guid UserId { get; internal set; } + public Guid ComplexId { get; internal set; } + public Guid RoleId { get; internal set; } - public Guid RoleId { get; private set; } - - public ApplicationUser? User { get; private set; } - public Complex? Complex { get; private set; } + public ApplicationUser? User { get; internal set; } + public Complex? Complex { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs index d1ab879..0201fee 100644 --- a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs +++ b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs @@ -1,4 +1,6 @@ -namespace Brizco.Domain.Entities.Shift; +using System; + +namespace Brizco.Domain.Entities.Shift; public partial class Shift { public static Shift Create(string title, string description, TimeSpan startAt, TimeSpan endAt) @@ -9,14 +11,14 @@ public partial class Shift public ShiftDay SetDay(DayOfWeek dayOfWeek) { var shiftDay = new ShiftDay(dayOfWeek , Id); - ShiftDays.Add(shiftDay); + Days.Add(shiftDay); return shiftDay; } public ShiftPlan AddPlan(DateTime startAt, DateTime endAt) { var plan = new ShiftPlan(startAt, endAt , Id); - ShiftPlans.Add(plan); + Plans.Add(plan); return plan; } } diff --git a/Brizco.Domain/Entities/Shift/Shift.cs b/Brizco.Domain/Entities/Shift/Shift.cs index ee32aaf..2a0e379 100644 --- a/Brizco.Domain/Entities/Shift/Shift.cs +++ b/Brizco.Domain/Entities/Shift/Shift.cs @@ -1,5 +1,11 @@ -namespace Brizco.Domain.Entities.Shift; +using System; +using System.Collections.Generic; +using Mapster; +namespace Brizco.Domain.Entities.Shift; + +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public partial class Shift : ApiEntity { public Shift() { } @@ -12,14 +18,12 @@ public partial class Shift : ApiEntity EndAt = endAt; } - public string Title { get; set; } = string.Empty; - public TimeSpan StartAt { get; set; } - public TimeSpan EndAt { get; set; } - public string Description { get; set; } = string.Empty; + public string Title { get; internal set; } = string.Empty; + public TimeSpan StartAt { get; internal set; } + public TimeSpan EndAt { get; internal set; } + public string Description { get; internal set; } = string.Empty; - public IReadOnlyCollection? Days => ShiftDays; - internal List? ShiftDays { get; private set; } = new(); + public List Days { get; internal set; } = new(); - public IReadOnlyCollection? Plans => ShiftPlans; - internal List? ShiftPlans { get; private set; } = new(); + public List Plans { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/Activity.cs b/Brizco.Domain/Entities/Task/Activity.cs index 8112875..c489636 100644 --- a/Brizco.Domain/Entities/Task/Activity.cs +++ b/Brizco.Domain/Entities/Task/Activity.cs @@ -1,8 +1,47 @@ -namespace Brizco.Domain.Entities.Task; +using System; -public class Activity : Task +namespace Brizco.Domain.Entities.Task; + +public partial class Activity : Task { - public ActivityStatus Status { get; private set; } - public DateTime DoneAt { get; private set; } - public string PerformanceDescription { get; private set; } = string.Empty; + + public Activity() + { + + } + + public Activity( + ActivityStatus status, + DateTime doneAt, + string performanceDescription, + TaskType type, + bool isRelatedToShift, + bool isRelatedToRole, + bool isRelatedToPerson, + bool isDisposable, + DateTime setFor, + bool hasDisposed, + int amount, + PurchaseAmountType amountType, + string title, + string description) : base(type, + isRelatedToShift, + isRelatedToRole, + isRelatedToPerson, + isDisposable, + setFor, + hasDisposed, + amount, + amountType, + title, + description) + { + Status = status; + DoneAt = doneAt; + PerformanceDescription = performanceDescription; + } + public ActivityStatus Status { get; internal set; } + public DateTime DoneAt { get; internal set; } + public bool IsDone { get; internal set; } + public string PerformanceDescription { get; internal set; } = string.Empty; } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/Aggregate.Task.cs b/Brizco.Domain/Entities/Task/Aggregate.Task.cs new file mode 100644 index 0000000..fe3418a --- /dev/null +++ b/Brizco.Domain/Entities/Task/Aggregate.Task.cs @@ -0,0 +1,120 @@ +namespace Brizco.Domain.Entities.Task; + + +public partial class Task +{ + + public static Task Create( + string title, + string description, + TaskType type, + bool isRelatedToShift, + bool isRelatedToRole, + bool isRelatedToPerson, + bool isDisposable, + DateTime setFor, + bool hasDisposed, + int amount, + PurchaseAmountType amountType) + { + return new Task(type, + isRelatedToShift, + isRelatedToRole, + isRelatedToPerson, + isDisposable, + setFor, + hasDisposed, + amount, + amountType, + title, + description); + } + + public void AddShift(params Guid[] shiftIds) + { + foreach (var shiftId in shiftIds) + { + var plan = new TaskShift(Id, shiftId); + Shifts.Add(plan); + } + } + public TaskShift AddShift(Guid shiftId) + { + var plan = new TaskShift(Id, shiftId); + Shifts.Add(plan); + return plan; + } + + public void AddUser(params Guid[] userIds) + { + foreach (var userId in userIds) + { + var plan = new TaskUser(Id, userId); + Users.Add(plan); + } + } + public TaskUser AddUser(Guid userId) + { + var plan = new TaskUser(Id, userId); + Users.Add(plan); + return plan; + } + + public TaskRole AddRole(Guid roleId) + { + var plan = new TaskRole(Id, roleId); + Roles.Add(plan); + return plan; + } + public void AddRole(params Guid[] roleIds) + { + foreach (var roleId in roleIds) + { + var plan = new TaskRole(Id, roleId); + Roles.Add(plan); + } + } +} + +public partial class Activity +{ + + public static Activity Create( + ActivityStatus status, + DateTime doneAt, + string performanceDescription, + string title, + string description, + TaskType type, + bool isRelatedToShift, + bool isRelatedToRole, + bool isRelatedToPerson, + bool isDisposable, + DateTime setFor, + bool hasDisposed, + int amount, + PurchaseAmountType amountType) + { + return new Activity( + status, + doneAt, + performanceDescription, + type, + isRelatedToShift, + isRelatedToRole, + isRelatedToPerson, + isDisposable, + setFor, + hasDisposed, + amount, + amountType, + title, + description); + } + + public void DoneActivity() + { + DoneAt = DateTime.UtcNow; + IsDone = true; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/SubTask.cs b/Brizco.Domain/Entities/Task/SubTask.cs deleted file mode 100644 index 76b9d1d..0000000 --- a/Brizco.Domain/Entities/Task/SubTask.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Brizco.Domain.Entities.Task; - -public class SubTask : Task -{ -} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/Task.cs b/Brizco.Domain/Entities/Task/Task.cs index d1efc52..fb616ab 100644 --- a/Brizco.Domain/Entities/Task/Task.cs +++ b/Brizco.Domain/Entities/Task/Task.cs @@ -1,36 +1,15 @@ -namespace Brizco.Domain.Entities.Task; -public class Task : ApiEntity +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.Entities.Task; +[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 Task : ApiEntity { public Task() { } - - public static Task Create( - string title, - string description, - TaskType type, - bool isRelatedToShift, - bool isRelatedToRole, - bool isRelatedToPerson, - bool isDisposable, - DateTime setFor, - bool hasDisposed, - int amount, - PurchaseAmountType amountType) - { - return new Task(type, - isRelatedToShift, - isRelatedToRole, - isRelatedToPerson, - isDisposable, - setFor, - hasDisposed, - amount, - amountType, - title, - description); - } internal Task( TaskType type, bool isRelatedToShift, @@ -57,21 +36,24 @@ public class Task : ApiEntity Description = description; } - public TaskType Type { get; private set; } - public string Title { get; private set; } = string.Empty; - public string Description { get; private set; } = string.Empty; - public bool IsRelatedToShift { get; private set; } - public bool IsRelatedToRole { get; private set; } - public bool IsRelatedToPerson { get; private set; } - public bool IsDisposable { get; private set; } - public DateTime SetFor { get; private set; } - public bool HasDisposed { get; private set; } + public TaskType Type { get; internal set; } + public string Title { get; internal set; } = string.Empty; + public string Description { get; internal set; } = string.Empty; + public bool IsRelatedToShift { get; internal set; } + public bool IsRelatedToRole { get; internal set; } + public bool IsRelatedToPerson { get; internal set; } + public bool IsDisposable { get; internal set; } + public DateTime SetFor { get; internal set; } + public bool HasDisposed { get; internal set; } - public int Amount { get; private set; } - public PurchaseAmountType AmountType { get; private set; } + public int Amount { get; internal set; } + public PurchaseAmountType AmountType { get; internal set; } - public virtual ICollection? TaskUsers { get; set; } - public virtual ICollection? TaskShifts { get; set; } - public virtual ICollection? TaskRoles { get; set; } + + public List Users { get; internal set; } = new(); + + public List Shifts { get; internal set; } = new(); + + public List Roles { get; internal set; } = new(); } diff --git a/Brizco.Domain/Entities/Task/TaskRole.cs b/Brizco.Domain/Entities/Task/TaskRole.cs index 9cac118..50a10cd 100644 --- a/Brizco.Domain/Entities/Task/TaskRole.cs +++ b/Brizco.Domain/Entities/Task/TaskRole.cs @@ -2,11 +2,23 @@ namespace Brizco.Domain.Entities.Task; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public class TaskRole : ApiEntity { - public Guid RoleId { get; private set; } - public virtual ApplicationRole? Role { get; private set; } - public Guid TaskId { get; private set; } - public virtual Task? Task { get; private set; } + public TaskRole() + { + + } + + public TaskRole(Guid roleId, Guid taskId) + { + RoleId = roleId; + TaskId = taskId; + } + public Guid RoleId { get; internal set; } + public virtual ApplicationRole? Role { get; internal set; } + public Guid TaskId { get; internal set; } + public virtual Task? Task { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/TaskShift.cs b/Brizco.Domain/Entities/Task/TaskShift.cs index 79ad7ad..7350def 100644 --- a/Brizco.Domain/Entities/Task/TaskShift.cs +++ b/Brizco.Domain/Entities/Task/TaskShift.cs @@ -1,10 +1,22 @@ namespace Brizco.Domain.Entities.Task; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public class TaskShift : ApiEntity { - public Guid TaskId { get; private set; } - public virtual Task? Task { get; private set; } + public TaskShift() + { + + } - public Guid ShiftId { get; private set; } - public virtual Shift.Shift? Shift { get; private set; } + internal TaskShift(Guid taskId, Guid shiftId) + { + TaskId = taskId; + ShiftId = shiftId; + } + public Guid TaskId { get; internal set; } + public virtual Task? Task { get; internal set; } + + public Guid ShiftId { get; internal set; } + public virtual Shift.Shift? Shift { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/TaskUser.cs b/Brizco.Domain/Entities/Task/TaskUser.cs index 18f5a4d..17643f9 100644 --- a/Brizco.Domain/Entities/Task/TaskUser.cs +++ b/Brizco.Domain/Entities/Task/TaskUser.cs @@ -2,10 +2,22 @@ namespace Brizco.Domain.Entities.Task; +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] public class TaskUser : ApiEntity { - public Guid UserId { get; private set; } - public virtual ApplicationUser? User { get; private set; } - public Guid TaskId { get; private set; } - public virtual Task? Task { get; private set; } + public TaskUser() + { + + } + + public TaskUser(Guid userId,Guid taskId) + { + UserId = userId; + TaskId = taskId; + } + public Guid UserId { get; internal set; } + public virtual ApplicationUser? User { get; internal set; } + public Guid TaskId { get; internal set; } + public virtual Task? Task { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs new file mode 100644 index 0000000..2b5e639 --- /dev/null +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -0,0 +1,218 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.LargDtos; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Mappers +{ + public static partial class ActivityMapper + { + public static Activity AdaptToActivity(this ActivitySDto p1) + { + return p1 == null ? null : new Activity() + { + Status = p1.Status, + DoneAt = p1.DoneAt, + IsDone = p1.IsDone, + PerformanceDescription = p1.PerformanceDescription, + Id = p1.Id + }; + } + public static Activity AdaptTo(this ActivitySDto p2, Activity p3) + { + if (p2 == null) + { + return null; + } + Activity result = p3 ?? new Activity(); + + result.Status = p2.Status; + result.DoneAt = p2.DoneAt; + result.IsDone = p2.IsDone; + result.PerformanceDescription = p2.PerformanceDescription; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToActivity => p4 => new Activity() + { + Status = p4.Status, + DoneAt = p4.DoneAt, + IsDone = p4.IsDone, + PerformanceDescription = p4.PerformanceDescription, + Id = p4.Id + }; + public static ActivitySDto AdaptToSDto(this Activity p5) + { + return p5 == null ? null : new ActivitySDto() + { + Type = p5.Type, + Title = p5.Title, + Description = p5.Description, + IsRelatedToShift = p5.IsRelatedToShift, + IsRelatedToRole = p5.IsRelatedToRole, + IsRelatedToPerson = p5.IsRelatedToPerson, + IsDisposable = p5.IsDisposable, + SetFor = p5.SetFor, + HasDisposed = p5.HasDisposed, + Status = p5.Status, + DoneAt = p5.DoneAt, + IsDone = p5.IsDone, + PerformanceDescription = p5.PerformanceDescription, + Amount = p5.Amount, + AmountType = p5.AmountType, + Id = p5.Id + }; + } + public static ActivitySDto AdaptTo(this Activity p6, ActivitySDto p7) + { + if (p6 == null) + { + return null; + } + ActivitySDto result = p7 ?? new ActivitySDto(); + + result.Type = p6.Type; + result.Title = p6.Title; + result.Description = p6.Description; + result.IsRelatedToShift = p6.IsRelatedToShift; + result.IsRelatedToRole = p6.IsRelatedToRole; + result.IsRelatedToPerson = p6.IsRelatedToPerson; + result.IsDisposable = p6.IsDisposable; + result.SetFor = p6.SetFor; + result.HasDisposed = p6.HasDisposed; + result.Status = p6.Status; + result.DoneAt = p6.DoneAt; + result.IsDone = p6.IsDone; + result.PerformanceDescription = p6.PerformanceDescription; + result.Amount = p6.Amount; + result.AmountType = p6.AmountType; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new ActivitySDto() + { + Type = p8.Type, + Title = p8.Title, + Description = p8.Description, + IsRelatedToShift = p8.IsRelatedToShift, + IsRelatedToRole = p8.IsRelatedToRole, + IsRelatedToPerson = p8.IsRelatedToPerson, + IsDisposable = p8.IsDisposable, + SetFor = p8.SetFor, + HasDisposed = p8.HasDisposed, + Status = p8.Status, + DoneAt = p8.DoneAt, + IsDone = p8.IsDone, + PerformanceDescription = p8.PerformanceDescription, + Amount = p8.Amount, + AmountType = p8.AmountType, + Id = p8.Id + }; + public static Activity AdaptToActivity(this ActivityLDto p9) + { + return p9 == null ? null : new Activity() + { + Status = p9.Status, + DoneAt = p9.DoneAt, + IsDone = p9.IsDone, + PerformanceDescription = p9.PerformanceDescription, + Id = p9.Id + }; + } + public static Activity AdaptTo(this ActivityLDto p10, Activity p11) + { + if (p10 == null) + { + return null; + } + Activity result = p11 ?? new Activity(); + + result.Status = p10.Status; + result.DoneAt = p10.DoneAt; + result.IsDone = p10.IsDone; + result.PerformanceDescription = p10.PerformanceDescription; + result.Id = p10.Id; + return result; + + } + public static Expression> ProjectLDtoToActivity => p12 => new Activity() + { + Status = p12.Status, + DoneAt = p12.DoneAt, + IsDone = p12.IsDone, + PerformanceDescription = p12.PerformanceDescription, + Id = p12.Id + }; + public static ActivityLDto AdaptToLDto(this Activity p13) + { + return p13 == null ? null : new ActivityLDto() + { + Type = p13.Type, + Title = p13.Title, + Description = p13.Description, + IsRelatedToShift = p13.IsRelatedToShift, + IsRelatedToRole = p13.IsRelatedToRole, + IsRelatedToPerson = p13.IsRelatedToPerson, + IsDisposable = p13.IsDisposable, + SetFor = p13.SetFor, + HasDisposed = p13.HasDisposed, + Status = p13.Status, + DoneAt = p13.DoneAt, + IsDone = p13.IsDone, + PerformanceDescription = p13.PerformanceDescription, + Amount = p13.Amount, + AmountType = p13.AmountType, + Id = p13.Id + }; + } + public static ActivityLDto AdaptTo(this Activity p14, ActivityLDto p15) + { + if (p14 == null) + { + return null; + } + ActivityLDto result = p15 ?? new ActivityLDto(); + + result.Type = p14.Type; + result.Title = p14.Title; + result.Description = p14.Description; + result.IsRelatedToShift = p14.IsRelatedToShift; + result.IsRelatedToRole = p14.IsRelatedToRole; + result.IsRelatedToPerson = p14.IsRelatedToPerson; + result.IsDisposable = p14.IsDisposable; + result.SetFor = p14.SetFor; + result.HasDisposed = p14.HasDisposed; + result.Status = p14.Status; + result.DoneAt = p14.DoneAt; + result.IsDone = p14.IsDone; + result.PerformanceDescription = p14.PerformanceDescription; + result.Amount = p14.Amount; + result.AmountType = p14.AmountType; + result.Id = p14.Id; + return result; + + } + public static Expression> ProjectToLDto => p16 => new ActivityLDto() + { + Type = p16.Type, + Title = p16.Title, + Description = p16.Description, + IsRelatedToShift = p16.IsRelatedToShift, + IsRelatedToRole = p16.IsRelatedToRole, + IsRelatedToPerson = p16.IsRelatedToPerson, + IsDisposable = p16.IsDisposable, + SetFor = p16.SetFor, + HasDisposed = p16.HasDisposed, + Status = p16.Status, + DoneAt = p16.DoneAt, + IsDone = p16.IsDone, + PerformanceDescription = p16.PerformanceDescription, + Amount = p16.Amount, + AmountType = p16.AmountType, + Id = p16.Id + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ComplexMapper.g.cs b/Brizco.Domain/Mappers/ComplexMapper.g.cs new file mode 100644 index 0000000..53665e1 --- /dev/null +++ b/Brizco.Domain/Mappers/ComplexMapper.g.cs @@ -0,0 +1,140 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.LargDtos; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Complex; + +namespace Brizco.Domain.Mappers +{ + public static partial class ComplexMapper + { + public static Complex AdaptToComplex(this ComplexSDto p1) + { + return p1 == null ? null : new Complex() + { + Name = p1.Name, + Address = p1.Address, + SupportPhone = p1.SupportPhone, + Id = p1.Id + }; + } + public static Complex AdaptTo(this ComplexSDto p2, Complex p3) + { + if (p2 == null) + { + return null; + } + Complex result = p3 ?? new Complex(); + + result.Name = p2.Name; + result.Address = p2.Address; + result.SupportPhone = p2.SupportPhone; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToComplex => p4 => new Complex() + { + Name = p4.Name, + Address = p4.Address, + SupportPhone = p4.SupportPhone, + Id = p4.Id + }; + public static ComplexSDto AdaptToSDto(this Complex p5) + { + return p5 == null ? null : new ComplexSDto() + { + Name = p5.Name, + Address = p5.Address, + SupportPhone = p5.SupportPhone, + Id = p5.Id + }; + } + public static ComplexSDto AdaptTo(this Complex p6, ComplexSDto p7) + { + if (p6 == null) + { + return null; + } + ComplexSDto result = p7 ?? new ComplexSDto(); + + result.Name = p6.Name; + result.Address = p6.Address; + result.SupportPhone = p6.SupportPhone; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new ComplexSDto() + { + Name = p8.Name, + Address = p8.Address, + SupportPhone = p8.SupportPhone, + Id = p8.Id + }; + public static Complex AdaptToComplex(this ComplexLDto p9) + { + return p9 == null ? null : new Complex() + { + Name = p9.Name, + Address = p9.Address, + SupportPhone = p9.SupportPhone, + Id = p9.Id + }; + } + public static Complex AdaptTo(this ComplexLDto p10, Complex p11) + { + if (p10 == null) + { + return null; + } + Complex result = p11 ?? new Complex(); + + result.Name = p10.Name; + result.Address = p10.Address; + result.SupportPhone = p10.SupportPhone; + result.Id = p10.Id; + return result; + + } + public static Expression> ProjectLDtoToComplex => p12 => new Complex() + { + Name = p12.Name, + Address = p12.Address, + SupportPhone = p12.SupportPhone, + Id = p12.Id + }; + public static ComplexLDto AdaptToLDto(this Complex p13) + { + return p13 == null ? null : new ComplexLDto() + { + Name = p13.Name, + Address = p13.Address, + SupportPhone = p13.SupportPhone, + Id = p13.Id + }; + } + public static ComplexLDto AdaptTo(this Complex p14, ComplexLDto p15) + { + if (p14 == null) + { + return null; + } + ComplexLDto result = p15 ?? new ComplexLDto(); + + result.Name = p14.Name; + result.Address = p14.Address; + result.SupportPhone = p14.SupportPhone; + result.Id = p14.Id; + return result; + + } + public static Expression> ProjectToLDto => p16 => new ComplexLDto() + { + Name = p16.Name, + Address = p16.Address, + SupportPhone = p16.SupportPhone, + Id = p16.Id + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ComplexUserMapper.g.cs b/Brizco.Domain/Mappers/ComplexUserMapper.g.cs new file mode 100644 index 0000000..a4383cf --- /dev/null +++ b/Brizco.Domain/Mappers/ComplexUserMapper.g.cs @@ -0,0 +1,75 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Complex; + +namespace Brizco.Domain.Mappers +{ + public static partial class ComplexUserMapper + { + public static ComplexUser AdaptToComplexUser(this ComplexUserSDto p1) + { + return p1 == null ? null : new ComplexUser() + { + UserId = p1.UserId, + ComplexId = p1.ComplexId, + RoleId = p1.RoleId, + Id = p1.Id + }; + } + public static ComplexUser AdaptTo(this ComplexUserSDto p2, ComplexUser p3) + { + if (p2 == null) + { + return null; + } + ComplexUser result = p3 ?? new ComplexUser(); + + result.UserId = p2.UserId; + result.ComplexId = p2.ComplexId; + result.RoleId = p2.RoleId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToComplexUser => p4 => new ComplexUser() + { + UserId = p4.UserId, + ComplexId = p4.ComplexId, + RoleId = p4.RoleId, + Id = p4.Id + }; + public static ComplexUserSDto AdaptToSDto(this ComplexUser p5) + { + return p5 == null ? null : new ComplexUserSDto() + { + UserId = p5.UserId, + ComplexId = p5.ComplexId, + RoleId = p5.RoleId, + Id = p5.Id + }; + } + public static ComplexUserSDto AdaptTo(this ComplexUser p6, ComplexUserSDto p7) + { + if (p6 == null) + { + return null; + } + ComplexUserSDto result = p7 ?? new ComplexUserSDto(); + + result.UserId = p6.UserId; + result.ComplexId = p6.ComplexId; + result.RoleId = p6.RoleId; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new ComplexUserSDto() + { + UserId = p8.UserId, + ComplexId = p8.ComplexId, + RoleId = p8.RoleId, + Id = p8.Id + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftMapper.g.cs b/Brizco.Domain/Mappers/ShiftMapper.g.cs new file mode 100644 index 0000000..5769120 --- /dev/null +++ b/Brizco.Domain/Mappers/ShiftMapper.g.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Domain.Mappers +{ + public static partial class ShiftMapper + { + public static Shift AdaptToShift(this ShiftSDto p1) + { + return p1 == null ? null : new Shift() + { + Title = p1.Title, + StartAt = p1.StartAt, + EndAt = p1.EndAt, + Description = p1.Description, + Days = funcMain1(p1.Days), + Id = p1.Id + }; + } + public static Shift AdaptTo(this ShiftSDto p3, Shift p4) + { + if (p3 == null) + { + return null; + } + Shift result = p4 ?? new Shift(); + + result.Title = p3.Title; + result.StartAt = p3.StartAt; + result.EndAt = p3.EndAt; + result.Description = p3.Description; + result.Days = funcMain2(p3.Days, result.Days); + result.Id = p3.Id; + return result; + + } + public static Expression> ProjectToShift => p7 => 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 + }; + public static ShiftSDto AdaptToSDto(this Shift p9) + { + return p9 == 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 + }; + } + public static ShiftSDto AdaptTo(this Shift p11, ShiftSDto p12) + { + if (p11 == null) + { + return null; + } + ShiftSDto result = p12 ?? 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; + return result; + + } + public static Expression> ProjectToSDto => p15 => 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 + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + DayOfWeek item = p2[i]; + result.Add(new ShiftDay() {}); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + DayOfWeek item = p5[i]; + result.Add(new ShiftDay() {}); + i++; + } + return result; + + } + + private static List funcMain3(List p10) + { + if (p10 == null) + { + return null; + } + List result = new List(p10.Count); + + int i = 0; + int len = p10.Count; + + while (i < len) + { + DayOfWeek item = p10[i]; + result.Add(item); + i++; + } + return result; + + } + + private static DayOfWeek funcMain4(ShiftDay d) + { + return d.DayOfWeek; + } + + private static List funcMain5(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) + { + DayOfWeek item = p13[i]; + result.Add(item); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs new file mode 100644 index 0000000..2cd6217 --- /dev/null +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -0,0 +1,587 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.LargDtos; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Task; +using Task = Brizco.Domain.Entities.Task.Task; + +namespace Brizco.Domain.Mappers +{ + public static partial class TaskMapper + { + public static Task AdaptToTask(this TaskSDto p1) + { + return p1 == null ? null : new Task() + { + Type = p1.Type, + Title = p1.Title, + Description = p1.Description, + 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 + }; + } + public static Task AdaptTo(this TaskSDto p2, Task p3) + { + if (p2 == null) + { + return null; + } + Task result = p3 ?? new Task(); + + result.Type = p2.Type; + result.Title = p2.Title; + result.Description = p2.Description; + result.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; + + } + public static Expression> ProjectToTask => p4 => new Task() + { + 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 TaskSDto AdaptToSDto(this Task p5) + { + return p5 == null ? null : new TaskSDto() + { + Type = p5.Type, + Title = p5.Title, + Description = p5.Description, + IsRelatedToShift = p5.IsRelatedToShift, + IsRelatedToRole = p5.IsRelatedToRole, + IsRelatedToPerson = p5.IsRelatedToPerson, + IsDisposable = p5.IsDisposable, + SetFor = p5.SetFor, + HasDisposed = p5.HasDisposed, + Amount = p5.Amount, + AmountType = p5.AmountType, + Id = p5.Id + }; + } + public static TaskSDto AdaptTo(this Task p6, TaskSDto p7) + { + if (p6 == null) + { + return null; + } + TaskSDto result = p7 ?? new TaskSDto(); + + result.Type = p6.Type; + result.Title = p6.Title; + result.Description = p6.Description; + result.IsRelatedToShift = p6.IsRelatedToShift; + result.IsRelatedToRole = p6.IsRelatedToRole; + result.IsRelatedToPerson = p6.IsRelatedToPerson; + result.IsDisposable = p6.IsDisposable; + result.SetFor = p6.SetFor; + result.HasDisposed = p6.HasDisposed; + result.Amount = p6.Amount; + result.AmountType = p6.AmountType; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new TaskSDto() + { + Type = p8.Type, + Title = p8.Title, + Description = p8.Description, + IsRelatedToShift = p8.IsRelatedToShift, + IsRelatedToRole = p8.IsRelatedToRole, + IsRelatedToPerson = p8.IsRelatedToPerson, + IsDisposable = p8.IsDisposable, + SetFor = p8.SetFor, + HasDisposed = p8.HasDisposed, + Amount = p8.Amount, + AmountType = p8.AmountType, + Id = p8.Id + }; + public static Task AdaptToTask(this TaskLDto p9) + { + return p9 == null ? null : new Task() + { + Type = p9.Type, + Title = p9.Title, + Description = p9.Description, + IsRelatedToShift = p9.IsRelatedToShift, + IsRelatedToRole = p9.IsRelatedToRole, + IsRelatedToPerson = p9.IsRelatedToPerson, + IsDisposable = p9.IsDisposable, + SetFor = p9.SetFor, + HasDisposed = p9.HasDisposed, + Amount = p9.Amount, + AmountType = p9.AmountType, + Users = funcMain1(p9.Users), + Shifts = funcMain2(p9.Shifts), + Roles = funcMain3(p9.Roles), + Id = p9.Id + }; + } + public static Task AdaptTo(this TaskLDto p13, Task p14) + { + if (p13 == null) + { + return null; + } + Task result = p14 ?? new Task(); + + result.Type = p13.Type; + result.Title = p13.Title; + result.Description = p13.Description; + result.IsRelatedToShift = p13.IsRelatedToShift; + result.IsRelatedToRole = p13.IsRelatedToRole; + result.IsRelatedToPerson = p13.IsRelatedToPerson; + result.IsDisposable = p13.IsDisposable; + result.SetFor = p13.SetFor; + result.HasDisposed = p13.HasDisposed; + result.Amount = p13.Amount; + result.AmountType = p13.AmountType; + result.Users = funcMain4(p13.Users, result.Users); + result.Shifts = funcMain5(p13.Shifts, result.Shifts); + result.Roles = funcMain6(p13.Roles, result.Roles); + result.Id = p13.Id; + return result; + + } + public static Expression> ProjectLDtoToTask => p21 => new Task() + { + Type = p21.Type, + Title = p21.Title, + Description = p21.Description, + IsRelatedToShift = p21.IsRelatedToShift, + IsRelatedToRole = p21.IsRelatedToRole, + IsRelatedToPerson = p21.IsRelatedToPerson, + IsDisposable = p21.IsDisposable, + SetFor = p21.SetFor, + HasDisposed = p21.HasDisposed, + Amount = p21.Amount, + AmountType = p21.AmountType, + Users = p21.Users.Select(p22 => new TaskUser() + { + UserId = p22.UserId, + TaskId = p22.TaskId + }).ToList(), + Shifts = p21.Shifts.Select(p23 => new TaskShift() + { + TaskId = p23.TaskId, + ShiftId = p23.ShiftId + }).ToList(), + Roles = p21.Roles.Select(p24 => new TaskRole() + { + RoleId = p24.RoleId, + TaskId = p24.TaskId, + Id = p24.Id + }).ToList(), + Id = p21.Id + }; + public static TaskLDto AdaptToLDto(this Task p25) + { + return p25 == null ? null : new TaskLDto() + { + Type = p25.Type, + Title = p25.Title, + Description = p25.Description, + IsRelatedToShift = p25.IsRelatedToShift, + IsRelatedToRole = p25.IsRelatedToRole, + IsRelatedToPerson = p25.IsRelatedToPerson, + IsDisposable = p25.IsDisposable, + SetFor = p25.SetFor, + HasDisposed = p25.HasDisposed, + Amount = p25.Amount, + AmountType = p25.AmountType, + Users = funcMain7(p25.Users), + Shifts = funcMain8(p25.Shifts), + Roles = funcMain9(p25.Roles), + Id = p25.Id + }; + } + public static TaskLDto AdaptTo(this Task p29, TaskLDto p30) + { + if (p29 == null) + { + return null; + } + TaskLDto result = p30 ?? new TaskLDto(); + + result.Type = p29.Type; + result.Title = p29.Title; + result.Description = p29.Description; + result.IsRelatedToShift = p29.IsRelatedToShift; + result.IsRelatedToRole = p29.IsRelatedToRole; + result.IsRelatedToPerson = p29.IsRelatedToPerson; + result.IsDisposable = p29.IsDisposable; + result.SetFor = p29.SetFor; + result.HasDisposed = p29.HasDisposed; + result.Amount = p29.Amount; + result.AmountType = p29.AmountType; + result.Users = funcMain10(p29.Users, result.Users); + result.Shifts = funcMain11(p29.Shifts, result.Shifts); + result.Roles = funcMain12(p29.Roles, result.Roles); + result.Id = p29.Id; + return result; + + } + public static Expression> ProjectToLDto => p37 => new TaskLDto() + { + Type = p37.Type, + Title = p37.Title, + Description = p37.Description, + IsRelatedToShift = p37.IsRelatedToShift, + IsRelatedToRole = p37.IsRelatedToRole, + IsRelatedToPerson = p37.IsRelatedToPerson, + IsDisposable = p37.IsDisposable, + SetFor = p37.SetFor, + HasDisposed = p37.HasDisposed, + Amount = p37.Amount, + AmountType = p37.AmountType, + Users = p37.Users.Select(p38 => new TaskUserSDto() + { + UserId = p38.UserId, + TaskId = p38.TaskId + }).ToList(), + Shifts = p37.Shifts.Select(p39 => new TaskShiftSDto() + { + ShiftId = p39.ShiftId, + TaskId = p39.TaskId + }).ToList(), + Roles = p37.Roles.Select(p40 => new TaskRoleSDto() + { + RoleId = p40.RoleId, + TaskId = p40.TaskId, + Id = p40.Id + }).ToList(), + Id = p37.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) + { + TaskUserSDto item = p10[i]; + result.Add(item == null ? null : new TaskUser() + { + UserId = item.UserId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain2(List p11) + { + if (p11 == null) + { + return null; + } + List result = new List(p11.Count); + + int i = 0; + int len = p11.Count; + + while (i < len) + { + TaskShiftSDto item = p11[i]; + result.Add(item == null ? null : new TaskShift() + { + TaskId = item.TaskId, + ShiftId = item.ShiftId + }); + i++; + } + return result; + + } + + private static List funcMain3(List p12) + { + if (p12 == null) + { + return null; + } + List result = new List(p12.Count); + + int i = 0; + int len = p12.Count; + + while (i < len) + { + TaskRoleSDto item = p12[i]; + result.Add(item == null ? null : new TaskRole() + { + RoleId = item.RoleId, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p15, List p16) + { + if (p15 == null) + { + return null; + } + List result = new List(p15.Count); + + int i = 0; + int len = p15.Count; + + while (i < len) + { + TaskUserSDto item = p15[i]; + result.Add(item == null ? null : new TaskUser() + { + UserId = item.UserId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain5(List p17, List p18) + { + if (p17 == null) + { + return null; + } + List result = new List(p17.Count); + + int i = 0; + int len = p17.Count; + + while (i < len) + { + TaskShiftSDto item = p17[i]; + result.Add(item == null ? null : new TaskShift() + { + TaskId = item.TaskId, + ShiftId = item.ShiftId + }); + i++; + } + return result; + + } + + private static List funcMain6(List p19, List p20) + { + if (p19 == null) + { + return null; + } + List result = new List(p19.Count); + + int i = 0; + int len = p19.Count; + + while (i < len) + { + TaskRoleSDto item = p19[i]; + result.Add(item == null ? null : new TaskRole() + { + RoleId = item.RoleId, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain7(List p26) + { + if (p26 == null) + { + return null; + } + List result = new List(p26.Count); + + int i = 0; + int len = p26.Count; + + while (i < len) + { + TaskUser item = p26[i]; + result.Add(item == null ? null : new TaskUserSDto() + { + UserId = item.UserId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain8(List p27) + { + if (p27 == null) + { + return null; + } + List result = new List(p27.Count); + + int i = 0; + int len = p27.Count; + + while (i < len) + { + TaskShift item = p27[i]; + result.Add(item == null ? null : new TaskShiftSDto() + { + ShiftId = item.ShiftId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain9(List p28) + { + if (p28 == null) + { + return null; + } + List result = new List(p28.Count); + + int i = 0; + int len = p28.Count; + + while (i < len) + { + TaskRole item = p28[i]; + result.Add(item == null ? null : new TaskRoleSDto() + { + RoleId = item.RoleId, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain10(List p31, List p32) + { + if (p31 == null) + { + return null; + } + List result = new List(p31.Count); + + int i = 0; + int len = p31.Count; + + while (i < len) + { + TaskUser item = p31[i]; + result.Add(item == null ? null : new TaskUserSDto() + { + UserId = item.UserId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain11(List p33, List p34) + { + if (p33 == null) + { + return null; + } + List result = new List(p33.Count); + + int i = 0; + int len = p33.Count; + + while (i < len) + { + TaskShift item = p33[i]; + result.Add(item == null ? null : new TaskShiftSDto() + { + ShiftId = item.ShiftId, + TaskId = item.TaskId + }); + i++; + } + return result; + + } + + private static List funcMain12(List p35, List p36) + { + if (p35 == null) + { + return null; + } + List result = new List(p35.Count); + + int i = 0; + int len = p35.Count; + + while (i < len) + { + TaskRole item = p35[i]; + result.Add(item == null ? null : new TaskRoleSDto() + { + RoleId = item.RoleId, + TaskId = item.TaskId, + Id = item.Id + }); + i++; + } + return result; + + } + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/TaskRoleMapper.g.cs b/Brizco.Domain/Mappers/TaskRoleMapper.g.cs new file mode 100644 index 0000000..79ae17a --- /dev/null +++ b/Brizco.Domain/Mappers/TaskRoleMapper.g.cs @@ -0,0 +1,69 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Mappers +{ + public static partial class TaskRoleMapper + { + public static TaskRole AdaptToTaskRole(this TaskRoleSDto p1) + { + return p1 == null ? null : new TaskRole() + { + RoleId = p1.RoleId, + TaskId = p1.TaskId, + Id = p1.Id + }; + } + public static TaskRole AdaptTo(this TaskRoleSDto p2, TaskRole p3) + { + if (p2 == null) + { + return null; + } + TaskRole result = p3 ?? new TaskRole(); + + result.RoleId = p2.RoleId; + result.TaskId = p2.TaskId; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToTaskRole => p4 => new TaskRole() + { + RoleId = p4.RoleId, + TaskId = p4.TaskId, + Id = p4.Id + }; + public static TaskRoleSDto AdaptToSDto(this TaskRole p5) + { + return p5 == null ? null : new TaskRoleSDto() + { + RoleId = p5.RoleId, + TaskId = p5.TaskId, + Id = p5.Id + }; + } + public static TaskRoleSDto AdaptTo(this TaskRole p6, TaskRoleSDto p7) + { + if (p6 == null) + { + return null; + } + TaskRoleSDto result = p7 ?? new TaskRoleSDto(); + + result.RoleId = p6.RoleId; + result.TaskId = p6.TaskId; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new TaskRoleSDto() + { + RoleId = p8.RoleId, + TaskId = p8.TaskId, + Id = p8.Id + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/TaskShiftMapper.g.cs b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs new file mode 100644 index 0000000..202af45 --- /dev/null +++ b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs @@ -0,0 +1,63 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Mappers +{ + public static partial class TaskShiftMapper + { + public static TaskShift AdaptToTaskShift(this TaskShiftSDto p1) + { + return p1 == null ? null : new TaskShift() + { + TaskId = p1.TaskId, + ShiftId = p1.ShiftId + }; + } + public static TaskShift AdaptTo(this TaskShiftSDto p2, TaskShift p3) + { + if (p2 == null) + { + return null; + } + TaskShift result = p3 ?? new TaskShift(); + + result.TaskId = p2.TaskId; + result.ShiftId = p2.ShiftId; + return result; + + } + public static Expression> ProjectToTaskShift => p4 => new TaskShift() + { + TaskId = p4.TaskId, + ShiftId = p4.ShiftId + }; + public static TaskShiftSDto AdaptToSDto(this TaskShift p5) + { + return p5 == null ? null : new TaskShiftSDto() + { + ShiftId = p5.ShiftId, + TaskId = p5.TaskId + }; + } + public static TaskShiftSDto AdaptTo(this TaskShift p6, TaskShiftSDto p7) + { + if (p6 == null) + { + return null; + } + TaskShiftSDto result = p7 ?? new TaskShiftSDto(); + + result.ShiftId = p6.ShiftId; + result.TaskId = p6.TaskId; + return result; + + } + public static Expression> ProjectToSDto => p8 => new TaskShiftSDto() + { + ShiftId = p8.ShiftId, + TaskId = p8.TaskId + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/TaskUserMapper.g.cs b/Brizco.Domain/Mappers/TaskUserMapper.g.cs new file mode 100644 index 0000000..58301c6 --- /dev/null +++ b/Brizco.Domain/Mappers/TaskUserMapper.g.cs @@ -0,0 +1,63 @@ +using System; +using System.Linq.Expressions; +using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Task; + +namespace Brizco.Domain.Mappers +{ + public static partial class TaskUserMapper + { + public static TaskUser AdaptToTaskUser(this TaskUserSDto p1) + { + return p1 == null ? null : new TaskUser() + { + UserId = p1.UserId, + TaskId = p1.TaskId + }; + } + public static TaskUser AdaptTo(this TaskUserSDto p2, TaskUser p3) + { + if (p2 == null) + { + return null; + } + TaskUser result = p3 ?? new TaskUser(); + + result.UserId = p2.UserId; + result.TaskId = p2.TaskId; + return result; + + } + public static Expression> ProjectToTaskUser => p4 => new TaskUser() + { + UserId = p4.UserId, + TaskId = p4.TaskId + }; + public static TaskUserSDto AdaptToSDto(this TaskUser p5) + { + return p5 == null ? null : new TaskUserSDto() + { + UserId = p5.UserId, + TaskId = p5.TaskId + }; + } + public static TaskUserSDto AdaptTo(this TaskUser p6, TaskUserSDto p7) + { + if (p6 == null) + { + return null; + } + TaskUserSDto result = p7 ?? new TaskUserSDto(); + + result.UserId = p6.UserId; + result.TaskId = p6.TaskId; + return result; + + } + public static Expression> ProjectToSDto => p8 => new TaskUserSDto() + { + UserId = p8.UserId, + TaskId = p8.TaskId + }; + } +} \ No newline at end of file diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs new file mode 100644 index 0000000..6e53f52 --- /dev/null +++ b/Brizco.Domain/MapsterRegister.cs @@ -0,0 +1,15 @@ +using Brizco.Domain.Entities.Shift; +using Mapster; + +namespace Brizco.Domain; + +public class MapsterRegister : IRegister +{ + public void Register(TypeAdapterConfig config) + { + config.NewConfig() + .Map("Days", org => org.Days != null ? org.Days.Select(d=>d.DayOfWeek).ToList() + : new List()) + .TwoWays(); + } +} \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 0000000..fb34cf6 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "7.0.400" + } +} \ No newline at end of file