From 1fbf37dd82c3d6ad5dafadd0dd0a9926449b0c12 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Mon, 8 Jul 2024 17:45:17 +0330 Subject: [PATCH] change(Activities) , feat(NotifyCommands) --- Brizco.Api/Brizco.Api.csproj | 2 +- .../ScalarUi/ScalarUiConfiguration.cs | 58 +++++++------- .../Swagger/SwaggerConfiguration.cs | 21 ++--- Brizco.Common/Brizco.Common.csproj | 8 +- Brizco.Core/Brizco.Core.csproj | 9 ++- Brizco.Core/CoreServices/AccountService.cs | 4 +- Brizco.Core/CoreServices/PageService.cs | 9 +-- Brizco.Core/EntityServices/ActivityService.cs | 4 +- .../EntityServices/ShiftPlanService.cs | 35 +++----- .../Commands/NotificationScheduleCommands.cs | 4 + ...ateShiftPlanNotificationsCommandHandler.cs | 38 +++++++++ ...tPlanNotificationScheduleCommandHandler.cs | 70 ++++++++++++++++ Brizco.Core/QuartzServices/JobScheduler.cs | 13 +-- .../NotificationScheduledJob.cs | 38 --------- .../ShiftPlanNotificationScheduledJob.cs | 80 +++++++++++++++++++ Brizco.Domain/Brizco.Domain.csproj | 14 ++-- .../Commands/NotificationCommands.cs | 2 +- Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs | 1 + .../Dtos/SmallDtos/ShiftPlanUserSDto.cs | 2 +- .../ShiftPlans/ShiftPlan.Aggregate.cs | 17 ++++ .../{Shifts => ShiftPlans}/ShiftPlan.cs | 7 +- .../{Shifts => ShiftPlans}/ShiftPlanUser.cs | 8 +- .../Entities/Shifts/Aggregate.Shift.cs | 17 ---- Brizco.Domain/Enums/ShiftPlanNotifyType.cs | 9 +++ Brizco.Domain/Mappers/ActivityMapper.g.cs | 2 +- Brizco.Domain/Mappers/ShiftPlanMapper.g.cs | 1 + .../Mappers/ShiftPlanUserMapper.g.cs | 2 +- Brizco.Domain/Mappers/TaskMapper.g.cs | 1 - Brizco.Domain/Mappers/TaskPositionMapper.g.cs | 1 - Brizco.Domain/Mappers/TaskShiftMapper.g.cs | 1 - Brizco.Domain/MapsterRegister.cs | 2 +- Brizco.Repository/Brizco.Repository.csproj | 6 +- .../CreateActivityCommandHandler.cs | 4 +- .../DeleteActivityCommandHandler.cs | 2 +- .../GetActivitiesQueryHandler.cs | 2 +- .../GetActivityQueryHandler.cs | 4 +- .../GetShiftPlanActivitiesQueryHandler.cs | 2 +- .../UpdateActivityCommandHandler.cs | 2 +- .../CreateComplexCommandHandler.cs | 6 +- .../CreateComplexUserCommandHandler.cs | 8 +- .../DeleteComplexCommandHandler.cs | 6 +- .../DeleteComplexUserCommandHandler.cs | 4 +- .../GetComplexQueryHandler.cs | 4 +- .../GetComplexUsersQueryHandler.cs | 6 +- .../GetComplexesQueryHandler.cs | 4 +- .../UpdateComplexUserCommandHandler.cs | 6 +- .../CreatePositionCommandHandler.cs | 6 +- .../DeletePositionCommandHandler.cs | 6 +- .../GetPositionQueryHandler.cs | 6 +- .../GetPositionsQueryHandler.cs | 4 +- .../UpdatePositionCommandHandler.cs | 10 +-- .../CreateRoutineCommandHandler.cs | 2 +- .../DeleteRoutineCommandHandler.cs | 2 +- .../GetRoutineQueryHandler.cs | 2 +- .../GetRoutineShiftsQueryHandler.cs | 8 +- .../GetRoutinesQueryHandler.cs | 2 +- .../UpdateRoutineCommandHandler.cs | 2 +- .../CreateSectionCommandHandler.cs | 6 +- .../DeleteSectionCommandHandler.cs | 8 +- .../GetSectionQueryHandler.cs | 6 +- .../GetSectionsQueryHandler.cs | 4 +- .../UpdateSectionCommandHandler.cs | 8 +- .../CreateShiftPlanCommandHandler.cs | 11 +-- .../DeleteShiftPlanCommandHandler.cs | 6 +- .../GetShiftPlanQueryHandler.cs | 6 +- .../GetShiftPlansQueryHandler.cs | 7 +- .../UpdateShiftPlanCommandHandler.cs | 10 +-- .../CreateShiftCommandHandler.cs | 6 +- .../DeleteShiftCommandHandler.cs | 6 +- .../{Shift => Shifts}/GetShiftQueryHandler.cs | 6 +- .../GetShiftsQueryHandler.cs | 17 ++-- .../UpdateShiftCommandHandler.cs | 10 +-- .../CreateTaskCommandHandler.cs | 4 +- .../DeleteTaskCommandHandler.cs | 2 +- .../{Task => Tasks}/GetTaskQueryHandler.cs | 4 +- .../{Task => Tasks}/GetTasksQueryHandler.cs | 2 +- .../UpdateTaskCommandHandler.cs | 2 +- .../Models/ApplicationContext.cs | 7 +- .../Repositories/Base/BaseRepository.cs | 4 +- .../Repositories/Base/Repository.cs | 5 +- .../Repositories/Base/WriteRepository.cs | 2 - .../Repositories/UnitOfWork/UnitOfWork.cs | 3 +- .../Contracts/IDbInitializerService.cs | 3 +- .../Services/DbInitializerService.cs | 3 +- 84 files changed, 418 insertions(+), 336 deletions(-) create mode 100644 Brizco.Core/QuartzServices/Commands/NotificationScheduleCommands.cs create mode 100644 Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs create mode 100644 Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs delete mode 100644 Brizco.Core/QuartzServices/NotificationScheduledJob.cs create mode 100644 Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs create mode 100644 Brizco.Domain/Entities/ShiftPlans/ShiftPlan.Aggregate.cs rename Brizco.Domain/Entities/{Shifts => ShiftPlans}/ShiftPlan.cs (92%) rename Brizco.Domain/Entities/{Shifts => ShiftPlans}/ShiftPlanUser.cs (81%) create mode 100644 Brizco.Domain/Enums/ShiftPlanNotifyType.cs rename Brizco.Repository/Handlers/{Activity => Activities}/CreateActivityCommandHandler.cs (95%) rename Brizco.Repository/Handlers/{Activity => Activities}/DeleteActivityCommandHandler.cs (95%) rename Brizco.Repository/Handlers/{Activity => Activities}/GetActivitiesQueryHandler.cs (98%) rename Brizco.Repository/Handlers/{Activity => Activities}/GetActivityQueryHandler.cs (90%) rename Brizco.Repository/Handlers/{Activity => Activities}/GetShiftPlanActivitiesQueryHandler.cs (93%) rename Brizco.Repository/Handlers/{Activity => Activities}/UpdateActivityCommandHandler.cs (97%) rename Brizco.Repository/Handlers/{Complex => Complexes}/CreateComplexCommandHandler.cs (78%) rename Brizco.Repository/Handlers/{Complex => Complexes}/CreateComplexUserCommandHandler.cs (92%) rename Brizco.Repository/Handlers/{Complex => Complexes}/DeleteComplexCommandHandler.cs (82%) rename Brizco.Repository/Handlers/{Complex => Complexes}/DeleteComplexUserCommandHandler.cs (95%) rename Brizco.Repository/Handlers/{Complex => Complexes}/GetComplexQueryHandler.cs (82%) rename Brizco.Repository/Handlers/{Complex => Complexes}/GetComplexUsersQueryHandler.cs (92%) rename Brizco.Repository/Handlers/{Complex => Complexes}/GetComplexesQueryHandler.cs (79%) rename Brizco.Repository/Handlers/{Complex => Complexes}/UpdateComplexUserCommandHandler.cs (95%) rename Brizco.Repository/Handlers/{Position => Positions}/CreatePositionCommandHandler.cs (88%) rename Brizco.Repository/Handlers/{Position => Positions}/DeletePositionCommandHandler.cs (76%) rename Brizco.Repository/Handlers/{Position => Positions}/GetPositionQueryHandler.cs (79%) rename Brizco.Repository/Handlers/{Position => Positions}/GetPositionsQueryHandler.cs (87%) rename Brizco.Repository/Handlers/{Position => Positions}/UpdatePositionCommandHandler.cs (85%) rename Brizco.Repository/Handlers/{Routine => Routines}/CreateRoutineCommandHandler.cs (96%) rename Brizco.Repository/Handlers/{Routine => Routines}/DeleteRoutineCommandHandler.cs (94%) rename Brizco.Repository/Handlers/{Routine => Routines}/GetRoutineQueryHandler.cs (94%) rename Brizco.Repository/Handlers/{Routine => Routines}/GetRoutineShiftsQueryHandler.cs (90%) rename Brizco.Repository/Handlers/{Routine => Routines}/GetRoutinesQueryHandler.cs (96%) rename Brizco.Repository/Handlers/{Routine => Routines}/UpdateRoutineCommandHandler.cs (96%) rename Brizco.Repository/Handlers/{Section => Sections}/CreateSectionCommandHandler.cs (87%) rename Brizco.Repository/Handlers/{Section => Sections}/DeleteSectionCommandHandler.cs (76%) rename Brizco.Repository/Handlers/{Section => Sections}/GetSectionQueryHandler.cs (79%) rename Brizco.Repository/Handlers/{Section => Sections}/GetSectionsQueryHandler.cs (87%) rename Brizco.Repository/Handlers/{Section => Sections}/UpdateSectionCommandHandler.cs (80%) rename Brizco.Repository/Handlers/{ShiftPlan => ShiftPlans}/CreateShiftPlanCommandHandler.cs (87%) rename Brizco.Repository/Handlers/{ShiftPlan => ShiftPlans}/DeleteShiftPlanCommandHandler.cs (76%) rename Brizco.Repository/Handlers/{ShiftPlan => ShiftPlans}/GetShiftPlanQueryHandler.cs (79%) rename Brizco.Repository/Handlers/{ShiftPlan => ShiftPlans}/GetShiftPlansQueryHandler.cs (97%) rename Brizco.Repository/Handlers/{ShiftPlan => ShiftPlans}/UpdateShiftPlanCommandHandler.cs (85%) rename Brizco.Repository/Handlers/{Shift => Shifts}/CreateShiftCommandHandler.cs (90%) rename Brizco.Repository/Handlers/{Shift => Shifts}/DeleteShiftCommandHandler.cs (77%) rename Brizco.Repository/Handlers/{Shift => Shifts}/GetShiftQueryHandler.cs (84%) rename Brizco.Repository/Handlers/{Shift => Shifts}/GetShiftsQueryHandler.cs (91%) rename Brizco.Repository/Handlers/{Shift => Shifts}/UpdateShiftCommandHandler.cs (90%) rename Brizco.Repository/Handlers/{Task => Tasks}/CreateTaskCommandHandler.cs (96%) rename Brizco.Repository/Handlers/{Task => Tasks}/DeleteTaskCommandHandler.cs (94%) rename Brizco.Repository/Handlers/{Task => Tasks}/GetTaskQueryHandler.cs (90%) rename Brizco.Repository/Handlers/{Task => Tasks}/GetTasksQueryHandler.cs (96%) rename Brizco.Repository/Handlers/{Task => Tasks}/UpdateTaskCommandHandler.cs (99%) diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index 4c65071..99a3101 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -73,7 +73,7 @@ - + diff --git a/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs b/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs index 7c256c7..79979fb 100644 --- a/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs +++ b/Brizco.Api/WebFramework/ScalarUi/ScalarUiConfiguration.cs @@ -8,35 +8,35 @@ public static class ScalarUiConfiguration { var scalarScript = $$""" - - - - Scalar API Reference - - - - - - - - - - - - - - """; + + + + Scalar API Reference + + + + + + + + + + + + + + """; return Results.Content(scalarScript, "text/html"); }).ExcludeFromDescription(); diff --git a/Brizco.Api/WebFramework/Swagger/SwaggerConfiguration.cs b/Brizco.Api/WebFramework/Swagger/SwaggerConfiguration.cs index ce89e04..e7188a8 100644 --- a/Brizco.Api/WebFramework/Swagger/SwaggerConfiguration.cs +++ b/Brizco.Api/WebFramework/Swagger/SwaggerConfiguration.cs @@ -1,5 +1,4 @@ -using Asp.Versioning; -using Brizco.Common.Extensions; +using Brizco.Common.Extensions; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.OpenApi.Models; using Pluralize.NET; @@ -10,7 +9,7 @@ namespace Brizco.Api.WebFramework.Swagger; public static class SwaggerConfiguration { - public static void AddCustomSwagger(this IServiceCollection services,string baseUrl) + public static void AddCustomSwagger(this IServiceCollection services, string baseUrl) { services.AddSwaggerGen(options => { @@ -20,9 +19,9 @@ public static class SwaggerConfiguration new OpenApiInfo { Version = "v1", - Title = "BrizCo Api Document", - Description = "BrizCo api document OpenApi based", - License = new OpenApiLicense { Name = "Briz Corp" }, + Title = "GolBarg Api Document", + Description = "GolBarg api for clients that wana use , based OpenApi", + License = new OpenApiLicense { Name = "Vira Safir Fanavar " }, Contact = new OpenApiContact { Name = "Amir Hossein Khademi", @@ -85,7 +84,7 @@ public static class SwaggerConfiguration }); } - public static void UseCustomSwagger(this IApplicationBuilder app,string baseUrl) + public static void UseCustomSwagger(this IApplicationBuilder app, string baseUrl) { app.UseSwagger(options => { @@ -195,13 +194,17 @@ public class ApplySummariesOperationFilter : IOperationFilter public void Apply(OpenApiOperation operation, OperationFilterContext context) { var controllerActionDescriptor = context.ApiDescription.ActionDescriptor as ControllerActionDescriptor; - if (controllerActionDescriptor == null) return; + if (controllerActionDescriptor == null) + { + operation.Summary = context.ApiDescription.ActionDescriptor.DisplayName; + return; + } var pluralizer = new Pluralizer(); var actionName = controllerActionDescriptor.ActionName; var singularizeName = pluralizer.Singularize(controllerActionDescriptor.ControllerName); - var pluralizeName = pluralizer.Pluralize(singularizeName); + var pluralizeName = pluralizer.Pluralize(controllerActionDescriptor.DisplayName); var parameterCount = operation.Parameters.Where(p => p.Name != "version" && p.Name != "api-version").Count(); diff --git a/Brizco.Common/Brizco.Common.csproj b/Brizco.Common/Brizco.Common.csproj index 393ed47..8b1d127 100644 --- a/Brizco.Common/Brizco.Common.csproj +++ b/Brizco.Common/Brizco.Common.csproj @@ -1,6 +1,6 @@  - + - + diff --git a/Brizco.Core/Brizco.Core.csproj b/Brizco.Core/Brizco.Core.csproj index f7a64ae..70523ac 100644 --- a/Brizco.Core/Brizco.Core.csproj +++ b/Brizco.Core/Brizco.Core.csproj @@ -18,6 +18,7 @@ + @@ -35,6 +36,7 @@ + @@ -43,8 +45,11 @@ - - + + + + + diff --git a/Brizco.Core/CoreServices/AccountService.cs b/Brizco.Core/CoreServices/AccountService.cs index 118292f..e97abcc 100644 --- a/Brizco.Core/CoreServices/AccountService.cs +++ b/Brizco.Core/CoreServices/AccountService.cs @@ -1,6 +1,6 @@ using System.Threading; using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Shifts; +using Brizco.Domain.Entities.ShiftPlans; using Brizco.Domain.Entities.Users; using NPOI.SS.Formula.Functions; @@ -168,8 +168,6 @@ public class AccountService : IAccountService throw new AppException("نام و نام خانوادگی را وارد کنید"); if (requestDto.ComplexName.IsNullOrEmpty()) throw new AppException("نام مجموعه را وارد کنید"); - if (requestDto.ComplexAddress.IsNullOrEmpty()) - throw new AppException("آدرس مجموعه را وارد کنید"); diff --git a/Brizco.Core/CoreServices/PageService.cs b/Brizco.Core/CoreServices/PageService.cs index 09db5c2..9926ef5 100644 --- a/Brizco.Core/CoreServices/PageService.cs +++ b/Brizco.Core/CoreServices/PageService.cs @@ -1,10 +1,5 @@ -using Task = Brizco.Domain.Entities.Tasks.Task; -using System.Linq; -using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Routines; -using Brizco.Domain.Entities.Shifts; -using Brizco.Domain.Entities.Tasks; -using Brizco.Domain.Entities.Users; +using Brizco.Domain.Entities.Tasks; +using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Core.CoreServices; diff --git a/Brizco.Core/EntityServices/ActivityService.cs b/Brizco.Core/EntityServices/ActivityService.cs index e1b867c..d4604fa 100644 --- a/Brizco.Core/EntityServices/ActivityService.cs +++ b/Brizco.Core/EntityServices/ActivityService.cs @@ -1,5 +1,4 @@ -using Brizco.Domain.Entities.Shifts; -using Brizco.Domain.Entities.Tasks; +using Brizco.Domain.Entities.Tasks; using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Core.EntityServices; @@ -95,6 +94,7 @@ public class ActivityService : IActivityService var tasks = new List(); tasks.AddRange(weeklyTasks); + tasks.AddRange(dailyTasks); tasks.AddRange(customTasks); diff --git a/Brizco.Core/EntityServices/ShiftPlanService.cs b/Brizco.Core/EntityServices/ShiftPlanService.cs index e546cb7..2f4ce03 100644 --- a/Brizco.Core/EntityServices/ShiftPlanService.cs +++ b/Brizco.Core/EntityServices/ShiftPlanService.cs @@ -1,50 +1,39 @@ -using Brizco.Domain.Entities.Shifts; +namespace Brizco.Core.EntityServices; -namespace Brizco.Core.EntityServices; - -public class ShiftPlanService : IShiftPlanService +public class ShiftPlanService(IMediator mediator, IActivityService activityService, IRepositoryWrapper repositoryWrapper) : IShiftPlanService { - private readonly ISender _sender; - private readonly IActivityService _activityService; - private readonly IRepositoryWrapper _repositoryWrapper; - - public ShiftPlanService(ISender sender,IActivityService activityService,IRepositoryWrapper repositoryWrapper) - { - _sender = sender; - _activityService = activityService; - _repositoryWrapper = repositoryWrapper; - } public async Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId, bool isChangeToShift, bool isDisable) { - var shiftPlan = await _sender.Send(new GetShiftPlanQuery(shiftPlanId)); + var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId)); } public async Task CreateAsync(CreateShiftPlanCommand createShiftPlanCommand, CancellationToken cancellationToken) { - var shiftPlan = await _sender.Send(createShiftPlanCommand, cancellationToken); - await _activityService.CreateActivitiesByShiftPlan(shiftPlan.Id, cancellationToken); + var shiftPlan = await mediator.Send(createShiftPlanCommand, cancellationToken); + await activityService.CreateActivitiesByShiftPlan(shiftPlan.Id, cancellationToken); + await mediator.Send(new CreateShiftPlanNotificationsCommand(shiftPlan.Id), cancellationToken); return true; } public async Task UpdateAsync(UpdateShiftPlanCommand updateShiftPlanCommand, CancellationToken cancellationToken) { - await _sender.Send(updateShiftPlanCommand, cancellationToken); - await _activityService.UpdateActivitiesByShiftPlan(updateShiftPlanCommand.Id, cancellationToken); + await mediator.Send(updateShiftPlanCommand, cancellationToken); + await activityService.UpdateActivitiesByShiftPlan(updateShiftPlanCommand.Id, cancellationToken); return true; } public async Task CompleteShiftPlanAsync(Guid id, CompleteShiftPlanRequestDto requestDtos, CancellationToken cancellationToken) { - var shiftPlan = await _repositoryWrapper.SetRepository() + var shiftPlan = await repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == id, cancellationToken); if (shiftPlan == null) throw new AppException("Shift plan not found", ApiResultStatusCode.NotFound); shiftPlan.CompletePlan(requestDtos.CompleteDescription,requestDtos.CompletePercent); - _repositoryWrapper.SetRepository().Update(shiftPlan); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); - await _activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); + repositoryWrapper.SetRepository().Update(shiftPlan); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); return true; } } \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/Commands/NotificationScheduleCommands.cs b/Brizco.Core/QuartzServices/Commands/NotificationScheduleCommands.cs new file mode 100644 index 0000000..fb7541c --- /dev/null +++ b/Brizco.Core/QuartzServices/Commands/NotificationScheduleCommands.cs @@ -0,0 +1,4 @@ +namespace Brizco.Core.QuartzServices.Commands; + +public record SetShiftPlanNotificationScheduleCommand(Guid ShiftPlanId) : IRequest; +public record CreateShiftPlanNotificationsCommand(Guid ShiftPlanId , bool InStart) : IRequest; \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs new file mode 100644 index 0000000..5e11562 --- /dev/null +++ b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs @@ -0,0 +1,38 @@ +using Brizco.Domain.Entities.ShiftPlans; + +namespace Brizco.Core.QuartzServices.Handlers; + +public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepositoryWrapper repositoryWrapper) + : IRequestHandler +{ + public async Task Handle(CreateShiftPlanNotificationsCommand request, CancellationToken cancellationToken) + { + if (request.InStart) + { + await mediator.Send(new SetShiftPlanNotificationScheduleCommand(request.ShiftPlanId), cancellationToken); + } + else + { + var shiftPlan = await repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.Id == request.ShiftPlanId) + .Select(ShiftPlanMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (shiftPlan == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "ShiftPlan not found in create shift plan notification"); + + + var shiftPlanUsers = await repositoryWrapper.SetRepository() + .TableNoTracking + .Where(f => f.ShiftPlanId == request.ShiftPlanId) + .ToListAsync(cancellationToken); + + foreach (var shiftPlanUser in shiftPlanUsers) + { + var completeShiftMessageForUser = $""; + await mediator.Send( new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken); + } + + } + return true; + } +} \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs new file mode 100644 index 0000000..ceb4416 --- /dev/null +++ b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs @@ -0,0 +1,70 @@ +using Brizco.Core.QuartzServices.Commands; +using Quartz; + +namespace Brizco.Core.QuartzServices.Handlers; + +public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler) : IRequestHandler +{ + public async Task Handle(SetShiftPlanNotificationScheduleCommand request, CancellationToken cancellationToken) + { + var shiftPlan = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(sp => sp.Id == request.ShiftPlanId, cancellationToken); + if (shiftPlan == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "ShiftPlan not found in set schedule"); + + var shift = await repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.Id == shiftPlan.ShiftId, cancellationToken); + + if(shift == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Shift not found in set schedule"); + + var shiftPlanStartAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.StartAt.Hours,shift.StartAt.Minutes,shift.StartAt.Seconds)).ToUniversalTime(); + var shiftPlanEndAt = (new DateTime(shiftPlan.PlanFor.Year, shiftPlan.PlanFor.Month, shiftPlan.PlanFor.Day, shift.EndAt.Hours, shift.EndAt.Minutes, shift.EndAt.Seconds)).ToUniversalTime(); + + var startTimeOffset = new DateTimeOffset(shiftPlanStartAt.Year, shiftPlanStartAt.Month, shiftPlanStartAt.Day, shiftPlanStartAt.Hour, + shiftPlanStartAt.Minute, shiftPlanStartAt.Second, TimeSpan.Zero); + var endTimeOffset = new DateTimeOffset(shiftPlanEndAt.Year, shiftPlanEndAt.Month, shiftPlanEndAt.Day, shiftPlanEndAt.Hour, + shiftPlanEndAt.Minute, shiftPlanEndAt.Second, TimeSpan.Zero); + + + + IJobDetail beforeEndShift30Min = JobBuilder.Create() + .WithIdentity(ShiftPlanNotifyType.BeforeEndShift30Min.ToString(), shiftPlan.Id.ToString()) + .Build(); + ITrigger beforeEndShift30MinTrigger = TriggerBuilder.Create() + .WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString()) + .WithSimpleSchedule(x => x.WithRepeatCount(0)) + .StartAt(endTimeOffset.AddMinutes(-40)) + .Build(); + + + IJobDetail endOfShift = JobBuilder.Create() + .WithIdentity(ShiftPlanNotifyType.EndOfShift.ToString(), shiftPlan.Id.ToString()) + .Build(); + ITrigger endOfShiftTrigger = TriggerBuilder.Create() + .WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString()) + .WithSimpleSchedule(x => x.WithRepeatCount(0)) + .StartAt(endTimeOffset) + .Build(); + + + IJobDetail afterStartShift2Hour = JobBuilder.Create() + .WithIdentity(ShiftPlanNotifyType.AfterStartShift2Hour.ToString(), shiftPlan.Id.ToString()) + .Build(); + ITrigger afterStartShift2HourTrigger = TriggerBuilder.Create() + .WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString()) + .WithSimpleSchedule(x => x.WithRepeatCount(0)) + .StartAt(startTimeOffset.AddHours(2)) + .Build(); + + + await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken); + await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken); + await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken); + + + return true; + } +} \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/JobScheduler.cs b/Brizco.Core/QuartzServices/JobScheduler.cs index 63f7120..8254d3b 100644 --- a/Brizco.Core/QuartzServices/JobScheduler.cs +++ b/Brizco.Core/QuartzServices/JobScheduler.cs @@ -18,18 +18,7 @@ public class JobScheduler { _scheduler.Start(); - //IJobDetail job = JobBuilder.Create() - // .WithIdentity("NotificationJob", "notification") - // .Build(); - //ITrigger trigger = TriggerBuilder.Create() - // .WithIdentity("NotificationJobTrigger", "notification") - // .WithSimpleSchedule(x=>x.WithIntervalInHours(12)) - // .StartNow() - // .Build(); - //var offset = _scheduler.ScheduleJob(job, trigger); - - - //_logger.LogInformation($"======== NOTIFICATION Schedulers Set For {offset.Result.ToString()} IN {DateTime.Now.ToString()} ==========="); + _logger.LogInformation($"======== Scheduler Start ==========="); } } \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/NotificationScheduledJob.cs b/Brizco.Core/QuartzServices/NotificationScheduledJob.cs deleted file mode 100644 index b0fa9c7..0000000 --- a/Brizco.Core/QuartzServices/NotificationScheduledJob.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Brizco.Domain.Entities.Shifts; -using Microsoft.Extensions.Logging; -using Quartz; - -namespace Brizco.Core.QuartzServices; - -public class NotificationScheduledJob : IJob -{ - private readonly ILogger _logger; - private readonly IScheduler _scheduler; - private readonly IRepositoryWrapper _repositoryWrapper; - - public NotificationScheduledJob(ILogger logger,IScheduler scheduler,IRepositoryWrapper repositoryWrapper) - { - _logger = logger; - _scheduler = scheduler; - _repositoryWrapper = repositoryWrapper; - } - - public async Task Execute(IJobExecutionContext context) - { - var currentShiftPlans = await _repositoryWrapper.SetRepository() - .TableNoTracking - .Where(s => s.PlanFor.Date >= DateTime.Today.Date) - .ToListAsync(); - - IJobDetail job = JobBuilder.Create() - .WithIdentity("NotificationJob", "notification") - .Build(); - ITrigger trigger = TriggerBuilder.Create() - .WithIdentity("NotificationJobTrigger", "notification") - .StartNow() - .Build(); - var offset = _scheduler.ScheduleJob(job, trigger); - - _logger.LogInformation($"Notification Job Done At : {DateTime.Now}"); - } -} \ No newline at end of file diff --git a/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs new file mode 100644 index 0000000..cdc4da6 --- /dev/null +++ b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs @@ -0,0 +1,80 @@ +using Brizco.Domain.Entities.ShiftPlans; +using Brizco.Domain.Entities.Tasks; +using Microsoft.Extensions.Logging; +using Quartz; +using Task = System.Threading.Tasks.Task; + +namespace Brizco.Core.QuartzServices; + +public class ShiftPlanNotificationScheduledJob : IJob +{ + private readonly ILogger _logger; + private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IMediator _mediator; + + public ShiftPlanNotificationScheduledJob(ILogger logger,IRepositoryWrapper repositoryWrapper,IMediator mediator) + { + _logger = logger; + _repositoryWrapper = repositoryWrapper; + _mediator = mediator; + } + + public async Task Execute(IJobExecutionContext context) + { + try + { + var notifyType = (ShiftPlanNotifyType)int.Parse(context.JobDetail.Key.Name); + var shiftPlanId = Guid.Parse(context.JobDetail.Key.Group); + var shiftPlan = await _repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(f => f.Id == shiftPlanId); + if (shiftPlan == null) + throw new Exception("Shift plan not found"); + var shiftPlanUsers = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(f => f.ShiftPlanId == shiftPlanId) + .ToListAsync(); + var superVisorId = shiftPlan.SupervisorId; + switch (notifyType) + { + case ShiftPlanNotifyType.None: + return; + break; + case ShiftPlanNotifyType.BeforeEndShift30Min: + var activities = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(a => a.ShiftPlanId == shiftPlanId).ToListAsync(); + foreach (var shiftPlanUser in shiftPlanUsers) + { + var unDoneCount = activities.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); + if(unDoneCount == 0) + continue; + string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید ، نیم ساعت به پایان شیفت مانده است"; + await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); + } + break; + case ShiftPlanNotifyType.EndOfShift: + var activitiesEndShift = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(a => a.ShiftPlanId == shiftPlanId).ToListAsync(); + foreach (var shiftPlanUser in shiftPlanUsers) + { + var unDoneCount = activitiesEndShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); + if (unDoneCount == 0) + continue; + string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید"; + await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); + } + string superVisorAfterShiftMessage = $"سوپر وایزر محترم ، شیفت مورد نظر به پایان رسیده است ، لطفا فعالیت ها را رسیدگی کنید"; + await _mediator.Send(new CreateNotificationCommand(superVisorAfterShiftMessage, shiftPlan.SupervisorId, shiftPlan.ComplexId)); + break; + case ShiftPlanNotifyType.AfterStartShift2Hour: + + break; + default: + return; + } + } + catch (Exception e) + { + _logger.LogError(e.Message); + } + } +} \ No newline at end of file diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index 9f6ec27..97677fb 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -1,6 +1,6 @@  - + - + @@ -55,12 +55,10 @@ - - - + + - diff --git a/Brizco.Domain/CommandQueries/Commands/NotificationCommands.cs b/Brizco.Domain/CommandQueries/Commands/NotificationCommands.cs index 9c9a3bb..72df82e 100644 --- a/Brizco.Domain/CommandQueries/Commands/NotificationCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/NotificationCommands.cs @@ -1,4 +1,4 @@ namespace Brizco.Domain.CommandQueries.Commands; -public record CreateNotificationCommand(string Message,Guid UserId) : IRequest; +public record CreateNotificationCommand(string Message,Guid UserId,Guid ComplexId) : IRequest; public record ReadNotificationCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs index a146c6c..8dd6d8d 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -13,6 +13,7 @@ public class ShiftPlanSDto : BaseDto public int CompletePercent { get; set; } public string SupervisorFullName { get; set; } = string.Empty; public string CompleteDescription { get; set; } = string.Empty; + public Guid ComplexId { get; set; } public Guid ShiftId { get; set; } public string ShiftTitle { get; set; } = string.Empty; public TimeSpan StartAt { get; set; } diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs index bbbffb7..63da2a8 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanUserSDto.cs @@ -1,4 +1,4 @@ -using Brizco.Domain.Entities.Shifts; +using Brizco.Domain.Entities.ShiftPlans; namespace Brizco.Domain.Dtos.SmallDtos; diff --git a/Brizco.Domain/Entities/ShiftPlans/ShiftPlan.Aggregate.cs b/Brizco.Domain/Entities/ShiftPlans/ShiftPlan.Aggregate.cs new file mode 100644 index 0000000..5e6e4d8 --- /dev/null +++ b/Brizco.Domain/Entities/ShiftPlans/ShiftPlan.Aggregate.cs @@ -0,0 +1,17 @@ +namespace Brizco.Domain.Entities.ShiftPlans; +public partial class ShiftPlan +{ + public ShiftPlanUser AddUser(Guid positionId, Guid userId) + { + var planUser = new ShiftPlanUser(Id, positionId, userId); + Users.Add(planUser); + return planUser; + } + + public void CompletePlan(string completeDescription, int completePercent) + { + IsCompleted = true; + CompleteDescription = completeDescription; + CompletePercent = completePercent; + } +} \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shifts/ShiftPlan.cs b/Brizco.Domain/Entities/ShiftPlans/ShiftPlan.cs similarity index 92% rename from Brizco.Domain/Entities/Shifts/ShiftPlan.cs rename to Brizco.Domain/Entities/ShiftPlans/ShiftPlan.cs index 50036fc..5642496 100644 --- a/Brizco.Domain/Entities/Shifts/ShiftPlan.cs +++ b/Brizco.Domain/Entities/ShiftPlans/ShiftPlan.cs @@ -1,7 +1,5 @@ -using Brizco.Domain.Entities.Routines; -using Brizco.Domain.Entities.Users; - -namespace Brizco.Domain.Entities.Shifts; + +namespace Brizco.Domain.Entities.ShiftPlans; [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)] @@ -25,6 +23,7 @@ public partial class ShiftPlan : ApiEntity public DateTime PlanFor { get; internal set; } public bool IsCompleted { get; internal set; } + public bool IsScheduled { get; internal set; } public int CompletePercent { get; internal set; } public string CompleteDescription { get; internal set; } = string.Empty; diff --git a/Brizco.Domain/Entities/Shifts/ShiftPlanUser.cs b/Brizco.Domain/Entities/ShiftPlans/ShiftPlanUser.cs similarity index 81% rename from Brizco.Domain/Entities/Shifts/ShiftPlanUser.cs rename to Brizco.Domain/Entities/ShiftPlans/ShiftPlanUser.cs index c9b30bb..751f9f1 100644 --- a/Brizco.Domain/Entities/Shifts/ShiftPlanUser.cs +++ b/Brizco.Domain/Entities/ShiftPlans/ShiftPlanUser.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Users; - -namespace Brizco.Domain.Entities.Shifts; +namespace Brizco.Domain.Entities.ShiftPlans; [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] @@ -8,10 +6,10 @@ public class ShiftPlanUser : ApiEntity { public ShiftPlanUser() { - + } - public ShiftPlanUser(Guid shiftPlanId,Guid positionId, Guid userId) + public ShiftPlanUser(Guid shiftPlanId, Guid positionId, Guid userId) { ShiftPlanId = shiftPlanId; PositionId = positionId; diff --git a/Brizco.Domain/Entities/Shifts/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shifts/Aggregate.Shift.cs index e7f9322..9ea0495 100644 --- a/Brizco.Domain/Entities/Shifts/Aggregate.Shift.cs +++ b/Brizco.Domain/Entities/Shifts/Aggregate.Shift.cs @@ -26,20 +26,3 @@ public partial class Shift return routine; } } - -public partial class ShiftPlan -{ - public ShiftPlanUser AddUser(Guid positionId,Guid userId) - { - var planUser = new ShiftPlanUser(Id , positionId, userId); - Users.Add(planUser); - return planUser; - } - - public void CompletePlan(string completeDescription,int completePercent) - { - IsCompleted = true; - CompleteDescription = completeDescription; - CompletePercent = completePercent; - } -} \ No newline at end of file diff --git a/Brizco.Domain/Enums/ShiftPlanNotifyType.cs b/Brizco.Domain/Enums/ShiftPlanNotifyType.cs new file mode 100644 index 0000000..5df1a0d --- /dev/null +++ b/Brizco.Domain/Enums/ShiftPlanNotifyType.cs @@ -0,0 +1,9 @@ +namespace Brizco.Domain.Enums; + +public enum ShiftPlanNotifyType +{ + None = 0, + BeforeEndShift30Min = 1, + EndOfShift = 2, + AfterStartShift2Hour = 3 +} \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs index 823309d..99eb127 100644 --- a/Brizco.Domain/Mappers/ActivityMapper.g.cs +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -2,7 +2,7 @@ using System; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargeDtos; using Brizco.Domain.Dtos.SmallDtos; -using Brizco.Domain.Entities.Shifts; +using Brizco.Domain.Entities.ShiftPlans; using Brizco.Domain.Entities.Tasks; using Brizco.Domain.Entities.Users; using Mapster.Models; diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index 189c6f9..cb227fd 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -6,6 +6,7 @@ using Brizco.Domain.Dtos.LargeDtos; using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Complexes; using Brizco.Domain.Entities.Routines; +using Brizco.Domain.Entities.ShiftPlans; using Brizco.Domain.Entities.Shifts; using Brizco.Domain.Entities.Users; using Mapster.Models; diff --git a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs index 483ad6f..3d080ff 100644 --- a/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanUserMapper.g.cs @@ -2,7 +2,7 @@ using System; using System.Linq.Expressions; using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Shifts; +using Brizco.Domain.Entities.ShiftPlans; using Brizco.Domain.Entities.Users; using Mapster.Models; diff --git a/Brizco.Domain/Mappers/TaskMapper.g.cs b/Brizco.Domain/Mappers/TaskMapper.g.cs index 2f6020b..f089fba 100644 --- a/Brizco.Domain/Mappers/TaskMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskMapper.g.cs @@ -9,7 +9,6 @@ using Brizco.Domain.Entities.Complexes; using Brizco.Domain.Entities.Shifts; using Brizco.Domain.Entities.Tasks; using Mapster.Models; -using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Domain.Mappers { diff --git a/Brizco.Domain/Mappers/TaskPositionMapper.g.cs b/Brizco.Domain/Mappers/TaskPositionMapper.g.cs index d657ca0..b703d2c 100644 --- a/Brizco.Domain/Mappers/TaskPositionMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskPositionMapper.g.cs @@ -4,7 +4,6 @@ using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Complexes; using Brizco.Domain.Entities.Tasks; using Mapster.Models; -using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Domain.Mappers { diff --git a/Brizco.Domain/Mappers/TaskShiftMapper.g.cs b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs index 372eaad..7ae1787 100644 --- a/Brizco.Domain/Mappers/TaskShiftMapper.g.cs +++ b/Brizco.Domain/Mappers/TaskShiftMapper.g.cs @@ -4,7 +4,6 @@ using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Shifts; using Brizco.Domain.Entities.Tasks; using Mapster.Models; -using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Domain.Mappers { diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index 587ec77..90b8624 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -1,6 +1,6 @@ using Brizco.Domain.Dtos.LargeDtos; using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Shifts; +using Brizco.Domain.Entities.ShiftPlans; using Brizco.Domain.Entities.Tasks; using MD.PersianDateTime.Standard; using Task = Brizco.Domain.Entities.Tasks.Task; diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj index 7726157..4f55406 100644 --- a/Brizco.Repository/Brizco.Repository.csproj +++ b/Brizco.Repository/Brizco.Repository.csproj @@ -46,8 +46,12 @@ - + + + + + diff --git a/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs b/Brizco.Repository/Handlers/Activities/CreateActivityCommandHandler.cs similarity index 95% rename from Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs rename to Brizco.Repository/Handlers/Activities/CreateActivityCommandHandler.cs index 2b600e2..4961f31 100644 --- a/Brizco.Repository/Handlers/Activity/CreateActivityCommandHandler.cs +++ b/Brizco.Repository/Handlers/Activities/CreateActivityCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class CreateActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs b/Brizco.Repository/Handlers/Activities/DeleteActivityCommandHandler.cs similarity index 95% rename from Brizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs rename to Brizco.Repository/Handlers/Activities/DeleteActivityCommandHandler.cs index 62e7e10..147daca 100644 --- a/Brizco.Repository/Handlers/Activity/DeleteActivityCommandHandler.cs +++ b/Brizco.Repository/Handlers/Activities/DeleteActivityCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class DeleteActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs similarity index 98% rename from Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs rename to Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs index 85d0b82..7ba6ee7 100644 --- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class GetActivitiesQueryHandler : IRequestHandler> { diff --git a/Brizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetActivityQueryHandler.cs similarity index 90% rename from Brizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs rename to Brizco.Repository/Handlers/Activities/GetActivityQueryHandler.cs index ece9288..777626b 100644 --- a/Brizco.Repository/Handlers/Activity/GetActivityQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activities/GetActivityQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class GetActivityQueryHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Activity/GetShiftPlanActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs similarity index 93% rename from Brizco.Repository/Handlers/Activity/GetShiftPlanActivitiesQueryHandler.cs rename to Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs index 92f5443..e76acbd 100644 --- a/Brizco.Repository/Handlers/Activity/GetShiftPlanActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class GetShiftPlanActivitiesQueryHandler : IRequestHandler> { diff --git a/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs b/Brizco.Repository/Handlers/Activities/UpdateActivityCommandHandler.cs similarity index 97% rename from Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs rename to Brizco.Repository/Handlers/Activities/UpdateActivityCommandHandler.cs index 5d3b586..104119f 100644 --- a/Brizco.Repository/Handlers/Activity/UpdateActivityCommandHandler.cs +++ b/Brizco.Repository/Handlers/Activities/UpdateActivityCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Activity; +namespace Brizco.Repository.Handlers.Activities; public class UpdateActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Complex/CreateComplexCommandHandler.cs b/Brizco.Repository/Handlers/Complexes/CreateComplexCommandHandler.cs similarity index 78% rename from Brizco.Repository/Handlers/Complex/CreateComplexCommandHandler.cs rename to Brizco.Repository/Handlers/Complexes/CreateComplexCommandHandler.cs index eec4f07..7e0cf8d 100644 --- a/Brizco.Repository/Handlers/Complex/CreateComplexCommandHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/CreateComplexCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class CreateComplexCommandHandler : IRequestHandler { @@ -16,8 +16,8 @@ public class CreateComplexCommandHandler : IRequestHandler().Add(complex); + var complex = Complex.Create(request.Name, request.Address, request.SupportPhone); + _repositoryWrapper.SetRepository().Add(complex); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); return complex.AdaptToSDto(); diff --git a/Brizco.Repository/Handlers/Complex/CreateComplexUserCommandHandler.cs b/Brizco.Repository/Handlers/Complexes/CreateComplexUserCommandHandler.cs similarity index 92% rename from Brizco.Repository/Handlers/Complex/CreateComplexUserCommandHandler.cs rename to Brizco.Repository/Handlers/Complexes/CreateComplexUserCommandHandler.cs index a0325f9..78458a0 100644 --- a/Brizco.Repository/Handlers/Complex/CreateComplexUserCommandHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/CreateComplexUserCommandHandler.cs @@ -1,8 +1,4 @@ -using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Users; -using Microsoft.AspNetCore.Identity; - -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class CreateComplexUserCommandHandler : IRequestHandler { @@ -27,7 +23,7 @@ public class CreateComplexUserCommandHandler : IRequestHandler().TableNoTracking + var complex = await _repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(c => c.Id == request.ComplexId, cancellationToken); if (complex == null) throw new AppException("Complex not found", ApiResultStatusCode.NotFound); diff --git a/Brizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs b/Brizco.Repository/Handlers/Complexes/DeleteComplexCommandHandler.cs similarity index 82% rename from Brizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs rename to Brizco.Repository/Handlers/Complexes/DeleteComplexCommandHandler.cs index b871319..3f8f5bc 100644 --- a/Brizco.Repository/Handlers/Complex/DeleteComplexCommandHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/DeleteComplexCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class DeleteComplexCommandHandler : IRequestHandler { @@ -13,12 +13,12 @@ public class DeleteComplexCommandHandler : IRequestHandler() + 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() + _repositoryWrapper.SetRepository() .Delete(task); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Complex/DeleteComplexUserCommandHandler.cs b/Brizco.Repository/Handlers/Complexes/DeleteComplexUserCommandHandler.cs similarity index 95% rename from Brizco.Repository/Handlers/Complex/DeleteComplexUserCommandHandler.cs rename to Brizco.Repository/Handlers/Complexes/DeleteComplexUserCommandHandler.cs index b688c7c..1998ba0 100644 --- a/Brizco.Repository/Handlers/Complex/DeleteComplexUserCommandHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/DeleteComplexUserCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Complexes; - -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class DeleteComplexUserCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs b/Brizco.Repository/Handlers/Complexes/GetComplexQueryHandler.cs similarity index 82% rename from Brizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs rename to Brizco.Repository/Handlers/Complexes/GetComplexQueryHandler.cs index 51bd4d2..37f5f1f 100644 --- a/Brizco.Repository/Handlers/Complex/GetComplexQueryHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/GetComplexQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class GetComplexQueryHandler : IRequestHandler { @@ -11,7 +11,7 @@ public class GetComplexQueryHandler : IRequestHandler Handle(GetComplexQuery request, CancellationToken cancellationToken) { - var complex = await _repositoryWrapper.SetRepository() + var complex = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(s => s.Id == request.Id) .Select(ComplexMapper.ProjectToSDto) diff --git a/Brizco.Repository/Handlers/Complex/GetComplexUsersQueryHandler.cs b/Brizco.Repository/Handlers/Complexes/GetComplexUsersQueryHandler.cs similarity index 92% rename from Brizco.Repository/Handlers/Complex/GetComplexUsersQueryHandler.cs rename to Brizco.Repository/Handlers/Complexes/GetComplexUsersQueryHandler.cs index faa5337..27480fa 100644 --- a/Brizco.Repository/Handlers/Complex/GetComplexUsersQueryHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/GetComplexUsersQueryHandler.cs @@ -1,8 +1,6 @@ -using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Users; -using Microsoft.IdentityModel.Tokens; +using Microsoft.IdentityModel.Tokens; -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class GetComplexUsersQueryHandler : IRequestHandler> { diff --git a/Brizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs b/Brizco.Repository/Handlers/Complexes/GetComplexesQueryHandler.cs similarity index 79% rename from Brizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs rename to Brizco.Repository/Handlers/Complexes/GetComplexesQueryHandler.cs index 7022a1b..4de6d06 100644 --- a/Brizco.Repository/Handlers/Complex/GetComplexesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/GetComplexesQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class GetComplexesQueryHandler : IRequestHandler> { @@ -10,7 +10,7 @@ public class GetComplexesQueryHandler : IRequestHandler> Handle(GetComplexesQuery request, CancellationToken cancellationToken) { - var tasks = await _repositoryWrapper.SetRepository().TableNoTracking + var tasks = await _repositoryWrapper.SetRepository().TableNoTracking .OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) .Select(ComplexMapper.ProjectToSDto) diff --git a/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs b/Brizco.Repository/Handlers/Complexes/UpdateComplexUserCommandHandler.cs similarity index 95% rename from Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs rename to Brizco.Repository/Handlers/Complexes/UpdateComplexUserCommandHandler.cs index 04bfef3..20aef51 100644 --- a/Brizco.Repository/Handlers/Complex/UpdateComplexUserCommandHandler.cs +++ b/Brizco.Repository/Handlers/Complexes/UpdateComplexUserCommandHandler.cs @@ -1,8 +1,4 @@ -using Brizco.Domain.Entities.Complexes; -using Brizco.Domain.Entities.Users; -using StackExchange.Redis; - -namespace Brizco.Repository.Handlers.Complex; +namespace Brizco.Repository.Handlers.Complexes; public class UpdateComplexUserCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Positions/CreatePositionCommandHandler.cs similarity index 88% rename from Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs rename to Brizco.Repository/Handlers/Positions/CreatePositionCommandHandler.cs index 792af42..a219f19 100644 --- a/Brizco.Repository/Handlers/Position/CreatePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Positions/CreatePositionCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Position; +namespace Brizco.Repository.Handlers.Positions; public class CreatePositionCommandHandler : IRequestHandler { @@ -21,7 +21,7 @@ public class CreatePositionCommandHandler : IRequestHandlerentity.AddPermission(f)); - _repositoryWrapper.SetRepository().Add(entity); + _repositoryWrapper.SetRepository().Add(entity); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); return entity.AdaptToSDto(); diff --git a/Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs b/Brizco.Repository/Handlers/Positions/DeletePositionCommandHandler.cs similarity index 76% rename from Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs rename to Brizco.Repository/Handlers/Positions/DeletePositionCommandHandler.cs index 9996a47..3aaf78b 100644 --- a/Brizco.Repository/Handlers/Position/DeletePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Positions/DeletePositionCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Position; +namespace Brizco.Repository.Handlers.Positions; public class DeletePositionCommandHandler : IRequestHandler { @@ -10,12 +10,12 @@ public class DeletePositionCommandHandler : IRequestHandler Handle(DeletePositionCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shift == null) throw new AppException("Postion not found", ApiResultStatusCode.NotFound); - _repositoryWrapper.SetRepository() + _repositoryWrapper.SetRepository() .Delete(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs b/Brizco.Repository/Handlers/Positions/GetPositionQueryHandler.cs similarity index 79% rename from Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs rename to Brizco.Repository/Handlers/Positions/GetPositionQueryHandler.cs index acd96e3..baab437 100644 --- a/Brizco.Repository/Handlers/Position/GetPositionQueryHandler.cs +++ b/Brizco.Repository/Handlers/Positions/GetPositionQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Position; +namespace Brizco.Repository.Handlers.Positions; public class GetPositionQueryHandler : IRequestHandler { @@ -12,7 +10,7 @@ public class GetPositionQueryHandler : IRequestHandler Handle(GetPositionQuery request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(s => s.Id == request.Id) .Select(PositionMapper.ProjectToLDto) diff --git a/Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs b/Brizco.Repository/Handlers/Positions/GetPositionsQueryHandler.cs similarity index 87% rename from Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs rename to Brizco.Repository/Handlers/Positions/GetPositionsQueryHandler.cs index 32d7cba..2f51abd 100644 --- a/Brizco.Repository/Handlers/Position/GetPositionsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Positions/GetPositionsQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Position; +namespace Brizco.Repository.Handlers.Positions; public class GetPositionsQueryHandler : IRequestHandler> { @@ -18,7 +18,7 @@ public class GetPositionsQueryHandler : IRequestHandler().TableNoTracking + var shifts = await _repositoryWrapper.SetRepository().TableNoTracking .Where(p=>p.ComplexId==complexId) .OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) diff --git a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs b/Brizco.Repository/Handlers/Positions/UpdatePositionCommandHandler.cs similarity index 85% rename from Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs rename to Brizco.Repository/Handlers/Positions/UpdatePositionCommandHandler.cs index d6a17c4..03e7341 100644 --- a/Brizco.Repository/Handlers/Position/UpdatePositionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Positions/UpdatePositionCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Complexes; - -namespace Brizco.Repository.Handlers.Position; +namespace Brizco.Repository.Handlers.Positions; public class UpdatePositionCommandHandler : IRequestHandler { @@ -15,7 +13,7 @@ public class UpdatePositionCommandHandler : IRequestHandler Handle(UpdatePositionCommand request, CancellationToken cancellationToken) { - var ent = await _repositoryWrapper.SetRepository() + var ent = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (ent == null) throw new AppException("Postion not found", ApiResultStatusCode.NotFound); @@ -25,7 +23,7 @@ public class UpdatePositionCommandHandler : IRequestHandler !permissionsDb.Select(d => d.Permission).Contains(p))) newPosition.AddPermission(permission); - _repositoryWrapper.SetRepository() + _repositoryWrapper.SetRepository() .Update(newPosition); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routines/CreateRoutineCommandHandler.cs similarity index 96% rename from Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs rename to Brizco.Repository/Handlers/Routines/CreateRoutineCommandHandler.cs index 0972998..0f87aba 100644 --- a/Brizco.Repository/Handlers/Routine/CreateRoutineCommandHandler.cs +++ b/Brizco.Repository/Handlers/Routines/CreateRoutineCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class CreateRoutineCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routines/DeleteRoutineCommandHandler.cs similarity index 94% rename from Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs rename to Brizco.Repository/Handlers/Routines/DeleteRoutineCommandHandler.cs index ce1c45f..5ae013a 100644 --- a/Brizco.Repository/Handlers/Routine/DeleteRoutineCommandHandler.cs +++ b/Brizco.Repository/Handlers/Routines/DeleteRoutineCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class DeleteRoutineCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs b/Brizco.Repository/Handlers/Routines/GetRoutineQueryHandler.cs similarity index 94% rename from Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs rename to Brizco.Repository/Handlers/Routines/GetRoutineQueryHandler.cs index e77e5d2..f0afc7d 100644 --- a/Brizco.Repository/Handlers/Routine/GetRoutineQueryHandler.cs +++ b/Brizco.Repository/Handlers/Routines/GetRoutineQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class GetRoutineQueryHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Routines/GetRoutineShiftsQueryHandler.cs similarity index 90% rename from Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs rename to Brizco.Repository/Handlers/Routines/GetRoutineShiftsQueryHandler.cs index 279dacf..e85de3c 100644 --- a/Brizco.Repository/Handlers/Routine/GetRoutineShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Routines/GetRoutineShiftsQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Shifts; - -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class GetRoutineShiftsQueryHandler : IRequestHandler> { @@ -21,7 +19,7 @@ public class GetRoutineShiftsQueryHandler : IRequestHandler() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(s => s.Id == shiftRoutine.ShiftId) .Select(ShiftMapper.ProjectToSDto) @@ -48,7 +46,7 @@ public class GetRoutineShiftsQueryHandler : IRequestHandler() + var existedShiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken); shift.IsCompleted = existedShiftPlan?.IsCompleted ?? false; diff --git a/Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs b/Brizco.Repository/Handlers/Routines/GetRoutinesQueryHandler.cs similarity index 96% rename from Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs rename to Brizco.Repository/Handlers/Routines/GetRoutinesQueryHandler.cs index 9c7daf7..8b93193 100644 --- a/Brizco.Repository/Handlers/Routine/GetRoutinesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Routines/GetRoutinesQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class GetRoutinesQueryHandler : IRequestHandler> { diff --git a/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs b/Brizco.Repository/Handlers/Routines/UpdateRoutineCommandHandler.cs similarity index 96% rename from Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs rename to Brizco.Repository/Handlers/Routines/UpdateRoutineCommandHandler.cs index 6f9da84..4f4057d 100644 --- a/Brizco.Repository/Handlers/Routine/UpdateRoutineCommandHandler.cs +++ b/Brizco.Repository/Handlers/Routines/UpdateRoutineCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Routine; +namespace Brizco.Repository.Handlers.Routines; public class UpdateRoutineCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs b/Brizco.Repository/Handlers/Sections/CreateSectionCommandHandler.cs similarity index 87% rename from Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs rename to Brizco.Repository/Handlers/Sections/CreateSectionCommandHandler.cs index b5b702a..43a8952 100644 --- a/Brizco.Repository/Handlers/Section/CreateSectionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Sections/CreateSectionCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Section; +namespace Brizco.Repository.Handlers.Sections; public class CreateSectionCommandHandler : IRequestHandler { @@ -21,12 +21,12 @@ public class CreateSectionCommandHandler : IRequestHandler().Add(entity); + _repositoryWrapper.SetRepository
().Add(entity); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); return entity.AdaptToSDto(); diff --git a/Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs b/Brizco.Repository/Handlers/Sections/DeleteSectionCommandHandler.cs similarity index 76% rename from Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs rename to Brizco.Repository/Handlers/Sections/DeleteSectionCommandHandler.cs index ab68fb4..2d91f9f 100644 --- a/Brizco.Repository/Handlers/Section/DeleteSectionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Sections/DeleteSectionCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Section; +namespace Brizco.Repository.Handlers.Sections; public class DeleteSectionCommandHandler : IRequestHandler { @@ -10,20 +10,20 @@ public class DeleteSectionCommandHandler : IRequestHandler Handle(DeleteSectionCommand request, CancellationToken cancellationToken) { - var section = await _repositoryWrapper.SetRepository() + var section = await _repositoryWrapper.SetRepository
() .TableNoTracking .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (section == null) throw new AppException("Section not found", ApiResultStatusCode.NotFound); - var positions = await _repositoryWrapper.SetRepository() + var positions = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(p => p.SectionId == section.Id) .CountAsync(cancellationToken); if (positions > 0) throw new AppException("این سکشن پوزیشن فعال دارد ، نخست پوزیشن های سکشن را حذف کرده یا منتقل کنید"); - _repositoryWrapper.SetRepository() + _repositoryWrapper.SetRepository
() .Delete(section); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs b/Brizco.Repository/Handlers/Sections/GetSectionQueryHandler.cs similarity index 79% rename from Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs rename to Brizco.Repository/Handlers/Sections/GetSectionQueryHandler.cs index 55d1c24..4a862b0 100644 --- a/Brizco.Repository/Handlers/Section/GetSectionQueryHandler.cs +++ b/Brizco.Repository/Handlers/Sections/GetSectionQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Section; +namespace Brizco.Repository.Handlers.Sections; public class GetSectionQueryHandler : IRequestHandler { @@ -12,7 +10,7 @@ public class GetSectionQueryHandler : IRequestHandler Handle(GetSectionQuery request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository
() .TableNoTracking .Where(s => s.Id == request.Id) .Select(SectionMapper.ProjectToLDto) diff --git a/Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs b/Brizco.Repository/Handlers/Sections/GetSectionsQueryHandler.cs similarity index 87% rename from Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs rename to Brizco.Repository/Handlers/Sections/GetSectionsQueryHandler.cs index 0c91ce6..d6c595a 100644 --- a/Brizco.Repository/Handlers/Section/GetSectionsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Sections/GetSectionsQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Section; +namespace Brizco.Repository.Handlers.Sections; public class GetSectionsQueryHandler : IRequestHandler> { @@ -17,7 +17,7 @@ public class GetSectionsQueryHandler : IRequestHandler().TableNoTracking + var shifts = await _repositoryWrapper.SetRepository
().TableNoTracking .Where(s=>s.ComplexId==complexId) .OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) diff --git a/Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs b/Brizco.Repository/Handlers/Sections/UpdateSectionCommandHandler.cs similarity index 80% rename from Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs rename to Brizco.Repository/Handlers/Sections/UpdateSectionCommandHandler.cs index 879db42..30e3483 100644 --- a/Brizco.Repository/Handlers/Section/UpdateSectionCommandHandler.cs +++ b/Brizco.Repository/Handlers/Sections/UpdateSectionCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Section; +namespace Brizco.Repository.Handlers.Sections; public class UpdateSectionCommandHandler : IRequestHandler { @@ -13,7 +13,7 @@ public class UpdateSectionCommandHandler : IRequestHandler Handle(UpdateSectionCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository
() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shift == null) throw new AppException("Section not found", ApiResultStatusCode.NotFound); @@ -23,13 +23,13 @@ public class UpdateSectionCommandHandler : IRequestHandler() + _repositoryWrapper.SetRepository
() .Update(newSection); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/CreateShiftPlanCommandHandler.cs similarity index 87% rename from Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs rename to Brizco.Repository/Handlers/ShiftPlans/CreateShiftPlanCommandHandler.cs index a41e586..9b13603 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/CreateShiftPlanCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.ShiftPlan; +namespace Brizco.Repository.Handlers.ShiftPlans; public class CreateShiftPlanCommandHandler : IRequestHandler { @@ -14,14 +12,13 @@ public class CreateShiftPlanCommandHandler : IRequestHandler Handle(CreateShiftPlanCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.Id == request.ShiftId, cancellationToken); - if (shift == null) throw new AppException("Shift not found", ApiResultStatusCode.NotFound); var planFor = DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate); - var existedShiftPlan = await _repositoryWrapper.SetRepository() + var existedShiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.ShiftId == request.ShiftId && s.PlanFor.Date == planFor.Date, cancellationToken); @@ -42,7 +39,7 @@ public class CreateShiftPlanCommandHandler : IRequestHandler().Add(shiftPlan); + _repositoryWrapper.SetRepository().Add(shiftPlan); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); return shiftPlan.AdaptToLDto(); diff --git a/Brizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/DeleteShiftPlanCommandHandler.cs similarity index 76% rename from Brizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs rename to Brizco.Repository/Handlers/ShiftPlans/DeleteShiftPlanCommandHandler.cs index 16d8dfc..55d8811 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/DeleteShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/DeleteShiftPlanCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.ShiftPlan; +namespace Brizco.Repository.Handlers.ShiftPlans; public class DeleteShiftPlanCommandHandler : IRequestHandler { @@ -11,13 +11,13 @@ public class DeleteShiftPlanCommandHandler : IRequestHandler Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken) { - var shiftPlan = await _repositoryWrapper.SetRepository() + var shiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken); if (shiftPlan == null) throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); - _repositoryWrapper.SetRepository() + _repositoryWrapper.SetRepository() .Delete(shiftPlan); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlanQueryHandler.cs similarity index 79% rename from Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs rename to Brizco.Repository/Handlers/ShiftPlans/GetShiftPlanQueryHandler.cs index 4a3bfac..8174bcc 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlanQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlanQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.ShiftPlan; +namespace Brizco.Repository.Handlers.ShiftPlans; public class GetShiftPlanQueryHandler : IRequestHandler { @@ -12,7 +10,7 @@ public class GetShiftPlanQueryHandler : IRequestHandler Handle(GetShiftPlanQuery request, CancellationToken cancellationToken) { - var shiftPlan = await _repositoryWrapper.SetRepository() + var shiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(s => s.Id == request.Id) .Select(ShiftPlanMapper.ProjectToLDto) diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs similarity index 97% rename from Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs rename to Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs index 9b7db0c..df074bf 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs @@ -1,7 +1,6 @@ -using Brizco.Domain.Entities.Shifts; -using MD.PersianDateTime.Standard; +using MD.PersianDateTime.Standard; -namespace Brizco.Repository.Handlers.ShiftPlan; +namespace Brizco.Repository.Handlers.ShiftPlans; public class GetShiftPlansQueryHandler : IRequestHandler> { @@ -20,7 +19,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler baseQuery = _repositoryWrapper.SetRepository() + IQueryable baseQuery = _repositoryWrapper.SetRepository() .TableNoTracking .OrderByDescending(s => s.CreatedAt) .Where(s => s.ComplexId == complexId); diff --git a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/UpdateShiftPlanCommandHandler.cs similarity index 85% rename from Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs rename to Brizco.Repository/Handlers/ShiftPlans/UpdateShiftPlanCommandHandler.cs index 902848f..9ce2c9f 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/UpdateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/UpdateShiftPlanCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Shifts; - -namespace Brizco.Repository.Handlers.ShiftPlan; +namespace Brizco.Repository.Handlers.ShiftPlans; public class UpdateShiftPlanCommandHandler : IRequestHandler { @@ -13,13 +11,13 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler Handle(UpdateShiftPlanCommand request, CancellationToken cancellationToken) { - var shiftPlan = await _repositoryWrapper.SetRepository() + var shiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id,cancellationToken); if (shiftPlan == null) throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.ShiftId, cancellationToken); if (shift == null) @@ -50,7 +48,7 @@ public class UpdateShiftPlanCommandHandler : IRequestHandler() + _repositoryWrapper.SetRepository() .Update(newPlan); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shifts/CreateShiftCommandHandler.cs similarity index 90% rename from Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs rename to Brizco.Repository/Handlers/Shifts/CreateShiftCommandHandler.cs index a1d0f69..18bef57 100644 --- a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/CreateShiftCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shifts; public class CreateShiftCommandHandler : IRequestHandler { @@ -21,7 +21,7 @@ public class CreateShiftCommandHandler : IRequestHandlershift.AddRoutine(r)); - _repositoryWrapper.SetRepository().Add(shift); + _repositoryWrapper.SetRepository().Add(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); return shift.AdaptToSDto(); diff --git a/Brizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shifts/DeleteShiftCommandHandler.cs similarity index 77% rename from Brizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs rename to Brizco.Repository/Handlers/Shifts/DeleteShiftCommandHandler.cs index ab039e2..18800fc 100644 --- a/Brizco.Repository/Handlers/Shift/DeleteShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/DeleteShiftCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shifts; public class DeletePositionCommandHandler : IRequestHandler { @@ -10,12 +10,12 @@ public class DeletePositionCommandHandler : IRequestHandler Handle(DeleteShiftCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shift == null) throw new AppException("Routine not found", ApiResultStatusCode.NotFound); - _repositoryWrapper.SetRepository() + _repositoryWrapper.SetRepository() .Delete(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs b/Brizco.Repository/Handlers/Shifts/GetShiftQueryHandler.cs similarity index 84% rename from Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs rename to Brizco.Repository/Handlers/Shifts/GetShiftQueryHandler.cs index 7fba182..b5390d3 100644 --- a/Brizco.Repository/Handlers/Shift/GetShiftQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/GetShiftQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shifts; public class GetShiftPlanQueryHandler : IRequestHandler { @@ -12,7 +10,7 @@ public class GetShiftPlanQueryHandler : IRequestHandler Handle(GetShiftQuery request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(s => s.Id == request.Id) .Select(ShiftMapper.ProjectToLDto) diff --git a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs similarity index 91% rename from Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs rename to Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs index fe332b6..4a6d024 100644 --- a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs @@ -1,8 +1,4 @@ -using Brizco.Domain.Entities.Shifts; -using Brizco.Domain.Entities.Users; -using Guid = System.Guid; - -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shifts; public class GetShiftPlansQueryHandler : IRequestHandler> { @@ -29,14 +25,15 @@ public class GetShiftPlansQueryHandler : IRequestHandler().Entities - join shift in _repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id + join shift in _repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId + orderby shift.StartAt descending select shift; shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken); foreach (var shift in shifts) { - var existedShiftPlan = await _repositoryWrapper.SetRepository() + var existedShiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken); if(existedShiftPlan == null) @@ -66,7 +63,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler() + var existedSupervisorShiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date && s.SupervisorId == userId, cancellationToken); shift.IsCompleted = existedSupervisorShiftPlan?.IsCompleted ?? false; @@ -87,9 +84,9 @@ public class GetShiftPlansQueryHandler : IRequestHandler().TableNoTracking + shifts = await _repositoryWrapper.SetRepository().TableNoTracking .Where(s => s.ComplexId == complexId) - .OrderByDescending(s => s.CreatedAt) + .OrderByDescending(s => s.StartAt) .Skip(request.Page * 15).Take(15) .Select(ShiftMapper.ProjectToSDto) .ToListAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shifts/UpdateShiftCommandHandler.cs similarity index 90% rename from Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs rename to Brizco.Repository/Handlers/Shifts/UpdateShiftCommandHandler.cs index dea75fb..a57b5e1 100644 --- a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/UpdateShiftCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Entities.Shifts; - -namespace Brizco.Repository.Handlers.Shift; +namespace Brizco.Repository.Handlers.Shifts; public class UpdatePositionCommandHandler : IRequestHandler { @@ -15,7 +13,7 @@ public class UpdatePositionCommandHandler : IRequestHandler Handle(UpdateShiftCommand request, CancellationToken cancellationToken) { - var shift = await _repositoryWrapper.SetRepository() + var shift = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shift == null) throw new AppException("Shift not found", ApiResultStatusCode.NotFound); @@ -25,7 +23,7 @@ public class UpdatePositionCommandHandler : IRequestHandler() + _repositoryWrapper.SetRepository() .Update(newShift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs b/Brizco.Repository/Handlers/Tasks/CreateTaskCommandHandler.cs similarity index 96% rename from Brizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs rename to Brizco.Repository/Handlers/Tasks/CreateTaskCommandHandler.cs index 83e104f..39bc4b8 100644 --- a/Brizco.Repository/Handlers/Task/CreateTaskCommandHandler.cs +++ b/Brizco.Repository/Handlers/Tasks/CreateTaskCommandHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Tasks; public class CreateActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs b/Brizco.Repository/Handlers/Tasks/DeleteTaskCommandHandler.cs similarity index 94% rename from Brizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs rename to Brizco.Repository/Handlers/Tasks/DeleteTaskCommandHandler.cs index 78c9f48..6a10b04 100644 --- a/Brizco.Repository/Handlers/Task/DeleteTaskCommandHandler.cs +++ b/Brizco.Repository/Handlers/Tasks/DeleteTaskCommandHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Tasks; public class DeleteActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Task/GetTaskQueryHandler.cs b/Brizco.Repository/Handlers/Tasks/GetTaskQueryHandler.cs similarity index 90% rename from Brizco.Repository/Handlers/Task/GetTaskQueryHandler.cs rename to Brizco.Repository/Handlers/Tasks/GetTaskQueryHandler.cs index c87599d..50080dc 100644 --- a/Brizco.Repository/Handlers/Task/GetTaskQueryHandler.cs +++ b/Brizco.Repository/Handlers/Tasks/GetTaskQueryHandler.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Dtos.LargeDtos; - -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Tasks; public class GetActivityQueryHandler : IRequestHandler { diff --git a/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs b/Brizco.Repository/Handlers/Tasks/GetTasksQueryHandler.cs similarity index 96% rename from Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs rename to Brizco.Repository/Handlers/Tasks/GetTasksQueryHandler.cs index 2373e3e..39f32d5 100644 --- a/Brizco.Repository/Handlers/Task/GetTasksQueryHandler.cs +++ b/Brizco.Repository/Handlers/Tasks/GetTasksQueryHandler.cs @@ -1,4 +1,4 @@ -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Tasks; public class GetActivitiesQueryHandler : IRequestHandler> { diff --git a/Brizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs b/Brizco.Repository/Handlers/Tasks/UpdateTaskCommandHandler.cs similarity index 99% rename from Brizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs rename to Brizco.Repository/Handlers/Tasks/UpdateTaskCommandHandler.cs index f5e9a12..d3fdce5 100644 --- a/Brizco.Repository/Handlers/Task/UpdateTaskCommandHandler.cs +++ b/Brizco.Repository/Handlers/Tasks/UpdateTaskCommandHandler.cs @@ -1,6 +1,6 @@ using Brizco.Domain.Entities.Tasks; -namespace Brizco.Repository.Handlers.Task; +namespace Brizco.Repository.Handlers.Tasks; public class UpdateActivityCommandHandler : IRequestHandler { diff --git a/Brizco.Repository/Models/ApplicationContext.cs b/Brizco.Repository/Models/ApplicationContext.cs index 2a3c999..c62b5e5 100644 --- a/Brizco.Repository/Models/ApplicationContext.cs +++ b/Brizco.Repository/Models/ApplicationContext.cs @@ -1,9 +1,4 @@ -using Brizco.Domain.Entities.Users; -using Brizco.Repository.Extensions; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; - -namespace Brizco.Repository.Models; +namespace Brizco.Repository.Models; public class ApplicationContext : IdentityDbContext { diff --git a/Brizco.Repository/Repositories/Base/BaseRepository.cs b/Brizco.Repository/Repositories/Base/BaseRepository.cs index 12fd08b..480ac1d 100644 --- a/Brizco.Repository/Repositories/Base/BaseRepository.cs +++ b/Brizco.Repository/Repositories/Base/BaseRepository.cs @@ -1,6 +1,4 @@ -using Brizco.Common.Extensions; - -namespace Brizco.Repository.Repositories.Base +namespace Brizco.Repository.Repositories.Base { public class BaseRepository : Repository, IBaseRepository where T : class, IApiEntity { diff --git a/Brizco.Repository/Repositories/Base/Repository.cs b/Brizco.Repository/Repositories/Base/Repository.cs index 6b9dd19..02bced2 100644 --- a/Brizco.Repository/Repositories/Base/Repository.cs +++ b/Brizco.Repository/Repositories/Base/Repository.cs @@ -1,7 +1,4 @@ -using System.Text; -using Microsoft.EntityFrameworkCore; - -namespace Brizco.Repository.Repositories.Base +namespace Brizco.Repository.Repositories.Base { public class Repository : IRepository where T : class, IApiEntity { diff --git a/Brizco.Repository/Repositories/Base/WriteRepository.cs b/Brizco.Repository/Repositories/Base/WriteRepository.cs index 9e344b3..a56f58c 100644 --- a/Brizco.Repository/Repositories/Base/WriteRepository.cs +++ b/Brizco.Repository/Repositories/Base/WriteRepository.cs @@ -1,6 +1,4 @@  -using Brizco.Repository.Abstracts; - namespace Brizco.Repository.Repositories.Base { public class WriteRepository : Repository, IDisposable, IWriteRepository where T : class, IApiEntity diff --git a/Brizco.Repository/Repositories/UnitOfWork/UnitOfWork.cs b/Brizco.Repository/Repositories/UnitOfWork/UnitOfWork.cs index 2425d23..481ed38 100644 --- a/Brizco.Repository/Repositories/UnitOfWork/UnitOfWork.cs +++ b/Brizco.Repository/Repositories/UnitOfWork/UnitOfWork.cs @@ -1,5 +1,4 @@ -using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage; using Task = System.Threading.Tasks.Task; namespace Brizco.Repository.Repositories.UnitOfWork; diff --git a/Brizco.Repository/Services/Contracts/IDbInitializerService.cs b/Brizco.Repository/Services/Contracts/IDbInitializerService.cs index 91554a7..a55baf4 100644 --- a/Brizco.Repository/Services/Contracts/IDbInitializerService.cs +++ b/Brizco.Repository/Services/Contracts/IDbInitializerService.cs @@ -1,5 +1,4 @@ -using Brizco.Common.Models; -using Task = System.Threading.Tasks.Task; +using Task = System.Threading.Tasks.Task; namespace Brizco.Repository.Services.Contracts; diff --git a/Brizco.Repository/Services/DbInitializerService.cs b/Brizco.Repository/Services/DbInitializerService.cs index f5a757c..2881ecf 100644 --- a/Brizco.Repository/Services/DbInitializerService.cs +++ b/Brizco.Repository/Services/DbInitializerService.cs @@ -1,5 +1,4 @@ -using Brizco.Domain.Entities.Users; -using Task = System.Threading.Tasks.Task; +using Task = System.Threading.Tasks.Task; namespace Brizco.Repository.Services;