diff --git a/.version b/.version index 636ed6a..baba1a6 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.0.1.2 \ No newline at end of file +1.4.9.4 \ No newline at end of file diff --git a/Brizco.Api/AppSettings/appsettings.Development.json b/Brizco.Api/AppSettings/appsettings.Development.json index 1b5d28b..6b8b9ac 100644 --- a/Brizco.Api/AppSettings/appsettings.Development.json +++ b/Brizco.Api/AppSettings/appsettings.Development.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "PostgresServer": "Host=185.220.227.123;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB", + "PostgresServer": "Host=185.220.227.126;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB", + "MartenDBServer": "Host=185.228.236.40;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoMartenDB", "Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Application Name=BrizCo", "MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;" }, diff --git a/Brizco.Api/Brizco.Api.csproj b/Brizco.Api/Brizco.Api.csproj index ad8afbf..c72375e 100644 --- a/Brizco.Api/Brizco.Api.csproj +++ b/Brizco.Api/Brizco.Api.csproj @@ -6,8 +6,8 @@ enable Linux ..\docker-compose.dcproj - 1.0.1.2 - 1.0.1.2 + 1.4.9.4 + 1.4.9.4 diff --git a/Brizco.Api/Controllers/ActivityController.cs b/Brizco.Api/Controllers/ActivityController.cs index fc5ef20..da10f20 100644 --- a/Brizco.Api/Controllers/ActivityController.cs +++ b/Brizco.Api/Controllers/ActivityController.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Enums; - -namespace Brizco.Api.Controllers; +namespace Brizco.Api.Controllers; public class ActivityController : ICarterModule { @@ -12,7 +10,7 @@ public class ActivityController : ICarterModule group.MapGet("", GetAllAsync) .WithDisplayName("GetActivities") - .RequireAuthorization(builder=>builder.RequireClaim(CustomClaimType.Permission,ApplicationPermission.ViewActivities, ApplicationPermission.ManageActivities)) + .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewActivities, ApplicationPermission.ManageActivities)) .HasApiVersion(1.0); group.MapGet("{id:guid}", GetAsync) @@ -26,7 +24,7 @@ public class ActivityController : ICarterModule .HasApiVersion(1.0); group.MapPost("complete", CompleteActivityAsync) - .WithDisplayName("DoneActivity") + .WithDisplayName("CompleteActivity") .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus)) .HasApiVersion(1.0); @@ -34,36 +32,35 @@ public class ActivityController : ICarterModule .WithDisplayName("UnDoneActivity") .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ChangeActivityStatus)) .HasApiVersion(1.0); - - //group.MapPost("", Post) - // .AllowAnonymous() - // .HasApiVersion(1.0); - - //group.MapPut("", Put) - // .HasApiVersion(1.0); - - //group.MapDelete("{id:guid}", Delete) - // .HasApiVersion(1.0); - } // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, [FromQuery] DateQueryFilter? dateQueryFilter, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShiftPlanId, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(Page: page, SelectedDate: selectedDate ?? 0 , SelectedShiftPlanId: selectedShiftPlanId ?? default , DateQueryFilter: dateQueryFilter ?? null), cancellationToken)); + public async Task GetAllAsync([FromQuery] int page, + [FromQuery] DateTimeQueryFilter? dateQueryFilter, + [FromQuery] long? selectedDate, + [FromQuery] Guid? selectedShiftPlanId, + [FromQuery] Guid? userId, + ISender sender, + CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(UserId: userId, + Page: page, + SelectedDate: selectedDate ?? 0, + SelectedShiftPlanId: selectedShiftPlanId, + DateQueryFilter: dateQueryFilter), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken) - => TypedResults.Ok(await activityService.DoneActivityAsync(id,cancellationToken)); + => TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken)); - public async Task CompleteActivityAsync([FromBody]List requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken) + public async Task CompleteActivityAsync([FromBody] List requestDtos, [FromServices] IActivityService activityService, CancellationToken cancellationToken) => TypedResults.Ok(await activityService.CompleteActivitiesAsync(requestDtos, cancellationToken)); public async Task DoneActivityAsync(Guid id, [FromServices] IActivityService activityService, CancellationToken cancellationToken) => TypedResults.Ok(await activityService.DoneActivityAsync(id, cancellationToken)); - public async Task UnDoneActivityAsync(Guid id,[FromQuery]string undoneReason, [FromServices]IActivityService activityService, CancellationToken cancellationToken) - => TypedResults.Ok(await activityService.UnDoneActivityAsync(id,undoneReason, cancellationToken)); + public async Task UnDoneActivityAsync(Guid id, [FromQuery] string undoneReason, [FromServices] IActivityService activityService, CancellationToken cancellationToken) + => TypedResults.Ok(await activityService.UnDoneActivityAsync(id, undoneReason, cancellationToken)); //// POST:Create Entity //public async Task Post([FromQuery]Guid shiftPlanId,IActivityService activityService, CancellationToken cancellationToken) diff --git a/Brizco.Api/Controllers/NewsFeedController.cs b/Brizco.Api/Controllers/NewsFeedController.cs new file mode 100644 index 0000000..0c4da3d --- /dev/null +++ b/Brizco.Api/Controllers/NewsFeedController.cs @@ -0,0 +1,38 @@ +namespace Brizco.Api.Controllers; + +public class NewsFeedController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("News") + .MapGroup("api/news"); + + group.MapGet("", GetEntitiesAsync) + .WithDisplayName("Get News Feed") + .HasApiVersion(1.0); + + group.MapPost("", PostEntitiesAsync) + .WithDisplayName("Create News Feed") + .HasApiVersion(1.0); + + group.MapPut("{id}/pin", ChangePinAsync) + .WithDisplayName("Change NewsFeed Pin") + .HasApiVersion(1.0); + + group.MapDelete("{id}", DeleteEntitiesAsync) + .WithDisplayName("Delete News Feed") + .HasApiVersion(1.0); + } + + private async Task GetEntitiesAsync([FromQuery] int page, [FromQuery] int? count, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetNewsFeedsQuery(page, count), cancellationToken)); + + private async Task PostEntitiesAsync([FromBody]CreateNewsFeedCommand request, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(request, cancellationToken)); + + private async Task ChangePinAsync([FromRoute] Guid id, [FromQuery]bool isPin, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new ChangeNewsFeedPinCommand(id,isPin), cancellationToken)); + + private async Task DeleteEntitiesAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new DeleteNewsFeedCommand(id), cancellationToken)); +} \ No newline at end of file diff --git a/Brizco.Api/Controllers/NotificationController.cs b/Brizco.Api/Controllers/NotificationController.cs index 668b6b9..4234bca 100644 --- a/Brizco.Api/Controllers/NotificationController.cs +++ b/Brizco.Api/Controllers/NotificationController.cs @@ -13,6 +13,12 @@ public class NotificationController : ICarterModule .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) .HasApiVersion(1.0); + group.MapGet("/unread/count", GetUserNotificationsCountAsync) + .WithDisplayName("Get Unread Notifications Count") + .WithDescription("Get user notifications , by JWT user id") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()) + .HasApiVersion(1.0); + group.MapPost("{id}/read",ReadNotificationAsync) .WithDisplayName("Read Notification") .WithDescription("Read notification , by JWT user id") @@ -24,7 +30,10 @@ public class NotificationController : ICarterModule private async Task ReadNotificationAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(new ReadNotificationCommand(id), cancellationToken)); - private async Task GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int count, + private async Task GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int? count, [FromServices] IMediator mediator, CancellationToken cancellationToken) => TypedResults.Ok(await mediator.Send(new GetNotificationsQuery(page, count), cancellationToken)); + + private async Task GetUserNotificationsCountAsync([FromServices] IMediator mediator, CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetNotificationsCountQuery(), cancellationToken)); } \ No newline at end of file diff --git a/Brizco.Api/Controllers/ShiftPlanController.cs b/Brizco.Api/Controllers/ShiftPlanController.cs index d203047..4a76816 100644 --- a/Brizco.Api/Controllers/ShiftPlanController.cs +++ b/Brizco.Api/Controllers/ShiftPlanController.cs @@ -1,6 +1,4 @@ -using Brizco.Domain.Enums; - -namespace Brizco.Api.Controllers; +namespace Brizco.Api.Controllers; public class ShiftPlanController : ICarterModule { @@ -32,6 +30,7 @@ public class ShiftPlanController : ICarterModule .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans)) .HasApiVersion(1.0); + group.MapPost("", Post) .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageShiftPlans)) .HasApiVersion(1.0); @@ -54,7 +53,10 @@ public class ShiftPlanController : ICarterModule // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] DateTimeQueryFilter? dateFilter , ISender sender, CancellationToken cancellationToken) + public async Task GetAllAsync([FromQuery] int page, + [FromQuery] long? selectedDate, + [FromQuery] DateTimeQueryFilter? dateFilter , + [FromServices]ISender sender, CancellationToken cancellationToken) => TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page , selectedDate ?? 0 , DateTimeQueryFilter: dateFilter), cancellationToken)); // GET:Get An Entity By Id diff --git a/Brizco.Api/Controllers/TaskController.cs b/Brizco.Api/Controllers/TaskController.cs index 90c50e3..6327b5c 100644 --- a/Brizco.Api/Controllers/TaskController.cs +++ b/Brizco.Api/Controllers/TaskController.cs @@ -34,7 +34,7 @@ public class TaskController : ICarterModule // GET:Get All Entity public async Task GetAllAsync([FromQuery] int page, [FromQuery] int? count, - [FromQuery] Guid shiftId, + [FromQuery] Guid? shiftId, ISender sender, CancellationToken cancellationToken) => TypedResults.Ok(await sender.Send(new GetTasksQuery(page, ShiftId: shiftId, Count: count), cancellationToken)); diff --git a/Brizco.Api/Controllers/UserController.cs b/Brizco.Api/Controllers/UserController.cs index 788ca80..737299c 100644 --- a/Brizco.Api/Controllers/UserController.cs +++ b/Brizco.Api/Controllers/UserController.cs @@ -16,6 +16,11 @@ public class UserController : ICarterModule .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers,ApplicationPermission.ManageUsers)) .HasApiVersion(1.0); + group.MapGet("/staff", GetAllStaffAsync) + .WithDisplayName("GetAllStaff") + .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers)) + .HasApiVersion(1.0); + group.MapGet("{id}", GetAsync) .WithDisplayName("GetOneUser") .RequireAuthorization(builder => builder.RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewUsers, ApplicationPermission.ManageUsers)) @@ -42,6 +47,12 @@ public class UserController : ICarterModule .HasApiVersion(1.0); } + private async Task GetAllStaffAsync([FromQuery] DateTimeQueryFilter filter, + [FromQuery] int page, + [FromQuery] int? count, + IMediator mediator, + CancellationToken cancellationToken) + => TypedResults.Ok(await mediator.Send(new GetStaffQuery(page, filter, count), cancellationToken)); public async Task ChangeUserRoleAsync(Guid roleId,IUserService userService, CancellationToken cancellationToken) => TypedResults.Ok(await userService.ChangeUserRoleAsync(roleId,cancellationToken)); diff --git a/Brizco.Api/Program.cs b/Brizco.Api/Program.cs index c84546c..a399cac 100644 --- a/Brizco.Api/Program.cs +++ b/Brizco.Api/Program.cs @@ -83,6 +83,7 @@ builder.Host.ConfigureContainer(builder => .Create(typeof(CoreConfig).Assembly) .WithAllOpenGenericHandlerTypesRegistered() .Build()); + builder.AddSchedulerToAutoFac(); }); var app = builder.Build(); diff --git a/Brizco.Api/Properties/launchSettings.json b/Brizco.Api/Properties/launchSettings.json index 4a0a476..78c6560 100644 --- a/Brizco.Api/Properties/launchSettings.json +++ b/Brizco.Api/Properties/launchSettings.json @@ -23,7 +23,8 @@ "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1", "environmentVariables": { - "ASPNETCORE_URLS": "http://+:80" + "ASPNETCORE_URLS": "http://+:80", + "TZ": "Asia/Tehran" }, "publishAllPorts": true, "DockerfileRunArguments": " --network=mother -p 32767:80" diff --git a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs index 379e751..399ad22 100644 --- a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -1,8 +1,10 @@ -using System.IO.Compression; +using System.Collections.Specialized; +using System.IO.Compression; using Asp.Versioning; using AspNetCoreRateLimit; using AspNetCoreRateLimit.Redis; -using Brizco.Domain.Entities.Users; +using Autofac.Extras.Quartz; +using Brizco.Core.QuartzServices; using Marten; using Microsoft.AspNetCore.ResponseCompression; using StackExchange.Redis.Extensions.Core.Configuration; @@ -14,6 +16,22 @@ namespace Brizco.Api.WebFramework.Configurations; public static class ServiceExtensions { + public static void AddSchedulerToAutoFac(this ContainerBuilder builder) + { + // configure and register Quartz + var schedulerConfig = new NameValueCollection { + {"quartz.threadPool.threadCount", "3"}, + {"quartz.scheduler.threadName", "MyScheduler"}, + }; + + builder.RegisterModule(new QuartzAutofacFactoryModule + { + ConfigurationProvider = c => schedulerConfig + }); + + builder.RegisterModule(new QuartzAutofacJobsModule(typeof(JobScheduler).Assembly)); + builder.RegisterType().AsSelf(); + } public static void AddIpRateLimit(this IServiceCollection services, IConfigurationRoot configuration) { diff --git a/Brizco.Common/Extensions/DateTimeExtensions.cs b/Brizco.Common/Extensions/DateTimeExtensions.cs index eb0ad4e..04d1c64 100644 --- a/Brizco.Common/Extensions/DateTimeExtensions.cs +++ b/Brizco.Common/Extensions/DateTimeExtensions.cs @@ -37,6 +37,8 @@ namespace Brizco.Common.Extensions public static long DateTimeToUnixTimeStamp(DateTime dateTime) { + if (dateTime == DateTime.MinValue) + return 0; return ((DateTimeOffset)dateTime).ToUnixTimeMilliseconds(); } diff --git a/Brizco.Core/Brizco.Core.csproj b/Brizco.Core/Brizco.Core.csproj index 70523ac..8517ffd 100644 --- a/Brizco.Core/Brizco.Core.csproj +++ b/Brizco.Core/Brizco.Core.csproj @@ -63,9 +63,11 @@ + + diff --git a/Brizco.Core/EntityServices/ActivityService.cs b/Brizco.Core/EntityServices/ActivityService.cs index d4604fa..393ce70 100644 --- a/Brizco.Core/EntityServices/ActivityService.cs +++ b/Brizco.Core/EntityServices/ActivityService.cs @@ -3,29 +3,21 @@ using Task = Brizco.Domain.Entities.Tasks.Task; namespace Brizco.Core.EntityServices; -public class ActivityService : IActivityService +public class ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper) : IActivityService { - private readonly IMediator _mediator; - private readonly IRepositoryWrapper _repositoryWrapper; - - public ActivityService(IMediator mediator, IRepositoryWrapper repositoryWrapper) - { - _mediator = mediator; - _repositoryWrapper = repositoryWrapper; - } public async Task DoneActivityAsync(Guid activityId, CancellationToken cancellationToken) { - var activity = await _repositoryWrapper.SetRepository() + var activity = await repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken); if (activity == null) throw new AppException("Activity not found", ApiResultStatusCode.NotFound); activity.DoneActivity(); - _repositoryWrapper.SetRepository() + repositoryWrapper.SetRepository() .Update(activity); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } @@ -33,14 +25,14 @@ public class ActivityService : IActivityService { foreach (var activityRequestDto in requestDtos) { - var activity = await _repositoryWrapper.SetRepository().TableNoTracking + var activity = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(a => a.Id == activityRequestDto.ActivityId, cancellationToken); if (activity == null) continue; activity.CompleteActivity(activityRequestDto.IsCompleted, activityRequestDto.PerformanceDescription); - _repositoryWrapper.SetRepository().Update(activity); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + repositoryWrapper.SetRepository().Update(activity); + await repositoryWrapper.SaveChangesAsync(cancellationToken); } return true; @@ -49,44 +41,44 @@ public class ActivityService : IActivityService public async Task UnDoneActivityAsync(Guid activityId, string undoneReason, CancellationToken cancellationToken) { - var activity = await _repositoryWrapper.SetRepository() + var activity = await repositoryWrapper.SetRepository() .TableNoTracking .FirstOrDefaultAsync(a => a.Id == activityId, cancellationToken); if (activity == null) throw new AppException("Activity not found ", ApiResultStatusCode.NotFound); activity.UnDoneActivity(undoneReason); - _repositoryWrapper.SetRepository() + repositoryWrapper.SetRepository() .Update(activity); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } public async Task UpdateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) { - var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); + var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); if (shiftPlan.Id == Guid.Empty) return false; - var dailyTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var dailyTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily select task).AsNoTracking().ToListAsync(cancellationToken); - var weeklyTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskDay in _repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var weeklyTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskDay in repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly group task by task.Id into groupedTask select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken); - var customTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var customTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date @@ -98,13 +90,13 @@ public class ActivityService : IActivityService tasks.AddRange(dailyTasks); tasks.AddRange(customTasks); - var shiftPlanPositions = await _repositoryWrapper.SetRepository() + var shiftPlanPositions = await repositoryWrapper.SetRepository() .TableNoTracking .Where(spu => spu.ShiftPlanId == shiftPlan.Id) .ToListAsync(cancellationToken); - var activities = await _repositoryWrapper.SetRepository() + var activities = await repositoryWrapper.SetRepository() .TableNoTracking .Where(a => a.ShiftPlanId == shiftPlan.ShiftId && a.SetFor.Date == shiftPlan.PlanFor.Date) .Select(ActivityMapper.ProjectToLDto) @@ -115,7 +107,7 @@ public class ActivityService : IActivityService if (foundedTask == null) continue; - var taskPositions = await _repositoryWrapper.SetRepository() + var taskPositions = await repositoryWrapper.SetRepository() .TableNoTracking .Where(tp => tp.TaskId == foundedTask.Id) .ToListAsync(cancellationToken); @@ -128,7 +120,7 @@ public class ActivityService : IActivityService if (activity.UserId != foundedUser.UserId) { - await _mediator.Send(new UpdateActivityCommand(activity.Id, activity.Status, activity.DoneAt, activity.PerformanceDescription, + await mediator.Send(new UpdateActivityCommand(activity.Id, activity.Status, activity.DoneAt, activity.PerformanceDescription, activity.Type, activity.Title, activity.Description, activity.IsDisposable, activity.SetFor, activity.HasDisposed, activity.Amount , activity.AmountType, activity.ScheduleType, shiftPlan.Id, foundedUser.UserId), cancellationToken); } @@ -138,30 +130,30 @@ public class ActivityService : IActivityService } public async Task CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken) { - var shiftPlan = await _mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); + var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId), cancellationToken); if (shiftPlan.Id == Guid.Empty) return false; - var dailyTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var dailyTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Daily select task).AsNoTracking().ToListAsync(cancellationToken); - var weeklyTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskDay in _repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var weeklyTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskDay in repositoryWrapper.SetRepository().Entities on task.Id equals taskDay.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && taskDay.DayOfWeek == shiftPlan.PlanFor.DayOfWeek && task.ScheduleType == TaskScheduleType.Weekly group task by task.Id into groupedTask select groupedTask.FirstOrDefault()).AsNoTracking().ToListAsync(cancellationToken); - var customTasks = await (from task in _repositoryWrapper.SetRepository().Entities - join taskShift in _repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId - join taskRoutine in _repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine + var customTasks = await (from task in repositoryWrapper.SetRepository().Entities + join taskShift in repositoryWrapper.SetRepository().Entities on task.Id equals taskShift.TaskId + join taskRoutine in repositoryWrapper.SetRepository().Entities on task.Id equals taskRoutine .TaskId where task.IsActivity == false && taskShift.ShiftId == shiftPlan.ShiftId && taskRoutine.RoutineId == shiftPlan.RoutineId && task.ScheduleType == TaskScheduleType.Custom && task.SetFor.Date == shiftPlan.PlanFor.Date @@ -173,14 +165,14 @@ public class ActivityService : IActivityService tasks.AddRange(customTasks); - var shiftPlanPositions = await _repositoryWrapper.SetRepository() + var shiftPlanPositions = await repositoryWrapper.SetRepository() .TableNoTracking .Where(spu => spu.ShiftPlanId == shiftPlan.Id) .ToListAsync(cancellationToken); foreach (var task in tasks) { - var taskPositions = await _repositoryWrapper.SetRepository() + var taskPositions = await repositoryWrapper.SetRepository() .TableNoTracking .Where(tp => tp.TaskId == task.Id) .ToListAsync(cancellationToken); @@ -190,7 +182,7 @@ public class ActivityService : IActivityService var fundedUser = shiftPlanPositions.FirstOrDefault(spu => spu.PositionId == taskPosition.PositionId); if (fundedUser != null) { - await _mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable, + await mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable, shiftPlan.PlanFor, task.HasDisposed, task.Amount, task.AmountType, task.ScheduleType, shiftPlan.Id, fundedUser.UserId), cancellationToken); } diff --git a/Brizco.Core/EntityServices/ShiftPlanService.cs b/Brizco.Core/EntityServices/ShiftPlanService.cs index b76fa18..312ce64 100644 --- a/Brizco.Core/EntityServices/ShiftPlanService.cs +++ b/Brizco.Core/EntityServices/ShiftPlanService.cs @@ -34,6 +34,17 @@ public class ShiftPlanService(IMediator mediator, IActivityService activityServi repositoryWrapper.SetRepository().Update(shiftPlan); await repositoryWrapper.SaveChangesAsync(cancellationToken); await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); + + var shiftPlanUsers = await repositoryWrapper.SetRepository() + .TableNoTracking.Where(s => s.ShiftPlanId == id) + .Select(ShiftPlanUserMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + foreach (var shiftPlanUser in shiftPlanUsers) + { + var message = $"{shiftPlanUser.UserFullName}"; + } + return true; } } \ No newline at end of file diff --git a/Brizco.Core/MartenServices/BrewService.cs b/Brizco.Core/MartenServices/BrewService.cs index f2916b5..93d19fc 100644 --- a/Brizco.Core/MartenServices/BrewService.cs +++ b/Brizco.Core/MartenServices/BrewService.cs @@ -1,7 +1,4 @@ -using Newtonsoft.Json; -using System.Reflection; - -namespace Brizco.Core.MartenServices; +namespace Brizco.Core.MartenServices; public class BrewService : IBrewService { diff --git a/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs index 5e11562..ab20f43 100644 --- a/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs +++ b/Brizco.Core/QuartzServices/Handlers/CreateShiftPlanNotificationsCommandHandler.cs @@ -1,9 +1,7 @@ -using Brizco.Domain.Entities.ShiftPlans; +namespace Brizco.Core.QuartzServices.Handlers; -namespace Brizco.Core.QuartzServices.Handlers; - -public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepositoryWrapper repositoryWrapper) - : IRequestHandler +public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper) + : IRequestHandler { public async Task Handle(CreateShiftPlanNotificationsCommand request, CancellationToken cancellationToken) { @@ -28,8 +26,8 @@ public class CreateShiftPlanNotificationsCommandHandler(IMediator mediator,IRepo foreach (var shiftPlanUser in shiftPlanUsers) { - var completeShiftMessageForUser = $""; - await mediator.Send( new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken); + var completeShiftMessageForUser = $"شیفت‌های هفته بعد بسته شد، دیگه کار، کار، کار."; + await mediator.Send(new CreateNotificationCommand(completeShiftMessageForUser, shiftPlanUser.UserId, shiftPlan.ComplexId), cancellationToken); } } diff --git a/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs index ceb4416..c38bfee 100644 --- a/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs +++ b/Brizco.Core/QuartzServices/Handlers/SetShiftPlanNotificationScheduleCommandHandler.cs @@ -1,9 +1,11 @@ using Brizco.Core.QuartzServices.Commands; +using Microsoft.Extensions.Logging; using Quartz; namespace Brizco.Core.QuartzServices.Handlers; -public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler) : IRequestHandler +public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper repositoryWrapper,IScheduler scheduler,IMediator mediator,ILogger logger) + : IRequestHandler { public async Task Handle(SetShiftPlanNotificationScheduleCommand request, CancellationToken cancellationToken) { @@ -20,9 +22,22 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r 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 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); + } + + 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 currentDate = DateTime.UtcNow; + 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, @@ -36,10 +51,9 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r ITrigger beforeEndShift30MinTrigger = TriggerBuilder.Create() .WithIdentity(StringExtensions.GetId(9), shift.ComplexId.ToString()) .WithSimpleSchedule(x => x.WithRepeatCount(0)) - .StartAt(endTimeOffset.AddMinutes(-40)) + .StartAt(endTimeOffset.AddMinutes(-35)) .Build(); - IJobDetail endOfShift = JobBuilder.Create() .WithIdentity(ShiftPlanNotifyType.EndOfShift.ToString(), shiftPlan.Id.ToString()) .Build(); @@ -60,9 +74,10 @@ public class SetShiftPlanNotificationScheduleCommandHandler(IRepositoryWrapper r .Build(); - await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken); - await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken); - await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken); + var seTimeOffsetA = await scheduler.ScheduleJob(beforeEndShift30Min, beforeEndShift30MinTrigger, cancellationToken); + var seTimeOffsetB = await scheduler.ScheduleJob(endOfShift, endOfShiftTrigger, cancellationToken); + var seTimeOffsetC = await scheduler.ScheduleJob(afterStartShift2Hour, afterStartShift2HourTrigger, cancellationToken); + await scheduler.Start(cancellationToken); return true; diff --git a/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs index cdc4da6..1b7e8a9 100644 --- a/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs +++ b/Brizco.Core/QuartzServices/ShiftPlanNotificationScheduledJob.cs @@ -1,5 +1,4 @@ -using Brizco.Domain.Entities.ShiftPlans; -using Brizco.Domain.Entities.Tasks; +using Brizco.Domain.Entities.Tasks; using Microsoft.Extensions.Logging; using Quartz; using Task = System.Threading.Tasks.Task; @@ -26,12 +25,15 @@ public class ShiftPlanNotificationScheduledJob : IJob 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); + .Where(f => f.Id == shiftPlanId) + .Select(ShiftPlanMapper.ProjectToSDto) + .FirstOrDefaultAsync(); if (shiftPlan == null) throw new Exception("Shift plan not found"); var shiftPlanUsers = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(f => f.ShiftPlanId == shiftPlanId) + .Select(ShiftPlanUserMapper.ProjectToSDto) .ToListAsync(); var superVisorId = shiftPlan.SupervisorId; switch (notifyType) @@ -47,7 +49,7 @@ public class ShiftPlanNotificationScheduledJob : IJob var unDoneCount = activities.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); if(unDoneCount == 0) continue; - string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید ، نیم ساعت به پایان شیفت مانده است"; + string message = $"نیم ساعت مونده تا شیفت تموم شه و {unDoneCount} عدد از تست هات مونده، حالا چه خاکی به سر کنیم!😱"; await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); } break; @@ -59,14 +61,23 @@ public class ShiftPlanNotificationScheduledJob : IJob var unDoneCount = activitiesEndShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); if (unDoneCount == 0) continue; - string message = $"شما تعداد {unDoneCount} وظیفه انجام نشده در شیفت مورد نظر دارید"; + string message = $"{shiftPlanUser.UserFullName} {shiftPlan.ShiftTitle} {shiftPlan.PlanFor.ToPersianDateTime().ToLongDateTimeString()} تموم شده است و {unDoneCount} - عدد از تسک های شما کاری روشون انجام نشده ، خطر سوپروایزر در کمین است"; await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); } - string superVisorAfterShiftMessage = $"سوپر وایزر محترم ، شیفت مورد نظر به پایان رسیده است ، لطفا فعالیت ها را رسیدگی کنید"; + string superVisorAfterShiftMessage = $"{shiftPlan.SupervisorFullName} محترم {shiftPlan.ShiftTitle} تموم شد. برو به کار بچه ها نمره بده و مو رو از ماست بکش و کامنت یادت نره"; await _mediator.Send(new CreateNotificationCommand(superVisorAfterShiftMessage, shiftPlan.SupervisorId, shiftPlan.ComplexId)); break; case ShiftPlanNotifyType.AfterStartShift2Hour: - + var activities2AfterStartShift = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(a => a.ShiftPlanId == shiftPlanId).ToListAsync(); + foreach (var shiftPlanUser in shiftPlanUsers) + { + var unDoneCount = activities2AfterStartShift.Count(a => a.UserId == shiftPlanUser.UserId && a.IsDone == false); + if (unDoneCount == 0) + continue; + string message = $"{shiftPlanUser.UserFullName} دوساعت از {shiftPlan.ShiftTitle} گذشته ، اون انگشت و بزن روی تیک تسک ها که وقت طلاس مشتیییییی "; + await _mediator.Send(new CreateNotificationCommand(message, shiftPlanUser.UserId, shiftPlan.ComplexId)); + } break; default: return; diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index 8ad6271..c096311 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -61,6 +61,7 @@ + @@ -70,4 +71,10 @@ + + + + + + diff --git a/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs b/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs new file mode 100644 index 0000000..1fe0029 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Commands/NewsFeedCommands.cs @@ -0,0 +1,5 @@ +namespace Brizco.Domain.CommandQueries.Commands; + +public record CreateNewsFeedCommand(string Title,string Content,bool IsPin) : IRequest; +public record DeleteNewsFeedCommand(Guid Id) : IRequest; +public record ChangeNewsFeedPinCommand(Guid Id , bool IsPin) : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs index a670b97..61a61eb 100644 --- a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs @@ -2,7 +2,11 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShiftPlanId = default , DateQueryFilter? DateQueryFilter = null) : IRequest>; +public sealed record GetActivitiesQuery(int Page = 0 , + long SelectedDate = 0 , + Guid? SelectedShiftPlanId = null , + DateTimeQueryFilter? DateQueryFilter = null, + Guid? UserId = null) : IRequest>; public sealed record GetActivityQuery(Guid Id) : IRequest; diff --git a/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs b/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs new file mode 100644 index 0000000..a9fc8e0 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/NewsFeedQueries.cs @@ -0,0 +1,3 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public record GetNewsFeedsQuery(int Page , int? Count = 0) : IRequest>; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs b/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs index 46d14dc..b61def6 100644 --- a/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/NotificationQueries.cs @@ -2,4 +2,5 @@ namespace Brizco.Domain.CommandQueries.Queries; -public record GetNotificationsQuery(int Page,int Count, Guid? UserId=null) : IRequest>; \ No newline at end of file +public record GetNotificationsQuery(int Page,int? Count=null, Guid? UserId=null) : IRequest>; +public record GetNotificationsCountQuery() : IRequest; \ No newline at end of file diff --git a/Brizco.Domain/CommandQueries/Queries/UserQueries.cs b/Brizco.Domain/CommandQueries/Queries/UserQueries.cs new file mode 100644 index 0000000..ed948a5 --- /dev/null +++ b/Brizco.Domain/CommandQueries/Queries/UserQueries.cs @@ -0,0 +1,3 @@ +namespace Brizco.Domain.CommandQueries.Queries; + +public record GetStaffQuery(int Page , DateTimeQueryFilter DateTimeQuery , int? Count = null) : IRequest>; \ No newline at end of file diff --git a/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs b/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs new file mode 100644 index 0000000..97d80ec --- /dev/null +++ b/Brizco.Domain/Dtos/ResponseDto/StaffResponseSDto.cs @@ -0,0 +1,8 @@ +namespace Brizco.Domain.Dtos.ResponseDto; + +public class StaffResponseSDto +{ + public Guid Id { get; set; } + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs index 47ac7ce..b0395f1 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs @@ -20,6 +20,7 @@ public class ActivitySDto : BaseDto public string UserFirstName { get; set; } = string.Empty; public string UserLastName { get; set; } = string.Empty; public string UserFullName => UserFirstName + " " + UserLastName; + public Guid UserId { get; set; } public int Amount { get; set; } diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs index 8dd6d8d..44d9add 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -18,6 +18,7 @@ public class ShiftPlanSDto : BaseDto public string ShiftTitle { get; set; } = string.Empty; public TimeSpan StartAt { get; set; } public TimeSpan EndAt { get; set; } + public Guid SupervisorId { get; set; } public List Users { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Enums/DateQueryFilter.cs b/Brizco.Domain/Enums/DateQueryFilter.cs deleted file mode 100644 index 72e155f..0000000 --- a/Brizco.Domain/Enums/DateQueryFilter.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Brizco.Domain.Enums; - -public enum DateQueryFilter -{ - Today = 0, - Tomorrow = 1, - ThisWeek = 2, - Yesterday = 3, -} \ No newline at end of file diff --git a/Brizco.Domain/Enums/DateTimeQueryFilter.cs b/Brizco.Domain/Enums/DateTimeQueryFilter.cs index 634fa3c..1450cbc 100644 --- a/Brizco.Domain/Enums/DateTimeQueryFilter.cs +++ b/Brizco.Domain/Enums/DateTimeQueryFilter.cs @@ -5,6 +5,7 @@ public enum DateTimeQueryFilter CustomDate = 0, Today = 1, Yesterday = 2, + Tomorrow = 3, PastWeek = 10, NextWeek = 11, ThisWeek = 12, diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs index 99eb127..601b055 100644 --- a/Brizco.Domain/Mappers/ActivityMapper.g.cs +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -20,10 +20,12 @@ namespace Brizco.Domain.Mappers IsDone = p1.IsDone, UnDoneReason = p1.UnDoneReason, PerformanceDescription = p1.PerformanceDescription, + UserId = p1.UserId, User = new ApplicationUser() { FirstName = p1.UserFirstName, - LastName = p1.UserLastName + LastName = p1.UserLastName, + Id = p1.UserId }, ShiftPlanId = p1.ShiftPlanId, ShiftPlan = new ShiftPlan() {Id = p1.ShiftPlanId}, @@ -52,6 +54,7 @@ namespace Brizco.Domain.Mappers result.IsDone = p2.IsDone; result.UnDoneReason = p2.UnDoneReason; result.PerformanceDescription = p2.PerformanceDescription; + result.UserId = p2.UserId; result.User = funcMain1(new Never(), result.User, p2); result.ShiftPlanId = p2.ShiftPlanId; result.ShiftPlan = funcMain2(new Never(), result.ShiftPlan, p2); @@ -75,10 +78,12 @@ namespace Brizco.Domain.Mappers IsDone = p8.IsDone, UnDoneReason = p8.UnDoneReason, PerformanceDescription = p8.PerformanceDescription, + UserId = p8.UserId, User = new ApplicationUser() { FirstName = p8.UserFirstName, - LastName = p8.UserLastName + LastName = p8.UserLastName, + Id = p8.UserId }, ShiftPlanId = p8.ShiftPlanId, ShiftPlan = new ShiftPlan() {Id = p8.ShiftPlanId}, @@ -112,6 +117,7 @@ namespace Brizco.Domain.Mappers PerformanceDescription = p9.PerformanceDescription, UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty, UserLastName = p9.User != null ? p9.User.LastName : string.Empty, + UserId = p9.UserId, Amount = p9.Amount, ShiftPlanId = p9.ShiftPlanId, AmountType = p9.AmountType, @@ -141,6 +147,7 @@ namespace Brizco.Domain.Mappers result.PerformanceDescription = p10.PerformanceDescription; result.UserFirstName = p10.User != null ? p10.User.FirstName : string.Empty; result.UserLastName = p10.User != null ? p10.User.LastName : string.Empty; + result.UserId = p10.UserId; result.Amount = p10.Amount; result.ShiftPlanId = p10.ShiftPlanId; result.AmountType = p10.AmountType; @@ -165,6 +172,7 @@ namespace Brizco.Domain.Mappers PerformanceDescription = p12.PerformanceDescription, UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty, UserLastName = p12.User != null ? p12.User.LastName : string.Empty, + UserId = p12.UserId, Amount = p12.Amount, ShiftPlanId = p12.ShiftPlanId, AmountType = p12.AmountType, @@ -289,6 +297,7 @@ namespace Brizco.Domain.Mappers result.FirstName = p2.UserFirstName; result.LastName = p2.UserLastName; + result.Id = p2.UserId; return result; } diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index cb227fd..422d5e0 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -29,6 +29,10 @@ namespace Brizco.Domain.Mappers Title = p1.ShiftTitle, Id = p1.ShiftId }, + ComplexId = p1.ComplexId, + Complex = new Complex() {Id = p1.ComplexId}, + SupervisorId = p1.SupervisorId, + Supervisor = new ApplicationUser() {Id = p1.SupervisorId}, Users = funcMain1(p1.Users), Id = p1.Id }; @@ -47,198 +51,212 @@ namespace Brizco.Domain.Mappers result.CompleteDescription = p3.CompleteDescription; result.ShiftId = p3.ShiftId; result.Shift = funcMain2(new Never(), result.Shift, p3); - result.Users = funcMain3(p3.Users, result.Users); + result.ComplexId = p3.ComplexId; + result.Complex = funcMain3(new Never(), result.Complex, p3); + result.SupervisorId = p3.SupervisorId; + result.Supervisor = funcMain4(new Never(), result.Supervisor, p3); + result.Users = funcMain5(p3.Users, result.Users); result.Id = p3.Id; return result; } - public static Expression> ProjectToShiftPlan => p9 => new ShiftPlan() + public static Expression> ProjectToShiftPlan => p13 => new ShiftPlan() { - PlanFor = p9.PlanFor, - IsCompleted = p9.IsCompleted, - CompletePercent = p9.CompletePercent, - CompleteDescription = p9.CompleteDescription, - ShiftId = p9.ShiftId, + PlanFor = p13.PlanFor, + IsCompleted = p13.IsCompleted, + CompletePercent = p13.CompletePercent, + CompleteDescription = p13.CompleteDescription, + ShiftId = p13.ShiftId, Shift = new Shift() { - Title = p9.ShiftTitle, - Id = p9.ShiftId + Title = p13.ShiftTitle, + Id = p13.ShiftId }, - Users = p9.Users.Select(p10 => new ShiftPlanUser() + ComplexId = p13.ComplexId, + Complex = new Complex() {Id = p13.ComplexId}, + SupervisorId = p13.SupervisorId, + Supervisor = new ApplicationUser() {Id = p13.SupervisorId}, + Users = p13.Users.Select(p14 => new ShiftPlanUser() { - ShiftPlanId = p10.ShiftPlanId, - ShiftPlan = new ShiftPlan() {Id = p10.ShiftPlanId}, - PositionId = p10.PositionId, + ShiftPlanId = p14.ShiftPlanId, + ShiftPlan = new ShiftPlan() {Id = p14.ShiftPlanId}, + PositionId = p14.PositionId, Position = new Position() { - Name = p10.PositionName, - Id = p10.PositionId + Name = p14.PositionName, + Id = p14.PositionId }, - UserId = p10.UserId, - User = new ApplicationUser() {Id = p10.UserId}, - Id = p10.Id + UserId = p14.UserId, + User = new ApplicationUser() {Id = p14.UserId}, + Id = p14.Id }).ToList(), - Id = p9.Id + Id = p13.Id }; - public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p11) + public static ShiftPlanSDto AdaptToSDto(this ShiftPlan p15) { - return p11 == null ? null : new ShiftPlanSDto() + return p15 == null ? null : new ShiftPlanSDto() { - PlanFor = p11.PlanFor, - IsCompleted = p11.IsCompleted, - CompletePercent = p11.CompletePercent, - SupervisorFullName = p11.Supervisor != null ? p11.Supervisor.FirstName + " " + p11.Supervisor.LastName : string.Empty, - CompleteDescription = p11.CompleteDescription, - ShiftId = p11.ShiftId, - ShiftTitle = p11.Shift == null ? null : p11.Shift.Title, - StartAt = p11.Shift != null ? p11.Shift.StartAt : TimeSpan.MinValue, - EndAt = p11.Shift != null ? p11.Shift.EndAt : TimeSpan.MinValue, - Users = funcMain4(p11.Users), - Id = p11.Id + PlanFor = p15.PlanFor, + IsCompleted = p15.IsCompleted, + CompletePercent = p15.CompletePercent, + SupervisorFullName = p15.Supervisor != null ? p15.Supervisor.FirstName + " " + p15.Supervisor.LastName : string.Empty, + CompleteDescription = p15.CompleteDescription, + ComplexId = p15.ComplexId, + ShiftId = p15.ShiftId, + ShiftTitle = p15.Shift == null ? null : p15.Shift.Title, + StartAt = p15.Shift != null ? p15.Shift.StartAt : TimeSpan.MinValue, + EndAt = p15.Shift != null ? p15.Shift.EndAt : TimeSpan.MinValue, + SupervisorId = p15.SupervisorId, + Users = funcMain6(p15.Users), + Id = p15.Id }; } - public static ShiftPlanSDto AdaptTo(this ShiftPlan p13, ShiftPlanSDto p14) + public static ShiftPlanSDto AdaptTo(this ShiftPlan p17, ShiftPlanSDto p18) { - if (p13 == null) + if (p17 == null) { return null; } - ShiftPlanSDto result = p14 ?? new ShiftPlanSDto(); + ShiftPlanSDto result = p18 ?? new ShiftPlanSDto(); - result.PlanFor = p13.PlanFor; - result.IsCompleted = p13.IsCompleted; - result.CompletePercent = p13.CompletePercent; - result.SupervisorFullName = p13.Supervisor != null ? p13.Supervisor.FirstName + " " + p13.Supervisor.LastName : string.Empty; - result.CompleteDescription = p13.CompleteDescription; - result.ShiftId = p13.ShiftId; - result.ShiftTitle = p13.Shift == null ? null : p13.Shift.Title; - result.StartAt = p13.Shift != null ? p13.Shift.StartAt : TimeSpan.MinValue; - result.EndAt = p13.Shift != null ? p13.Shift.EndAt : TimeSpan.MinValue; - result.Users = funcMain5(p13.Users, result.Users); - result.Id = p13.Id; + result.PlanFor = p17.PlanFor; + result.IsCompleted = p17.IsCompleted; + result.CompletePercent = p17.CompletePercent; + result.SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty; + result.CompleteDescription = p17.CompleteDescription; + result.ComplexId = p17.ComplexId; + result.ShiftId = p17.ShiftId; + result.ShiftTitle = p17.Shift == null ? null : p17.Shift.Title; + result.StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue; + result.EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue; + result.SupervisorId = p17.SupervisorId; + result.Users = funcMain7(p17.Users, result.Users); + result.Id = p17.Id; return result; } - public static Expression> ProjectToSDto => p17 => new ShiftPlanSDto() + public static Expression> ProjectToSDto => p21 => new ShiftPlanSDto() { - PlanFor = p17.PlanFor, - IsCompleted = p17.IsCompleted, - CompletePercent = p17.CompletePercent, - SupervisorFullName = p17.Supervisor != null ? p17.Supervisor.FirstName + " " + p17.Supervisor.LastName : string.Empty, - CompleteDescription = p17.CompleteDescription, - ShiftId = p17.ShiftId, - ShiftTitle = p17.Shift.Title, - StartAt = p17.Shift != null ? p17.Shift.StartAt : TimeSpan.MinValue, - EndAt = p17.Shift != null ? p17.Shift.EndAt : TimeSpan.MinValue, - Users = p17.Users.Select(p18 => new ShiftPlanUserSDto() + PlanFor = p21.PlanFor, + IsCompleted = p21.IsCompleted, + CompletePercent = p21.CompletePercent, + SupervisorFullName = p21.Supervisor != null ? p21.Supervisor.FirstName + " " + p21.Supervisor.LastName : string.Empty, + CompleteDescription = p21.CompleteDescription, + ComplexId = p21.ComplexId, + ShiftId = p21.ShiftId, + ShiftTitle = p21.Shift.Title, + StartAt = p21.Shift != null ? p21.Shift.StartAt : TimeSpan.MinValue, + EndAt = p21.Shift != null ? p21.Shift.EndAt : TimeSpan.MinValue, + SupervisorId = p21.SupervisorId, + Users = p21.Users.Select(p22 => new ShiftPlanUserSDto() { - ShiftPlanId = p18.ShiftPlanId, - UserId = p18.UserId, - UserFullName = p18.User != null ? p18.User.FirstName + " " + p18.User.LastName : string.Empty, - PositionId = p18.PositionId, - PositionName = p18.Position != null ? p18.Position.Name : string.Empty, - Id = p18.Id + ShiftPlanId = p22.ShiftPlanId, + UserId = p22.UserId, + UserFullName = p22.User != null ? p22.User.FirstName + " " + p22.User.LastName : string.Empty, + PositionId = p22.PositionId, + PositionName = p22.Position != null ? p22.Position.Name : string.Empty, + Id = p22.Id }).ToList(), - Id = p17.Id + Id = p21.Id }; - public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p19) + public static ShiftPlan AdaptToShiftPlan(this ShiftPlanLDto p23) { - return p19 == null ? null : new ShiftPlan() + return p23 == null ? null : new ShiftPlan() { - PlanFor = p19.PlanFor, - IsCompleted = p19.IsCompleted, - CompletePercent = p19.CompletePercent, - CompleteDescription = p19.CompleteDescription, - ShiftId = p19.ShiftId, - Shift = new Shift() {Id = p19.ShiftId}, - RoutineId = p19.RoutineId, - Routine = new Routine() {Id = p19.RoutineId}, - SupervisorId = p19.SupervisorId, - Supervisor = new ApplicationUser() {Id = p19.SupervisorId}, - Users = funcMain6(p19.Users), - Id = p19.Id + PlanFor = p23.PlanFor, + IsCompleted = p23.IsCompleted, + CompletePercent = p23.CompletePercent, + CompleteDescription = p23.CompleteDescription, + ShiftId = p23.ShiftId, + Shift = new Shift() {Id = p23.ShiftId}, + RoutineId = p23.RoutineId, + Routine = new Routine() {Id = p23.RoutineId}, + SupervisorId = p23.SupervisorId, + Supervisor = new ApplicationUser() {Id = p23.SupervisorId}, + Users = funcMain8(p23.Users), + Id = p23.Id }; } - public static ShiftPlan AdaptTo(this ShiftPlanLDto p21, ShiftPlan p22) + public static ShiftPlan AdaptTo(this ShiftPlanLDto p25, ShiftPlan p26) { - if (p21 == null) + if (p25 == null) { return null; } - ShiftPlan result = p22 ?? new ShiftPlan(); + ShiftPlan result = p26 ?? new ShiftPlan(); - result.PlanFor = p21.PlanFor; - result.IsCompleted = p21.IsCompleted; - result.CompletePercent = p21.CompletePercent; - result.CompleteDescription = p21.CompleteDescription; - result.ShiftId = p21.ShiftId; - result.Shift = funcMain7(new Never(), result.Shift, p21); - result.RoutineId = p21.RoutineId; - result.Routine = funcMain8(new Never(), result.Routine, p21); - result.SupervisorId = p21.SupervisorId; - result.Supervisor = funcMain9(new Never(), result.Supervisor, p21); - result.Users = funcMain10(p21.Users, result.Users); - result.Id = p21.Id; + result.PlanFor = p25.PlanFor; + result.IsCompleted = p25.IsCompleted; + result.CompletePercent = p25.CompletePercent; + result.CompleteDescription = p25.CompleteDescription; + result.ShiftId = p25.ShiftId; + result.Shift = funcMain9(new Never(), result.Shift, p25); + result.RoutineId = p25.RoutineId; + result.Routine = funcMain10(new Never(), result.Routine, p25); + result.SupervisorId = p25.SupervisorId; + result.Supervisor = funcMain11(new Never(), result.Supervisor, p25); + result.Users = funcMain12(p25.Users, result.Users); + result.Id = p25.Id; return result; } - public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p31) + public static ShiftPlanLDto AdaptToLDto(this ShiftPlan p35) { - return p31 == null ? null : new ShiftPlanLDto() + return p35 == null ? null : new ShiftPlanLDto() { - PlanFor = p31.PlanFor, - RoutineId = p31.RoutineId, - IsCompleted = p31.IsCompleted, - CompletePercent = p31.CompletePercent, - CompleteDescription = p31.CompleteDescription, - ShiftId = p31.ShiftId, - Users = funcMain11(p31.Users), - SupervisorId = p31.SupervisorId, - SupervisorFullName = p31.Supervisor != null ? p31.Supervisor.FirstName + " " + p31.Supervisor.LastName : string.Empty, - Id = p31.Id + PlanFor = p35.PlanFor, + RoutineId = p35.RoutineId, + IsCompleted = p35.IsCompleted, + CompletePercent = p35.CompletePercent, + CompleteDescription = p35.CompleteDescription, + ShiftId = p35.ShiftId, + Users = funcMain13(p35.Users), + SupervisorId = p35.SupervisorId, + SupervisorFullName = p35.Supervisor != null ? p35.Supervisor.FirstName + " " + p35.Supervisor.LastName : string.Empty, + Id = p35.Id }; } - public static ShiftPlanLDto AdaptTo(this ShiftPlan p33, ShiftPlanLDto p34) + public static ShiftPlanLDto AdaptTo(this ShiftPlan p37, ShiftPlanLDto p38) { - if (p33 == null) + if (p37 == null) { return null; } - ShiftPlanLDto result = p34 ?? new ShiftPlanLDto(); + ShiftPlanLDto result = p38 ?? new ShiftPlanLDto(); - result.PlanFor = p33.PlanFor; - result.RoutineId = p33.RoutineId; - result.IsCompleted = p33.IsCompleted; - result.CompletePercent = p33.CompletePercent; - result.CompleteDescription = p33.CompleteDescription; - result.ShiftId = p33.ShiftId; - result.Users = funcMain12(p33.Users, result.Users); - result.SupervisorId = p33.SupervisorId; - result.SupervisorFullName = p33.Supervisor != null ? p33.Supervisor.FirstName + " " + p33.Supervisor.LastName : string.Empty; - result.Id = p33.Id; + result.PlanFor = p37.PlanFor; + result.RoutineId = p37.RoutineId; + result.IsCompleted = p37.IsCompleted; + result.CompletePercent = p37.CompletePercent; + result.CompleteDescription = p37.CompleteDescription; + result.ShiftId = p37.ShiftId; + result.Users = funcMain14(p37.Users, result.Users); + result.SupervisorId = p37.SupervisorId; + result.SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty; + result.Id = p37.Id; return result; } - public static Expression> ProjectToLDto => p37 => new ShiftPlanLDto() + public static Expression> ProjectToLDto => p41 => new ShiftPlanLDto() { - PlanFor = p37.PlanFor, - RoutineId = p37.RoutineId, - IsCompleted = p37.IsCompleted, - CompletePercent = p37.CompletePercent, - CompleteDescription = p37.CompleteDescription, - ShiftId = p37.ShiftId, - Users = p37.Users.Select(p38 => new ShiftPlanUserSDto() + PlanFor = p41.PlanFor, + RoutineId = p41.RoutineId, + IsCompleted = p41.IsCompleted, + CompletePercent = p41.CompletePercent, + CompleteDescription = p41.CompleteDescription, + ShiftId = p41.ShiftId, + Users = p41.Users.Select(p42 => new ShiftPlanUserSDto() { - ShiftPlanId = p38.ShiftPlanId, - UserId = p38.UserId, - UserFullName = p38.User != null ? p38.User.FirstName + " " + p38.User.LastName : string.Empty, - PositionId = p38.PositionId, - PositionName = p38.Position != null ? p38.Position.Name : string.Empty, - Id = p38.Id + ShiftPlanId = p42.ShiftPlanId, + UserId = p42.UserId, + UserFullName = p42.User != null ? p42.User.FirstName + " " + p42.User.LastName : string.Empty, + PositionId = p42.PositionId, + PositionName = p42.Position != null ? p42.Position.Name : string.Empty, + Id = p42.Id }).ToList(), - SupervisorId = p37.SupervisorId, - SupervisorFullName = p37.Supervisor != null ? p37.Supervisor.FirstName + " " + p37.Supervisor.LastName : string.Empty, - Id = p37.Id + SupervisorId = p41.SupervisorId, + SupervisorFullName = p41.Supervisor != null ? p41.Supervisor.FirstName + " " + p41.Supervisor.LastName : string.Empty, + Id = p41.Id }; private static List funcMain1(List p2) @@ -285,20 +303,38 @@ namespace Brizco.Domain.Mappers } - private static List funcMain3(List p7, List p8) + private static Complex funcMain3(Never p7, Complex p8, ShiftPlanSDto p3) { - if (p7 == null) + Complex result = p8 ?? new Complex(); + + result.Id = p3.ComplexId; + return result; + + } + + private static ApplicationUser funcMain4(Never p9, ApplicationUser p10, ShiftPlanSDto p3) + { + ApplicationUser result = p10 ?? new ApplicationUser(); + + result.Id = p3.SupervisorId; + return result; + + } + + private static List funcMain5(List p11, List p12) + { + if (p11 == null) { return null; } - List result = new List(p7.Count); + List result = new List(p11.Count); int i = 0; - int len = p7.Count; + int len = p11.Count; while (i < len) { - ShiftPlanUserSDto item = p7[i]; + ShiftPlanUserSDto item = p11[i]; result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, @@ -319,20 +355,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain4(List p12) + private static List funcMain6(List p16) { - if (p12 == null) + if (p16 == null) { return null; } - List result = new List(p12.Count); + List result = new List(p16.Count); int i = 0; - int len = p12.Count; + int len = p16.Count; while (i < len) { - ShiftPlanUser item = p12[i]; + ShiftPlanUser item = p16[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, @@ -348,20 +384,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain5(List p15, List p16) + private static List funcMain7(List p19, List p20) { - if (p15 == null) + if (p19 == null) { return null; } - List result = new List(p15.Count); + List result = new List(p19.Count); int i = 0; - int len = p15.Count; + int len = p19.Count; while (i < len) { - ShiftPlanUser item = p15[i]; + ShiftPlanUser item = p19[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, @@ -377,20 +413,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain6(List p20) + private static List funcMain8(List p24) { - if (p20 == null) + if (p24 == null) { return null; } - List result = new List(p20.Count); + List result = new List(p24.Count); int i = 0; - int len = p20.Count; + int len = p24.Count; while (i < len) { - ShiftPlanUserSDto item = p20[i]; + ShiftPlanUserSDto item = p24[i]; result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, @@ -411,47 +447,47 @@ namespace Brizco.Domain.Mappers } - private static Shift funcMain7(Never p23, Shift p24, ShiftPlanLDto p21) + private static Shift funcMain9(Never p27, Shift p28, ShiftPlanLDto p25) { - Shift result = p24 ?? new Shift(); + Shift result = p28 ?? new Shift(); - result.Id = p21.ShiftId; + result.Id = p25.ShiftId; return result; } - private static Routine funcMain8(Never p25, Routine p26, ShiftPlanLDto p21) + private static Routine funcMain10(Never p29, Routine p30, ShiftPlanLDto p25) { - Routine result = p26 ?? new Routine(); + Routine result = p30 ?? new Routine(); - result.Id = p21.RoutineId; + result.Id = p25.RoutineId; return result; } - private static ApplicationUser funcMain9(Never p27, ApplicationUser p28, ShiftPlanLDto p21) + private static ApplicationUser funcMain11(Never p31, ApplicationUser p32, ShiftPlanLDto p25) { - ApplicationUser result = p28 ?? new ApplicationUser(); + ApplicationUser result = p32 ?? new ApplicationUser(); - result.Id = p21.SupervisorId; + result.Id = p25.SupervisorId; return result; } - private static List funcMain10(List p29, List p30) + private static List funcMain12(List p33, List p34) { - if (p29 == null) + if (p33 == null) { return null; } - List result = new List(p29.Count); + List result = new List(p33.Count); int i = 0; - int len = p29.Count; + int len = p33.Count; while (i < len) { - ShiftPlanUserSDto item = p29[i]; + ShiftPlanUserSDto item = p33[i]; result.Add(item == null ? null : new ShiftPlanUser() { ShiftPlanId = item.ShiftPlanId, @@ -472,20 +508,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain11(List p32) + private static List funcMain13(List p36) { - if (p32 == null) + if (p36 == null) { return null; } - List result = new List(p32.Count); + List result = new List(p36.Count); int i = 0; - int len = p32.Count; + int len = p36.Count; while (i < len) { - ShiftPlanUser item = p32[i]; + ShiftPlanUser item = p36[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, @@ -501,20 +537,20 @@ namespace Brizco.Domain.Mappers } - private static List funcMain12(List p35, List p36) + private static List funcMain14(List p39, List p40) { - if (p35 == null) + if (p39 == null) { return null; } - List result = new List(p35.Count); + List result = new List(p39.Count); int i = 0; - int len = p35.Count; + int len = p39.Count; while (i < len) { - ShiftPlanUser item = p35[i]; + ShiftPlanUser item = p39[i]; result.Add(item == null ? null : new ShiftPlanUserSDto() { ShiftPlanId = item.ShiftPlanId, diff --git a/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs b/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs new file mode 100644 index 0000000..85d80aa --- /dev/null +++ b/Brizco.Domain/MartenEntities/NewFeeds/NewsFeed.cs @@ -0,0 +1,9 @@ +namespace Brizco.Domain.MartenEntities.NewFeeds; + +public class NewsFeed : MartenEntity +{ + public string Content { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public bool IsPin { get; set; } + public DateTime CreatedAt { get; set; } +} \ No newline at end of file diff --git a/Brizco.Infrastructure/Marten/MartenRepository.cs b/Brizco.Infrastructure/Marten/MartenRepository.cs index a8376f7..0d590ce 100644 --- a/Brizco.Infrastructure/Marten/MartenRepository.cs +++ b/Brizco.Infrastructure/Marten/MartenRepository.cs @@ -36,7 +36,7 @@ public class MartenRepository : IMartenRepository await using var session = _documentStore.QuerySession(); var setting = await session.LoadAsync(id, cancellation); if (setting == null) - throw new AppException($"{nameof(setting)} not found", ApiResultStatusCode.NotFound); + throw new AppException($"{nameof(TMartenEntity)} not found", ApiResultStatusCode.NotFound); return setting; } diff --git a/Brizco.Repository/Brizco.Repository.csproj b/Brizco.Repository/Brizco.Repository.csproj index 33db06e..73f5f5b 100644 --- a/Brizco.Repository/Brizco.Repository.csproj +++ b/Brizco.Repository/Brizco.Repository.csproj @@ -27,7 +27,7 @@ - + @@ -50,6 +50,7 @@ + diff --git a/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs index 7ba6ee7..7a266d0 100644 --- a/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activities/GetActivitiesQueryHandler.cs @@ -1,51 +1,52 @@ namespace Brizco.Repository.Handlers.Activities; -public class GetActivitiesQueryHandler : IRequestHandler> +public class GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) + : IRequestHandler> { - private readonly IRepositoryWrapper _repositoryWrapper; - private readonly ICurrentUserService _currentUserService; - - public GetActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) - { - _repositoryWrapper = repositoryWrapper; - _currentUserService = currentUserService; - } public async Task> Handle(GetActivitiesQuery request, CancellationToken cancellationToken) { - if (_currentUserService.ComplexId == null) + if (currentUserService.ComplexId == null) throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); - if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); - if (_currentUserService.UserId == null) + if (currentUserService.UserId == null) throw new AppException("UserId is null", ApiResultStatusCode.NotFound); - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("UserId is wrong", ApiResultStatusCode.NotFound); - IQueryable activities = _repositoryWrapper.SetRepository().TableNoTracking + IQueryable activities = repositoryWrapper.SetRepository().TableNoTracking .Where(a=>a.IsActivity && a.ComplexId == complexId); - if (_currentUserService is { Permissions: not null, RoleName: not null }) + if (currentUserService is { Permissions: not null, RoleName: not null }) { - if (_currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities) && _currentUserService.RoleName == ApplicationRoles.Staff) + if (currentUserService.Permissions.Contains(ApplicationPermission.ViewMineActivities) && currentUserService.RoleName == ApplicationRoles.Staff) activities = activities.Where(a => a.UserId == userId); + else + activities = activities.Where(c => c.UserId == request.UserId); } if (request.DateQueryFilter != null) { + var date = DateTime.Now; switch (request.DateQueryFilter) { - case DateQueryFilter.Yesterday: + case DateTimeQueryFilter.Yesterday: activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date.AddDays(-1).Date); break; - case DateQueryFilter.Today: + case DateTimeQueryFilter.Today: activities = activities.Where(a => a.SetFor.Date == DateTime.Today.Date); break; - case DateQueryFilter.Tomorrow: + case DateTimeQueryFilter.Tomorrow: activities = activities.Where(a => a.SetFor.Date == DateTime.Today.AddDays(1).Date); break; - case DateQueryFilter.ThisWeek: - activities = activities.Where(a => a.SetFor.Date >= DateTime.Today.AddDays(-1).Date && a.SetFor.Date <= DateTime.Today.AddDays(+6).Date); + case DateTimeQueryFilter.ThisWeek: + DateTime today = DateTime.Today; + int delta = DayOfWeek.Saturday - today.DayOfWeek; + if (delta > 0) delta -= 7; + DateTime startOfWeek = today.AddDays(delta); + DateTime endOfWeek = startOfWeek.AddDays(6); + activities = activities.Where(a => a.SetFor.Date >= startOfWeek.Date && a.SetFor.Date <= endOfWeek.Date); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs index e76acbd..0057c5f 100644 --- a/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activities/GetShiftPlanActivitiesQueryHandler.cs @@ -1,16 +1,10 @@ namespace Brizco.Repository.Handlers.Activities; -public class GetShiftPlanActivitiesQueryHandler : IRequestHandler> +public class GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler> { - private IRepositoryWrapper _repositoryWrapper; - public GetShiftPlanActivitiesQueryHandler(IRepositoryWrapper repositoryWrapper) - { - _repositoryWrapper = repositoryWrapper; - } - public async Task> Handle(GetShiftPlanActivitiesQuery request, CancellationToken cancellationToken) { - var activities = await _repositoryWrapper.SetRepository() + var activities = await repositoryWrapper.SetRepository() .TableNoTracking .Where(a => a.ShiftPlanId == request.ShiftPlanId) .Select(ActivityMapper.ProjectToSDto) diff --git a/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs index df074bf..6e22766 100644 --- a/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlans/GetShiftPlansQueryHandler.cs @@ -2,24 +2,16 @@ namespace Brizco.Repository.Handlers.ShiftPlans; -public class GetShiftPlansQueryHandler : IRequestHandler> +public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler> { - private readonly IRepositoryWrapper _repositoryWrapper; - private readonly ICurrentUserService _currentUserService; - - public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) - { - _repositoryWrapper = repositoryWrapper; - _currentUserService = currentUserService; - } public async Task> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken) { - if (_currentUserService.ComplexId == null) + if (currentUserService.ComplexId == null) throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); - if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); - IQueryable baseQuery = _repositoryWrapper.SetRepository() + IQueryable baseQuery = repositoryWrapper.SetRepository() .TableNoTracking .OrderByDescending(s => s.CreatedAt) .Where(s => s.ComplexId == complexId); @@ -77,7 +69,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler s.PlanFor.Date >= startOfNextWeek.Date && s.PlanFor.Date <= endOfNextWeek.Date) .OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) @@ -138,13 +130,13 @@ public class GetShiftPlansQueryHandler : IRequestHandler() + var activitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); - var doneActivitiesCount = await _repositoryWrapper.SetRepository() + var doneActivitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); - var undoneActivitiesCount = await _repositoryWrapper.SetRepository() + var undoneActivitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == shiftPlan.PlanFor.Date && a.ShiftPlanId == shiftPlan.Id, cancellationToken); shiftPlan.UndoneActivitiesCount = undoneActivitiesCount; @@ -155,7 +147,7 @@ public class GetShiftPlansQueryHandler : IRequestHandler() + shiftPlan.StaffCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(spu => spu.ShiftPlanId == shiftPlan.Id, cancellationToken); diff --git a/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs index 4a6d024..6f50d57 100644 --- a/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shifts/GetShiftsQueryHandler.cs @@ -1,22 +1,13 @@ namespace Brizco.Repository.Handlers.Shifts; -public class GetShiftPlansQueryHandler : IRequestHandler> +public class GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper, UserManager userManager, ICurrentUserService currentUserService) + : IRequestHandler> { - private readonly IRepositoryWrapper _repositoryWrapper; - private readonly UserManager _userManager; - private readonly ICurrentUserService _currentUserService; - - public GetShiftPlansQueryHandler(IRepositoryWrapper repositoryWrapper,UserManager userManager, ICurrentUserService currentUserService) - { - _repositoryWrapper = repositoryWrapper; - _userManager = userManager; - _currentUserService = currentUserService; - } public async Task> Handle(GetShiftsQuery request, CancellationToken cancellationToken) { - if (_currentUserService.ComplexId == null) + if (currentUserService.ComplexId == null) throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); - if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); List shifts; @@ -24,46 +15,46 @@ public class GetShiftPlansQueryHandler : IRequestHandler().Entities - join shift in _repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id + var originalShifts = from shiftDay in repositoryWrapper.SetRepository().Entities + join shift in repositoryWrapper.SetRepository().Entities on shiftDay.ShiftId equals shift.Id where shiftDay.DayOfWeek == selectedDate.DayOfWeek && shift.ComplexId == complexId - orderby shift.StartAt descending + orderby shift.StartAt 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) continue; - var supervisor = await _userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString()); + var supervisor = await userManager.FindByIdAsync(existedShiftPlan.SupervisorId.ToString()); if (supervisor != null) shift.CurrentSupervisorFullName = supervisor.FirstName + " " + supervisor.LastName; - var activitiesCount = await _repositoryWrapper.SetRepository() + var activitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); - var doneActivitiesCount = await _repositoryWrapper.SetRepository() + var doneActivitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); - var undoneActivitiesCount = await _repositoryWrapper.SetRepository() + var undoneActivitiesCount = await repositoryWrapper.SetRepository() .TableNoTracking .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftPlanId == existedShiftPlan.Id, cancellationToken); shift.UndoneActivitiesCount = undoneActivitiesCount; shift.DoneActivitiesCount = doneActivitiesCount; shift.TotalActivitiesCount = activitiesCount; - switch (_currentUserService.RoleName) + switch (currentUserService.RoleName) { case null: continue; case ApplicationRoles.SuperVisor: { - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("User id is wrong"); - var existedSupervisorShiftPlan = await _repositoryWrapper.SetRepository() + 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; @@ -84,9 +75,9 @@ public class GetShiftPlansQueryHandler : IRequestHandler().TableNoTracking + shifts = await repositoryWrapper.SetRepository().TableNoTracking .Where(s => s.ComplexId == complexId) - .OrderByDescending(s => s.StartAt) + .OrderBy(s => s.StartAt) .Skip(request.Page * 15).Take(15) .Select(ShiftMapper.ProjectToSDto) .ToListAsync(cancellationToken); diff --git a/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs b/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs new file mode 100644 index 0000000..c892d7e --- /dev/null +++ b/Brizco.Repository/Handlers/Users/GetStaffQueryHandler.cs @@ -0,0 +1,106 @@ +using MD.PersianDateTime.Standard; +using Activity = Brizco.Domain.Entities.Tasks.Activity; + +namespace Brizco.Repository.Handlers.Users; + +public class GetStaffQueryHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler> +{ + public async Task> Handle(GetStaffQuery request, CancellationToken cancellationToken) + { + var count = request.Count ?? 10; + if (currentUserService.ComplexId == null) + throw new AppException("ComplexId is null", ApiResultStatusCode.NotFound); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new AppException("ComplexId is wrong", ApiResultStatusCode.NotFound); + + var baseQuery = repositoryWrapper.SetRepository() + .TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Where(s => s.ComplexId == complexId); + + List activities = new List(); + + switch (request.DateTimeQuery) + { + case DateTimeQueryFilter.Today: + activities = await baseQuery.Where(s => s.SetFor.Date == DateTime.Now.Date) + .Skip(request.Page * count).Take(count) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.Yesterday: + activities = await baseQuery.Where(s => s.SetFor.Date == DateTime.Now.AddDays(-1).Date) + .Skip(request.Page * count).Take(count) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.PastWeek: + DateTime pastWeekToday = DateTime.Today; + int pastWeekDelta = DayOfWeek.Saturday - pastWeekToday.DayOfWeek; + if (pastWeekDelta > 0) pastWeekDelta -= 7; + DateTime startOfPastWeek = DateTime.Today.AddDays(pastWeekDelta).AddDays(-7); + DateTime endOfPastWeek = startOfPastWeek.AddDays(6); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfPastWeek.Date && s.SetFor.Date <= endOfPastWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.NextWeek: + DateTime startOfNextWeek = DateTime.Today.AddDays(7 - (int)DateTime.Today.DayOfWeek + 1); + DateTime endOfNextWeek = startOfNextWeek.AddDays(6); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfNextWeek.Date && s.SetFor.Date <= endOfNextWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.ThisWeek: + DateTime today = DateTime.Today; + int delta = DayOfWeek.Saturday - today.DayOfWeek; + if (delta > 0) delta -= 7; + DateTime startOfWeek = today.AddDays(delta); + DateTime endOfWeek = startOfWeek.AddDays(6); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfWeek.Date && s.SetFor.Date <= endOfWeek.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.PastMonth: + + DateTime startOfPastMonth = new PersianDateTime(PersianDateTime.Today.AddMonths(-1).Year, PersianDateTime.Today.AddMonths(-1).Month, 1).ToDateTime(); + DateTime endOfPastMonth = startOfPastMonth.AddMonths(1); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfPastMonth.Date && s.SetFor.Date < endOfPastMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + case DateTimeQueryFilter.NextMonth: + DateTime startOfNextMonth = new PersianDateTime(PersianDateTime.Today.AddMonths(1).Year, PersianDateTime.Today.AddMonths(1).Month, 1).ToDateTime(); + DateTime endOfNextMonth = startOfNextMonth.AddMonths(1); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfNextMonth.Date && s.SetFor.Date < endOfNextMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + + case DateTimeQueryFilter.ThisMonth: + DateTime startOfThisMonth = new PersianDateTime(PersianDateTime.Today.Year, PersianDateTime.Today.Month, 1).ToDateTime(); + DateTime endOfThisMonth = startOfThisMonth.AddMonths(1); + activities = await baseQuery.Where(s => s.SetFor.Date >= startOfThisMonth.Date && s.SetFor.Date < endOfThisMonth.Date) + .OrderByDescending(s => s.CreatedAt) + .Select(ActivityMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + break; + default: + throw new ArgumentOutOfRangeException(); + + } + + var staffs = activities.Select(a => new StaffResponseSDto + { + FirstName = a.UserFirstName, + LastName = a.UserLastName, + Id = a.UserId + }).ToList(); + return staffs.DistinctBy(d => d.Id).ToList(); + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs new file mode 100644 index 0000000..47264ee --- /dev/null +++ b/Brizco.Repository/MartenHandlers/NewsFeeds/ChangeNewsFeedPinCommandHandler.cs @@ -0,0 +1,20 @@ +namespace Brizco.Repository.MartenHandlers.NewsFeeds; + +public class ChangeNewsFeedPinCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) + : IRequestHandler +{ + public async Task Handle(ChangeNewsFeedPinCommand request, CancellationToken cancellationToken) + { + if (currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + var ent = await martenRepositoryWrapper.SetRepository().GetEntityAsync(request.Id, cancellationToken); + if (ent.ComplexId != complexId) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + ent.IsPin = request.IsPin; + await martenRepositoryWrapper.SetRepository().AddOrUpdateEntityAsync(ent, cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs new file mode 100644 index 0000000..cc919f5 --- /dev/null +++ b/Brizco.Repository/MartenHandlers/NewsFeeds/CreateNewsFeedCommandHandler.cs @@ -0,0 +1,23 @@ +namespace Brizco.Repository.MartenHandlers.NewsFeeds; + +public class CreateNewsFeedCommandHandler (IMartenRepositoryWrapper martenRepositoryWrapper , ICurrentUserService currentUserService) + : IRequestHandler +{ + public async Task Handle(CreateNewsFeedCommand request, CancellationToken cancellationToken) + { + if (currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + var newsFeed = new NewsFeed + { + ComplexId = complexId, + Content = request.Content, + Title = request.Title, + IsPin = request.IsPin + }; + await martenRepositoryWrapper.SetRepository().AddOrUpdateEntityAsync(newsFeed, cancellationToken); + return newsFeed.Id; + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs new file mode 100644 index 0000000..640031b --- /dev/null +++ b/Brizco.Repository/MartenHandlers/NewsFeeds/DeleteNewsFeedCommandHandler.cs @@ -0,0 +1,19 @@ +namespace Brizco.Repository.MartenHandlers.NewsFeeds; + +public class DeleteNewsFeedCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) + : IRequestHandler +{ + public async Task Handle(DeleteNewsFeedCommand request, CancellationToken cancellationToken) + { + if (currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + var ent = await martenRepositoryWrapper.SetRepository().GetEntityAsync(request.Id, cancellationToken); + if (ent.ComplexId != complexId) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + await martenRepositoryWrapper.SetRepository().RemoveEntityAsync(ent, cancellationToken); + return true; + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs b/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs new file mode 100644 index 0000000..6ccaa1b --- /dev/null +++ b/Brizco.Repository/MartenHandlers/NewsFeeds/GetNewsFeedsQueryHandler.cs @@ -0,0 +1,22 @@ +namespace Brizco.Repository.MartenHandlers.NewsFeeds; + +public class GetNewsFeedsQueryHandler (IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler> +{ + public async Task> Handle(GetNewsFeedsQuery request, CancellationToken cancellationToken) + { + if (currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + var count = request.Count ?? 5; + var query = await martenRepositoryWrapper.SetRepository() + .GetQueryAsync(q=>q.ComplexId == complexId); + + query = query.Skip(request.Page * count) + .Take(count) + .OrderByDescending(c=>c.CreatedAt); + + return await query.ToListAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs b/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs index de0b94e..e64fc41 100644 --- a/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs +++ b/Brizco.Repository/MartenHandlers/Notifications/CreateNotificationHandlerCommand.cs @@ -1,22 +1,13 @@ -using Brizco.Domain.MartenEntities.Notifications; +namespace Brizco.Repository.MartenHandlers.Notifications; -namespace Brizco.Repository.MartenHandlers.Notifications; - -public class CreateNotificationHandlerCommand : IRequestHandler +public class CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) + : IRequestHandler { - private readonly IMartenRepositoryWrapper _martenRepositoryWrapper; - private readonly ICurrentUserService _currentUserService; - - public CreateNotificationHandlerCommand(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) - { - _martenRepositoryWrapper = martenRepositoryWrapper; - _currentUserService = currentUserService; - } public async Task Handle(CreateNotificationCommand request, CancellationToken cancellationToken) { - if (_currentUserService.ComplexId == null) + if (currentUserService.ComplexId == null) throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); - if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); var notification = new Notification { @@ -26,7 +17,7 @@ public class CreateNotificationHandlerCommand : IRequestHandler() + await martenRepositoryWrapper.SetRepository() .AddOrUpdateEntityAsync(notification, cancellationToken); return notification.Id; } diff --git a/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs new file mode 100644 index 0000000..dd1f82f --- /dev/null +++ b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsCountQueryHandler.cs @@ -0,0 +1,25 @@ +namespace Brizco.Repository.MartenHandlers.Notifications; + +public class GetNotificationsCountQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler +{ + public async Task Handle(GetNotificationsCountQuery request, CancellationToken cancellationToken) + { + + if (currentUserService.ComplexId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); + + Guid userId; + if (currentUserService.UserId == null) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); + if (!Guid.TryParse(currentUserService.UserId, out userId)) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong"); + + + var notifications = await martenRepositoryWrapper.SetRepository() + .GetEntitiesAsync(n => n.ComplexId == complexId && n.UserId == userId && !n.IsRead, cancellationToken); + + return notifications.Count; + } +} \ No newline at end of file diff --git a/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsQueryHandler.cs b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsQueryHandler.cs index 023ddd9..ebebb4a 100644 --- a/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsQueryHandler.cs +++ b/Brizco.Repository/MartenHandlers/Notifications/GetNotificationsQueryHandler.cs @@ -1,44 +1,37 @@ -using Brizco.Domain.MartenEntities.Notifications; +namespace Brizco.Repository.MartenHandlers.Notifications; -namespace Brizco.Repository.MartenHandlers.Notifications; - -public class GetNotificationsQueryHandler : IRequestHandler> +public class GetNotificationsQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler> { - private readonly IMartenRepositoryWrapper _martenRepositoryWrapper; - private readonly ICurrentUserService _currentUserService; - - public GetNotificationsQueryHandler(IMartenRepositoryWrapper martenRepositoryWrapper,ICurrentUserService currentUserService) - { - _martenRepositoryWrapper = martenRepositoryWrapper; - _currentUserService = currentUserService; - } public async Task> Handle(GetNotificationsQuery request, CancellationToken cancellationToken) { - if (_currentUserService.ComplexId == null) + if (currentUserService.ComplexId == null) throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is null"); - if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) + if (!Guid.TryParse(currentUserService.ComplexId, out Guid complexId)) throw new BaseApiException(ApiResultStatusCode.BadRequest, "Complex id is wrong"); - if (request.UserId == default) - throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); Guid userId; if (request.UserId == null) { - if (_currentUserService.UserId == null) + if (currentUserService.UserId == null) throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); - if (!Guid.TryParse(_currentUserService.UserId, out userId)) + if (!Guid.TryParse(currentUserService.UserId, out userId)) throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is wrong"); } else userId = request.UserId.Value; - var notifications = await _martenRepositoryWrapper.SetRepository() - .GetQueryAsync(n => n.ComplexId == complexId && n.UserId == userId); - var response = await notifications.Take(new Range(request.Page * request.Count, (request.Page * request.Count) + request.Count)) - .ToListAsync(cancellationToken); + if (userId == default) + throw new BaseApiException(ApiResultStatusCode.BadRequest, "User id is null"); + var count = request.Count ?? 10; + + var notifications = await martenRepositoryWrapper.SetRepository() + .GetEntitiesAsync(n => n.ComplexId == complexId && n.UserId == userId,cancellationToken); + var response = notifications.OrderByDescending(n=>n.CreatedAt) + .Take(new Range(request.Page * count, (request.Page * count) + count)) + .ToList(); return response; } } \ No newline at end of file diff --git a/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.Designer.cs b/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.Designer.cs new file mode 100644 index 0000000..6c8ae20 --- /dev/null +++ b/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.Designer.cs @@ -0,0 +1,1526 @@ +// +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("20240726144318_EditShiftPlanAddIsScheduled")] + partial class EditShiftPlanAddIsScheduled + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SupportPhone") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Complexes", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.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("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("UserId"); + + b.ToTable("ComplexUsers", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexUserId") + .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.HasKey("Id"); + + b.HasIndex("ComplexUserId"); + + b.HasIndex("RoleId"); + + b.ToTable("ComplexUserRoles", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", 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("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SectionId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("SectionId"); + + b.ToTable("Positions", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", 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("Permission") + .IsRequired() + .HasColumnType("text"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.ToTable("PositionPermissions", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", 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("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.ToTable("Sections", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", 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("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.ToTable("Routines", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CompleteDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("CompletePercent") + .HasColumnType("integer"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsScheduled") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanFor") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("SupervisorId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("SupervisorId"); + + b.ToTable("ShiftPlans", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", 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("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.HasIndex("ShiftPlanId"); + + b.HasIndex("UserId"); + + b.ToTable("ShiftPlanUsers", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", 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("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndAt") + .HasColumnType("interval"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("interval"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.ToTable("Shifts", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.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", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", 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("RoutineId") + .HasColumnType("uuid"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + b.ToTable("ShiftRoutines", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("integer"); + + b.Property("AmountType") + .HasColumnType("integer"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)"); + + b.Property("HasDisposed") + .HasColumnType("boolean"); + + b.Property("IsActivity") + .HasColumnType("boolean"); + + b.Property("IsDisposable") + .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("ScheduleType") + .HasColumnType("integer"); + + b.Property("SetFor") + .HasColumnType("timestamp without time zone"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.ToTable("Tasks", "public"); + + b.HasDiscriminator("Discriminator").HasValue("Task"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", 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("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskDays", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", 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("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskPositions", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", 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("RoutineId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoutineId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskRoutines", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.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", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EnglishName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PersianName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Roles", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Users.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("NationalId") + .IsRequired() + .HasColumnType("text"); + + 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("SelectedComplexUserRoleId") + .HasColumnType("uuid"); + + b.Property("SignUpStatus") + .HasColumnType("integer"); + + 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("Users", "public"); + }); + + 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("RoleClaims", "public"); + }); + + 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("Claims", "public"); + }); + + 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("Logins", "public"); + }); + + 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("UserRoles", "public"); + }); + + 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("Tokens", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Tasks.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UnDoneReason") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("ShiftPlanId"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany("Users") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.ComplexUser", "ComplexUser") + .WithMany("Roles") + .HasForeignKey("ComplexUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ComplexUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Complexes.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") + .WithMany("Permissions") + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Position"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "Supervisor") + .WithMany() + .HasForeignKey("SupervisorId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Position"); + + b.Navigation("ShiftPlan"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") + .WithMany("Shifts") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", b => + { + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") + .WithMany("Days") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Position"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") + .WithMany("Tasks") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Routine"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") + .WithMany() + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ShiftPlan"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => + { + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => + { + b.Navigation("Positions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => + { + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + + b.Navigation("Routines"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => + { + b.Navigation("Days"); + + b.Navigation("Positions"); + + b.Navigation("Routines"); + + b.Navigation("Shifts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.cs b/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.cs new file mode 100644 index 0000000..475af4e --- /dev/null +++ b/Brizco.Repository/Migrations/20240726144318_EditShiftPlanAddIsScheduled.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class EditShiftPlanAddIsScheduled : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsScheduled", + schema: "public", + table: "ShiftPlans", + type: "boolean", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsScheduled", + schema: "public", + table: "ShiftPlans"); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index cc7dcd1..640e7a8 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -18,12 +18,12 @@ namespace Brizco.Repository.Migrations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("public") - .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("ProductVersion", "8.0.6") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -70,7 +70,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Complexes", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -115,7 +115,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ComplexUsers", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -160,7 +160,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ComplexUserRoles", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -213,7 +213,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Positions", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -257,7 +257,7 @@ namespace Brizco.Repository.Migrations b.ToTable("PositionPermissions", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -305,7 +305,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Sections", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -353,7 +353,128 @@ namespace Brizco.Repository.Migrations b.ToTable("Routines", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CompleteDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("CompletePercent") + .HasColumnType("integer"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsCompleted") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("IsScheduled") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlanFor") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoutineId") + .HasColumnType("uuid"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("SupervisorId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + b.HasIndex("SupervisorId"); + + b.ToTable("ShiftPlans", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", 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("PositionId") + .HasColumnType("uuid"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("PositionId"); + + b.HasIndex("ShiftPlanId"); + + b.HasIndex("UserId"); + + b.ToTable("ShiftPlanUsers", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -407,7 +528,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Shifts", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftDay", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -450,125 +571,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ShiftDays", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CompleteDescription") - .IsRequired() - .HasColumnType("text"); - - b.Property("CompletePercent") - .HasColumnType("integer"); - - b.Property("ComplexId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsCompleted") - .HasColumnType("boolean"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("PlanFor") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("RoutineId") - .HasColumnType("uuid"); - - b.Property("ShiftId") - .HasColumnType("uuid"); - - b.Property("SupervisorId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ComplexId"); - - b.HasIndex("RoutineId"); - - b.HasIndex("ShiftId"); - - b.HasIndex("SupervisorId"); - - b.ToTable("ShiftPlans", "public"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", 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("PositionId") - .HasColumnType("uuid"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("ShiftPlanId") - .HasColumnType("uuid"); - - b.Property("UserId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("PositionId"); - - b.HasIndex("ShiftPlanId"); - - b.HasIndex("UserId"); - - b.ToTable("ShiftPlanUsers", "public"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -613,7 +616,7 @@ namespace Brizco.Repository.Migrations b.ToTable("ShiftRoutines", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -694,7 +697,7 @@ namespace Brizco.Repository.Migrations b.UseTphMappingStrategy(); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -737,7 +740,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskDays", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -782,7 +785,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskPositions", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -827,7 +830,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskRoutines", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskShift", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -872,7 +875,7 @@ namespace Brizco.Repository.Migrations b.ToTable("TaskShifts", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -916,7 +919,7 @@ namespace Brizco.Repository.Migrations b.ToTable("Roles", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationUser", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1108,9 +1111,9 @@ namespace Brizco.Repository.Migrations b.ToTable("Tokens", "public"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => { - b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + b.HasBaseType("Brizco.Domain.Entities.Tasks.Task"); b.Property("DoneAt") .HasColumnType("timestamp without time zone"); @@ -1142,14 +1145,14 @@ namespace Brizco.Repository.Migrations b.HasDiscriminator().HasValue("Activity"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany("Users") .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1159,14 +1162,14 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUserRole", b => { - b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser") + b.HasOne("Brizco.Domain.Entities.Complexes.ComplexUser", "ComplexUser") .WithMany("Roles") .HasForeignKey("ComplexUserId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", "Role") .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict); @@ -1176,14 +1179,14 @@ namespace Brizco.Repository.Migrations b.Navigation("Role"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany() .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + b.HasOne("Brizco.Domain.Entities.Complexes.Section", "Section") .WithMany("Positions") .HasForeignKey("SectionId") .OnDelete(DeleteBehavior.Restrict); @@ -1193,9 +1196,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Section"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.PositionPermission", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.PositionPermission", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") .WithMany("Permissions") .HasForeignKey("PositionId") .OnDelete(DeleteBehavior.Restrict); @@ -1203,9 +1206,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Position"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany() .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); @@ -1213,9 +1216,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Complex"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany() .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); @@ -1223,44 +1226,24 @@ namespace Brizco.Repository.Migrations b.Navigation("Complex"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") - .WithMany("Shifts") - .HasForeignKey("ComplexId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Complex"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => - { - b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") - .WithMany("Days") - .HasForeignKey("ShiftId") - .OnDelete(DeleteBehavior.Restrict); - - b.Navigation("Shift"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => - { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany() .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") .WithMany() .HasForeignKey("RoutineId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") .WithMany("Plans") .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "Supervisor") + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "Supervisor") .WithMany() .HasForeignKey("SupervisorId") .OnDelete(DeleteBehavior.Restrict); @@ -1274,19 +1257,19 @@ namespace Brizco.Repository.Migrations b.Navigation("Supervisor"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlanUser", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") .WithMany() .HasForeignKey("PositionId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") .WithMany("Users") .HasForeignKey("ShiftPlanId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1298,14 +1281,34 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => { - b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") .WithMany("Shifts") .HasForeignKey("RoutineId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") .WithMany("Routines") .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict); @@ -1315,9 +1318,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Shift"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany("Tasks") .HasForeignKey("ComplexId") .OnDelete(DeleteBehavior.Restrict); @@ -1325,9 +1328,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Complex"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskDay", b => { - b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") .WithMany("Days") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict); @@ -1335,14 +1338,14 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskPosition", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + b.HasOne("Brizco.Domain.Entities.Complexes.Position", "Position") .WithMany() .HasForeignKey("PositionId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") .WithMany("Positions") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict); @@ -1352,14 +1355,14 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskRoutine", b => { - b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + b.HasOne("Brizco.Domain.Entities.Routines.Routine", "Routine") .WithMany("Tasks") .HasForeignKey("RoutineId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") .WithMany("Routines") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict); @@ -1369,14 +1372,14 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.TaskShift", b => { - b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + b.HasOne("Brizco.Domain.Entities.Shifts.Shift", "Shift") .WithMany() .HasForeignKey("ShiftId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + b.HasOne("Brizco.Domain.Entities.Tasks.Task", "Task") .WithMany("Shifts") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Restrict); @@ -1386,9 +1389,9 @@ namespace Brizco.Repository.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + modelBuilder.Entity("Brizco.Domain.Entities.Users.ApplicationRole", b => { - b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + b.HasOne("Brizco.Domain.Entities.Complexes.Complex", "Complex") .WithMany("Roles") .HasForeignKey("ComplexId"); @@ -1397,7 +1400,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict); @@ -1405,7 +1408,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1413,7 +1416,7 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1421,12 +1424,12 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1434,20 +1437,20 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", null) .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); }); - modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Activity", b => { - b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + b.HasOne("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", "ShiftPlan") .WithMany() .HasForeignKey("ShiftPlanId") .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + b.HasOne("Brizco.Domain.Entities.Users.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict); @@ -1457,7 +1460,7 @@ namespace Brizco.Repository.Migrations b.Navigation("User"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Complex", b => { b.Navigation("Roles"); @@ -1468,29 +1471,34 @@ namespace Brizco.Repository.Migrations b.Navigation("Users"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.ComplexUser", b => { b.Navigation("Roles"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Position", b => { b.Navigation("Permissions"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + modelBuilder.Entity("Brizco.Domain.Entities.Complexes.Section", b => { b.Navigation("Positions"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + modelBuilder.Entity("Brizco.Domain.Entities.Routines.Routine", b => { b.Navigation("Shifts"); b.Navigation("Tasks"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + modelBuilder.Entity("Brizco.Domain.Entities.ShiftPlans.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shifts.Shift", b => { b.Navigation("Days"); @@ -1499,12 +1507,7 @@ namespace Brizco.Repository.Migrations b.Navigation("Routines"); }); - modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => - { - b.Navigation("Users"); - }); - - modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + modelBuilder.Entity("Brizco.Domain.Entities.Tasks.Task", b => { b.Navigation("Days"); diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..f82a9c4 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,28 @@ + + + + + + + + + + + + \ No newline at end of file