diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0c61f2d..db4df7b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "mapster.tool": { - "version": "8.3.0", + "version": "8.4.0", "commands": [ "dotnet-mapster" ] diff --git a/Brizco.Api/Controllers/ActivityController.cs b/Brizco.Api/Controllers/ActivityController.cs index e6272c6..116d158 100644 --- a/Brizco.Api/Controllers/ActivityController.cs +++ b/Brizco.Api/Controllers/ActivityController.cs @@ -21,6 +21,10 @@ public class ActivityController : ICarterModule .WithDisplayName("DoneActivity") .HasApiVersion(1.0); + group.MapPost("complete", CompleteActivityAsync) + .WithDisplayName("DoneActivity") + .HasApiVersion(1.0); + group.MapPost("undone/{id:guid}", UnDoneActivityAsync) .WithDisplayName("UnDoneActivity") .HasApiVersion(1.0); @@ -39,13 +43,16 @@ public class ActivityController : ICarterModule // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(page), cancellationToken)); + public async Task GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, [FromQuery] Guid? selectedShift, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetActivitiesQuery(Page: page, SelectedDate: selectedDate ?? 0 , SelectedShift: selectedShift ?? default), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, IActivityService activityService, CancellationToken cancellationToken) => TypedResults.Ok(await activityService.DoneActivityAsync(id,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)); diff --git a/Brizco.Api/Controllers/ShiftController.cs b/Brizco.Api/Controllers/ShiftController.cs index feeb88f..4b61e8a 100644 --- a/Brizco.Api/Controllers/ShiftController.cs +++ b/Brizco.Api/Controllers/ShiftController.cs @@ -29,8 +29,8 @@ public class ShiftController : ICarterModule } // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page,ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetShiftsQuery(page), cancellationToken)); + public async Task GetAllAsync([FromQuery] int page,ISender sender, CancellationToken cancellationToken, [FromQuery] long? selectedDate) + => TypedResults.Ok(await sender.Send(new GetShiftsQuery(Page: page, SelectedDate: selectedDate ?? 0), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) diff --git a/Brizco.Api/Controllers/ShiftPlanController.cs b/Brizco.Api/Controllers/ShiftPlanController.cs index b2adc69..8068a1a 100644 --- a/Brizco.Api/Controllers/ShiftPlanController.cs +++ b/Brizco.Api/Controllers/ShiftPlanController.cs @@ -17,6 +17,10 @@ public class ShiftPlanController : ICarterModule .WithDisplayName("GetShiftPlan") .HasApiVersion(1.0); + group.MapPost("{id:guid}/complete", CompletePlanAsync) + .WithDisplayName("DoneActivity") + .HasApiVersion(1.0); + group.MapPost("", Post) .HasApiVersion(1.0); @@ -28,10 +32,13 @@ public class ShiftPlanController : ICarterModule } + public async Task CompletePlanAsync(Guid id,[FromBody] CompleteShiftPlanRequestDto requestDtos, [FromServices] IShiftPlanService shiftPlanService, CancellationToken cancellationToken) + => TypedResults.Ok(await shiftPlanService.CompleteShiftPlanAsync(id,requestDtos, cancellationToken)); + // GET:Get All Entity - public async Task GetAllAsync([FromQuery] int page, ISender sender, CancellationToken cancellationToken) - => TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page), cancellationToken)); + public async Task GetAllAsync([FromQuery] int page, [FromQuery] long? selectedDate, ISender sender, CancellationToken cancellationToken) + => TypedResults.Ok(await sender.Send(new GetShiftPlansQuery(page , selectedDate ?? 0), cancellationToken)); // GET:Get An Entity By Id public async Task GetAsync(Guid id, ISender sender, CancellationToken cancellationToken) diff --git a/Brizco.Api/Controllers/UserController.cs b/Brizco.Api/Controllers/UserController.cs index d2e158f..5619d06 100644 --- a/Brizco.Api/Controllers/UserController.cs +++ b/Brizco.Api/Controllers/UserController.cs @@ -23,6 +23,10 @@ public class UserController : ICarterModule .WithDisplayName("GetUserProfile") .HasApiVersion(1.0); + group.MapPost("/role/change/{roleId}", ChangeUserRoleAsync) + .WithDisplayName("GetUserProfile") + .HasApiVersion(1.0); + group.MapPost("", Post) .HasApiVersion(1.0); @@ -33,6 +37,11 @@ public class UserController : ICarterModule .HasApiVersion(1.0); } + + public async Task ChangeUserRoleAsync(Guid roleId,IUserService userService, CancellationToken cancellationToken) + => TypedResults.Ok(await userService.ChangeUserRoleAsync(roleId,cancellationToken)); + + public async Task GetUserProfileAsync(IUserService userService, CancellationToken cancellationToken) => TypedResults.Ok(await userService.GetUserProfileAsync(cancellationToken)); diff --git a/Brizco.Api/Services/CurrentUserService.cs b/Brizco.Api/Services/CurrentUserService.cs index b491e9c..cc952d3 100644 --- a/Brizco.Api/Services/CurrentUserService.cs +++ b/Brizco.Api/Services/CurrentUserService.cs @@ -15,4 +15,6 @@ public class CurrentUserService : ICurrentUserService public string? RoleName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role); public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name); public string? ComplexId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("ComplexId"); + public string? RoleId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("RoleId"); + public List? Permissions => _httpContextAccessor.HttpContext?.User?.FindAll("Permission")?.Select(c=>c.Value)?.ToList(); } \ No newline at end of file diff --git a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs index 86aeea9..cfa3fa4 100644 --- a/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs +++ b/Brizco.Api/WebFramework/Configurations/ServiceExtensions.cs @@ -2,11 +2,14 @@ using Asp.Versioning; using AspNetCoreRateLimit; using AspNetCoreRateLimit.Redis; +using Brizco.Common.Models.Api; +using Brizco.Core.Models.Api; using Brizco.Domain.Entities.User; using Brizco.Domain.Models.Settings; using Brizco.Repository.Extensions; using Brizco.Repository.Models; using Microsoft.AspNetCore.ResponseCompression; +using Newtonsoft.Json.Serialization; using StackExchange.Redis.Extensions.Core.Configuration; using StackExchange.Redis.Extensions.Newtonsoft; using Task = System.Threading.Tasks.Task; @@ -160,7 +163,28 @@ public static class ServiceExtensions // Read the token out of the query string context.Token = accessToken.ToString(); return Task.CompletedTask; + }, + OnChallenge = async context => + { + // Call this to skip the default logic and avoid using the default response + context.HandleResponse(); + + // Write to the response in any way you wish + context.Response.StatusCode = (int)ApiResultStatusCode.UnAuthorized; + context.Response.ContentType = "application/json"; + var result = new ApiResult(false, ApiResultStatusCode.UnAuthorized, "You are not authorized!"); + var contractResolver = new DefaultContractResolver + { + NamingStrategy = new CamelCaseNamingStrategy() + }; + var json = JsonConvert.SerializeObject(result, new JsonSerializerSettings + { + ContractResolver = contractResolver, + Formatting = Formatting.Indented + }); + await context.Response.WriteAsync(json); } + }; }); } diff --git a/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs b/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs index 77ea608..064ffa3 100644 --- a/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs +++ b/Brizco.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs @@ -74,7 +74,8 @@ public class ExceptionHandlerMiddleware { message = exception.Message; } - if(exception.AdditionalData==null) + + if (exception.AdditionalData == null) await WriteToResponseAsync(); else await WriteToResponseWithObjectAsync(exception.AdditionalData); @@ -114,7 +115,8 @@ public class ExceptionHandlerMiddleware async Task WriteToResponseAsync() { if (context.Response.HasStarted) - throw new InvalidOperationException("The response has already started, the http status code middleware will not be executed."); + throw new InvalidOperationException( + "The response has already started, the http status code middleware will not be executed."); var result = new ApiResult(false, apiStatusCode, message); @@ -135,7 +137,6 @@ public class ExceptionHandlerMiddleware } - async Task WriteToResponseWithObjectAsync(object additionalData) { if (context.Response.HasStarted) diff --git a/Brizco.Common/Brizco.Common.csproj b/Brizco.Common/Brizco.Common.csproj index 75f79cb..3a22881 100644 --- a/Brizco.Common/Brizco.Common.csproj +++ b/Brizco.Common/Brizco.Common.csproj @@ -1,12 +1,26 @@  - - - net5.0 - 10 - enable - enable - - - - - - - - - diff --git a/Brizco.Common/Extensions/DateTimeExtensions.cs b/Brizco.Common/Extensions/DateTimeExtensions.cs index 48c39e1..eb0ad4e 100644 --- a/Brizco.Common/Extensions/DateTimeExtensions.cs +++ b/Brizco.Common/Extensions/DateTimeExtensions.cs @@ -30,7 +30,7 @@ namespace Brizco.Common.Extensions public static DateTime UnixTimeStampToDateTime(double unixTimeStamp) { // Unix timestamp is seconds past epoch - var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); + var dtDateTime = new DateTime(1970, 1, 1, 3, 30, 0, 0, DateTimeKind.Utc); dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime(); return dtDateTime; } diff --git a/Brizco.Core/BaseServices/Abstracts/IJwtService.cs b/Brizco.Core/BaseServices/Abstracts/IJwtService.cs index 4a8840f..dec7e79 100644 --- a/Brizco.Core/BaseServices/Abstracts/IJwtService.cs +++ b/Brizco.Core/BaseServices/Abstracts/IJwtService.cs @@ -7,7 +7,8 @@ public interface IJwtService : IScopedDependency Task> Generate(TUser user) where TUser : ApplicationUser; Task> Generate(TUser user, Guid complexId, Guid roleId) where TUser : ApplicationUser; - Task> Generate(TUser user, Guid complexId, Guid roleId) where TUser : ApplicationUser; Task> Generate(TUser user, Guid complexId) where TUser : ApplicationUser; Task> Generate(TUser user) where TUser : ApplicationUser; + + Task> Generate(TUser user, Guid complexId, Guid roleId) where TUser : ApplicationUser; } \ No newline at end of file diff --git a/Brizco.Core/BaseServices/JwtService.cs b/Brizco.Core/BaseServices/JwtService.cs index 78a8572..c4d4f8c 100644 --- a/Brizco.Core/BaseServices/JwtService.cs +++ b/Brizco.Core/BaseServices/JwtService.cs @@ -179,6 +179,7 @@ public class JwtService : IJwtService claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName)); claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString())); claims.Add(new Claim(ClaimTypes.Role,applicationRole.EnglishName)); + claims.Add(new Claim("RoleId", applicationRole.Id.ToString())); if (baseUser.Email != null) claims.Add(new Claim(ClaimTypes.Email, baseUser.Email)); claims.AddRange(roleClaims); diff --git a/Brizco.Core/CoreServices/PageService.cs b/Brizco.Core/CoreServices/PageService.cs index fd33b94..3401151 100644 --- a/Brizco.Core/CoreServices/PageService.cs +++ b/Brizco.Core/CoreServices/PageService.cs @@ -1,4 +1,8 @@ using Brizco.Domain.Entities.Task; +using System.Linq; +using Brizco.Domain.Entities.Routine; +using Brizco.Domain.Entities.Shift; +using Task = Brizco.Domain.Entities.Task.Task; namespace Brizco.Core.CoreServices; @@ -6,11 +10,16 @@ public class PageService : IPageService { private readonly ICurrentUserService _currentUserService; private readonly IRepositoryWrapper _repositoryWrapper; + private readonly RoleManager _roleManager; - public PageService(ICurrentUserService currentUserService,IRepositoryWrapper repositoryWrapper) + public PageService( + ICurrentUserService currentUserService, + IRepositoryWrapper repositoryWrapper, + RoleManager roleManager) { _currentUserService = currentUserService; _repositoryWrapper = repositoryWrapper; + _roleManager = roleManager; } public async Task GetAppDashboardAsync(CancellationToken cancellationToken) { @@ -18,17 +27,129 @@ public class PageService : IPageService throw new AppException("User id is null "); if (Guid.TryParse(_currentUserService.UserId, out Guid userId)!) throw new AppException("User id is wrong"); + if (Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)!) + throw new AppException("Complex id is wrong"); var todayTasks = await _repositoryWrapper.SetRepository() .TableNoTracking .Where(a => a.UserId == userId) .ToListAsync(cancellationToken); - - return new AppDashboardPageDto + var page = new AppDashboardPageDto { DoneActivitiesToday = todayTasks.Count(t => t.IsDone), TotalActivitiesToday = todayTasks.Count, UnDoneActivitiesToday = todayTasks.Count(t => t.IsDone!) }; + + if (_currentUserService.Permissions != null) + { + int totalStepCount = 0; + int completeStepCount = 0; + string currentStep = string.Empty; + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageRoutines)) + { + totalStepCount++; + var hasRoutine = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r=>r.ComplexId== complexId, cancellationToken); + if(hasRoutine) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش روتین ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageSections)) + { + totalStepCount++; + var hasSection = await _repositoryWrapper.SetRepository
() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasSection) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش سکشن ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManagePositions)) + { + totalStepCount++; + var hasPosition = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasPosition) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش پوزیشن ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageStaffs)) + { + totalStepCount++; + var hasStaff = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasStaff) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش کاربر ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageShifts)) + { + totalStepCount++; + var hasShift = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasShift) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش شیفت ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageTasks)) + { + totalStepCount++; + var hasTask = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasTask) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش تسک ها"; + } + } + if (_currentUserService.Permissions.Exists(s => s == ApplicationPermission.ManageShiftPlans)) + { + totalStepCount++; + var hasStaff = await _repositoryWrapper.SetRepository() + .TableNoTracking + .AnyAsync(r => r.ComplexId == complexId, cancellationToken); + if (hasStaff) + completeStepCount++; + else + { + if (currentStep.IsNullOrEmpty()) + currentStep = "تکمیل بخش شیفت بندی ها"; + } + } + + page.SignUpCompletePercent = ((totalStepCount * 100) / completeStepCount); + page.CurrentSignUpStep = currentStep; + + } + + return page; } } \ No newline at end of file diff --git a/Brizco.Core/EntityServices/Abstracts/IActivityService.cs b/Brizco.Core/EntityServices/Abstracts/IActivityService.cs index 5450230..5a571c8 100644 --- a/Brizco.Core/EntityServices/Abstracts/IActivityService.cs +++ b/Brizco.Core/EntityServices/Abstracts/IActivityService.cs @@ -4,5 +4,6 @@ public interface IActivityService : IScopedDependency { Task CreateActivitiesByShiftPlan(Guid shiftPlanId, CancellationToken cancellationToken); Task DoneActivityAsync(Guid activityId, CancellationToken cancellationToken); + Task CompleteActivitiesAsync(List requestDtos, CancellationToken cancellationToken); Task UnDoneActivityAsync(Guid activityId, string undoneReason, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs b/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs index 1a7df71..bcece6c 100644 --- a/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs +++ b/Brizco.Core/EntityServices/Abstracts/IShiftPlanService.cs @@ -4,4 +4,5 @@ public interface IShiftPlanService : IScopedDependency { Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId,bool isChangeToShift , bool isDisable); Task CreateAsync(CreateShiftPlanCommand createShiftPlanCommand,CancellationToken cancellationToken); + Task CompleteShiftPlanAsync(Guid id,CompleteShiftPlanRequestDto requestDtos, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/Brizco.Core/EntityServices/Abstracts/IUserService.cs b/Brizco.Core/EntityServices/Abstracts/IUserService.cs index 3471b1f..1a7d040 100644 --- a/Brizco.Core/EntityServices/Abstracts/IUserService.cs +++ b/Brizco.Core/EntityServices/Abstracts/IUserService.cs @@ -3,6 +3,7 @@ public interface IUserService : IScopedDependency { Task GetUserProfileAsync(CancellationToken cancellationToken); + Task> ChangeUserRoleAsync(Guid roleId,CancellationToken cancellationToken); Task> GetUserRolesAsync(CancellationToken cancellationToken); Task> GetUserRolesAsync(Guid userId, CancellationToken cancellationToken); Task> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default); diff --git a/Brizco.Core/EntityServices/ActivityService.cs b/Brizco.Core/EntityServices/ActivityService.cs index e1799ca..a86f750 100644 --- a/Brizco.Core/EntityServices/ActivityService.cs +++ b/Brizco.Core/EntityServices/ActivityService.cs @@ -1,7 +1,6 @@ using Brizco.Domain.CommandQueries.Queries; using Brizco.Domain.Entities.Shift; using Brizco.Domain.Entities.Task; -using System.Threading.Tasks; namespace Brizco.Core.EntityServices; @@ -31,6 +30,23 @@ public class ActivityService : IActivityService return true; } + public async Task CompleteActivitiesAsync(List requestDtos, CancellationToken cancellationToken) + { + foreach (var activityRequestDto in requestDtos) + { + 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); + } + + return true; + } + public async Task UnDoneActivityAsync(Guid activityId,string undoneReason, CancellationToken cancellationToken) { @@ -85,7 +101,7 @@ GROUP BY t.""Id""").ToListAsync(cancellationToken); if (fundedUser != null) { await _mediator.Send(new CreateActivityCommand(task.Type, task.Title, task.Description, task.IsDisposable, - task.SetFor, task.HasDisposed, task.Amount, task.AmountType, + shiftPlan.PlanFor, task.HasDisposed, task.Amount, task.AmountType, task.ScheduleType, shiftPlan.ShiftId, new List { fundedUser.UserId }),cancellationToken); } } diff --git a/Brizco.Core/EntityServices/ShiftPlanService.cs b/Brizco.Core/EntityServices/ShiftPlanService.cs index 23621e9..4bf1e59 100644 --- a/Brizco.Core/EntityServices/ShiftPlanService.cs +++ b/Brizco.Core/EntityServices/ShiftPlanService.cs @@ -1,4 +1,5 @@ using Brizco.Domain.CommandQueries.Queries; +using Brizco.Domain.Entities.Shift; namespace Brizco.Core.EntityServices; @@ -6,11 +7,13 @@ public class ShiftPlanService : IShiftPlanService { private readonly ISender _sender; private readonly IActivityService _activityService; + private readonly IRepositoryWrapper _repositoryWrapper; - public ShiftPlanService(ISender sender,IActivityService activityService) + public ShiftPlanService(ISender sender,IActivityService activityService,IRepositoryWrapper repositoryWrapper) { _sender = sender; _activityService = activityService; + _repositoryWrapper = repositoryWrapper; } public async Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId, bool isChangeToShift, bool isDisable) { @@ -24,4 +27,18 @@ public class ShiftPlanService : IShiftPlanService await _activityService.CreateActivitiesByShiftPlan(shiftPlan.Id, cancellationToken); return true; } + + public async Task CompleteShiftPlanAsync(Guid id, CompleteShiftPlanRequestDto requestDtos, CancellationToken cancellationToken) + { + var shiftPlan = await _repositoryWrapper.SetRepository() + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == id, cancellationToken); + if (shiftPlan == null) + throw new AppException("Shift plan not found", ApiResultStatusCode.NotFound); + + shiftPlan.CompletePlan(requestDtos.CompleteDescription,requestDtos.CompletePercent); + _repositoryWrapper.SetRepository().Update(shiftPlan); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await _activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); + return true; + } } \ No newline at end of file diff --git a/Brizco.Core/EntityServices/UserService.cs b/Brizco.Core/EntityServices/UserService.cs index a2786c4..ad8a417 100644 --- a/Brizco.Core/EntityServices/UserService.cs +++ b/Brizco.Core/EntityServices/UserService.cs @@ -12,18 +12,21 @@ public class UserService : IUserService private readonly RoleManager _roleManager; private readonly ISender _sender; private readonly IRepositoryWrapper _repositoryWrapper; + private readonly IJwtService _jwtService; public UserService(ICurrentUserService currentUserService, UserManager userManager, RoleManager roleManager, ISender sender, - IRepositoryWrapper repositoryWrapper) + IRepositoryWrapper repositoryWrapper, + IJwtService jwtService) { _currentUserService = currentUserService; _userManager = userManager; _roleManager = roleManager; _sender = sender; _repositoryWrapper = repositoryWrapper; + _jwtService = jwtService; } @@ -47,7 +50,8 @@ public class UserService : IUserService userSDto.SelectedComplexName = complexUserRole!.ComplexName; userSDto.SelectedRoleName = complexUserRole!.RoleName; - var role = await _roleManager.FindByIdAsync(complexUserRole.RoleId.ToString()); + response.User.SelectedRoleId = complexUserRole!.Id; + var role = await _roleManager.FindByIdAsync(complexUserRole.RoleId.ToString()); if (role != null) { var roleClaims = await _roleManager.GetClaimsAsync(role); @@ -59,6 +63,43 @@ public class UserService : IUserService return response; } + public async Task> ChangeUserRoleAsync(Guid roleId, CancellationToken cancellationToken) + { + + if (!Guid.TryParse(_currentUserService.UserId, out var userId)) + throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized); + AccessToken jwt; + var complexUserRole = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.Id == roleId) + .Select(ComplexUserRoleMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + if (complexUserRole == null) + throw new AppException("Role not found", ApiResultStatusCode.NotFound); + + var complexUser = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(mcu => mcu.Id == complexUserRole.ComplexUserId) + .Select(ComplexUserMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + var user = await _userManager.FindByIdAsync(userId.ToString()); + if (user == null) + throw new AppException("User not found", ApiResultStatusCode.NotFound); + if (complexUser?.UserId != user.Id) + throw new AppException("User role is wrong", ApiResultStatusCode.BadRequest); + + user.SelectedComplexUserRoleId = complexUserRole.Id; + await _userManager.UpdateAsync(user); + jwt = (await _jwtService.Generate(user, complexUser.ComplexId, complexUserRole.RoleId)).Adapt>(); + jwt.User.SelectedComplexName = complexUser.ComplexName; + jwt.User.SelectedRoleName = complexUserRole.RoleName; + jwt.User.SelectedRoleId = complexUserRole.Id; + jwt.Roles = await GetUserRolesAsync(cancellationToken); + return jwt; + } + public async Task> GetUserRolesAsync(CancellationToken cancellationToken) { if (!Guid.TryParse(_currentUserService.UserId, out var userId)) @@ -122,6 +163,7 @@ public class UserService : IUserService return response; } + public async Task> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default) { if (_currentUserService.ComplexId.IsNullOrEmpty()) diff --git a/Brizco.Domain/Brizco.Domain.csproj b/Brizco.Domain/Brizco.Domain.csproj index 378d834..9d80ecb 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -1,9 +1,10 @@  - + - + - + @@ -72,7 +73,6 @@ - diff --git a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs index a1a0d5f..1533582 100644 --- a/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ActivityQueries.cs @@ -1,6 +1,6 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetActivitiesQuery(int Page = 0) : +public sealed record GetActivitiesQuery(int Page = 0 , long SelectedDate = 0 , Guid SelectedShift = default) : IRequest>; public sealed record GetActivityQuery(Guid Id) : diff --git a/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs b/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs index 56c69f6..47a7401 100644 --- a/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ShiftPlanQueries.cs @@ -1,6 +1,6 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetShiftPlansQuery(int Page = 0) : +public sealed record GetShiftPlansQuery(int Page = 0 , long SelectedDate = 0) : IRequest>; public sealed record GetShiftPlanQuery(Guid Id) : diff --git a/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs b/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs index c33f490..77da97d 100644 --- a/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs +++ b/Brizco.Domain/CommandQueries/Queries/ShiftQueries.cs @@ -1,6 +1,6 @@ namespace Brizco.Domain.CommandQueries.Queries; -public sealed record GetShiftsQuery(int Page = 0) : +public sealed record GetShiftsQuery(int Page = 0,long SelectedDate = 0) : IRequest>; public sealed record GetShiftQuery(Guid Id) : diff --git a/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs index b0a39b9..a90d57d 100644 --- a/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs +++ b/Brizco.Domain/Dtos/LargDtos/ShiftPlanLDto.cs @@ -6,6 +6,9 @@ public class ShiftPlanLDto : BaseDto { public DateTime PlanFor { get; set; } public Guid RoutineId { get; set; } + public bool IsCompleted { get; internal set; } + public int CompletePercent { get; internal set; } + public string CompleteDescription { get; internal set; } = string.Empty; public Guid ShiftId { get; set; } public List Users { get; set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs b/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs index 5987b14..1bfd5cc 100644 --- a/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs +++ b/Brizco.Domain/Dtos/PageDto/AppDashboardPageDto.cs @@ -5,4 +5,9 @@ public class AppDashboardPageDto public int UnDoneActivitiesToday { get; set; } public int DoneActivitiesToday { get; set; } public int TotalActivitiesToday { get; set; } + public int TotalStaffToday { get; set; } + + public string CurrentSignUpStep { get; set; } = string.Empty; + public int SignUpCompletePercent { get; set; } + } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/RequestDtos/CompleteActivityRequestDto.cs b/Brizco.Domain/Dtos/RequestDtos/CompleteActivityRequestDto.cs new file mode 100644 index 0000000..60d4784 --- /dev/null +++ b/Brizco.Domain/Dtos/RequestDtos/CompleteActivityRequestDto.cs @@ -0,0 +1,8 @@ +namespace Brizco.Domain.Dtos.RequestDtos; + +public class CompleteActivityRequestDto +{ + public Guid ActivityId { get; set; } + public bool IsCompleted { get; set; } + public string PerformanceDescription { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/RequestDtos/CompleteShiftPlanRequestDto.cs b/Brizco.Domain/Dtos/RequestDtos/CompleteShiftPlanRequestDto.cs new file mode 100644 index 0000000..c83066d --- /dev/null +++ b/Brizco.Domain/Dtos/RequestDtos/CompleteShiftPlanRequestDto.cs @@ -0,0 +1,8 @@ +namespace Brizco.Domain.Dtos.RequestDtos; + +public class CompleteShiftPlanRequestDto +{ + public string CompleteDescription { get; set; } = string.Empty; + public List CompleteActivities { get; set; } = new(); + public int CompletePercent { get; internal set; } +} \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs index 3f3c02d..fe8501f 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ActivitySDto.cs @@ -16,8 +16,12 @@ public class ActivitySDto : BaseDto public DateTime DoneAt { get; internal set; } public bool IsDone { get; set; } public string PerformanceDescription { get; internal set; } = string.Empty; + public string UserFirstName { get; set; } = string.Empty; + public string UserLastName { get; set; } = string.Empty; + public string UserFullName => UserFirstName + " " + UserLastName; public int Amount { get; internal set; } + public Guid ShiftId { get; internal set; } public PurchaseAmountType AmountType { get; internal set; } } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs index f1684c1..0d7de34 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ApplicationUserSDto.cs @@ -12,6 +12,7 @@ public class ApplicationUserSDto : BaseDto public SignUpStatus SignUpStatus { get; set; } public string SelectedRoleName { get; set; } = string.Empty; public string SelectedComplexName { get; set; } = string.Empty; + public Guid SelectedRoleId { get; set; } public string NationalId { get; set; } = string.Empty; public List RoleIds { get; set; } = new(); diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs index 6358f58..57aba33 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftPlanSDto.cs @@ -4,8 +4,13 @@ namespace Brizco.Domain.Dtos.SmallDtos; public class ShiftPlanSDto : BaseDto { - public DateTime StartAt { get; set; } - public DateTime EndAt { get; set; } + public DateTime PlanFor { get; internal set; } + public bool IsCompleted { get; internal set; } + public int UndoneActivitiesCount { get; set; } + public int DoneActivitiesCount { get; set; } + public int TotalActivitiesCount { get; set; } + public int CompletePercent { get; internal set; } + public string CompleteDescription { get; internal set; } = string.Empty; public Guid ShiftId { get; set; } public string ShiftTitle { get; internal set; } = string.Empty; } \ No newline at end of file diff --git a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs index bde623e..a1ca515 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ShiftSDto.cs @@ -5,6 +5,10 @@ public class ShiftSDto : BaseDto { public string Title { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; + public int UndoneActivitiesCount { get; set; } + public int DoneActivitiesCount { get; set; } + public int TotalActivitiesCount { get; set; } + public bool IsCompleted { get; set; } public TimeSpan StartAt { get; set; } public TimeSpan EndAt { get; set; } public Guid ComplexId { get; set; } diff --git a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs index 562e9ca..da97850 100644 --- a/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs +++ b/Brizco.Domain/Entities/Shift/Aggregate.Shift.cs @@ -16,7 +16,7 @@ public partial class Shift } public ShiftPlan AddPlan(DateTime planDate,Guid routineId) { - var plan = new ShiftPlan(planDate , routineId, Id); + var plan = new ShiftPlan(planDate , routineId, Id ,this.ComplexId); Plans.Add(plan); return plan; } @@ -37,4 +37,11 @@ public partial class ShiftPlan Users.Add(planUser); return planUser; } + + public void CompletePlan(string completeDescription,int completePercent) + { + IsCompleted = true; + CompleteDescription = completeDescription; + CompletePercent = completePercent; + } } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Shift/ShiftPlan.cs b/Brizco.Domain/Entities/Shift/ShiftPlan.cs index 308e1d4..ed7ea38 100644 --- a/Brizco.Domain/Entities/Shift/ShiftPlan.cs +++ b/Brizco.Domain/Entities/Shift/ShiftPlan.cs @@ -10,19 +10,27 @@ public partial class ShiftPlan : ApiEntity } - internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId) + internal ShiftPlan(DateTime planFor, Guid routineId,Guid shiftId, Guid complexId) { PlanFor = planFor; RoutineId = routineId; ShiftId = shiftId; + ComplexId = complexId; } public DateTime PlanFor { get; internal set; } + public bool IsCompleted { get; internal set; } + public int CompletePercent { get; internal set; } + public string CompleteDescription { get; internal set; } = string.Empty; + public Guid ShiftId { get; internal set; } public virtual Shift? Shift { get; internal set; } public Guid RoutineId { get; internal set; } public virtual Routine.Routine? Routine { get; internal set; } + public Guid ComplexId { get; internal set; } + public Complex.Complex? Complex { get; internal set; } + public List Users { get; internal set; } = new(); } \ No newline at end of file diff --git a/Brizco.Domain/Entities/Task/Aggregate.Task.cs b/Brizco.Domain/Entities/Task/Aggregate.Task.cs index edabf28..16c612c 100644 --- a/Brizco.Domain/Entities/Task/Aggregate.Task.cs +++ b/Brizco.Domain/Entities/Task/Aggregate.Task.cs @@ -65,13 +65,13 @@ public partial class Task { foreach (var positionId in positionIds) { - var position = new TaskPosition(positionId,Id); + var position = new TaskPosition(positionId, Id); Positions.Add(position); } } public TaskPosition AddPosition(Guid positionId) { - var position = new TaskPosition(positionId,Id); + var position = new TaskPosition(positionId, Id); Positions.Add(position); return position; } @@ -82,13 +82,13 @@ public partial class Task { foreach (var routineId in routineIds) { - var routine = new TaskRoutine(routineId,Id); + var routine = new TaskRoutine(routineId, Id); Routines.Add(routine); } } public TaskRoutine AddRoutine(Guid routineId) { - var routine = new TaskRoutine(routineId,Id); + var routine = new TaskRoutine(routineId, Id); Routines.Add(routine); return routine; } @@ -146,6 +146,16 @@ public partial class Activity Status = ActivityStatus.Done; } + public void CompleteActivity(bool isDone, string performanceDescription) + { + if (!isDone) + Status = ActivityStatus.UnDone; + else + Status = ActivityStatus.Complete; + IsDone = isDone; + PerformanceDescription = performanceDescription; + } + public void UnDoneActivity(string undoneReason) { IsDone = false; diff --git a/Brizco.Domain/Mappers/ActivityMapper.g.cs b/Brizco.Domain/Mappers/ActivityMapper.g.cs index 51a437d..b74482f 100644 --- a/Brizco.Domain/Mappers/ActivityMapper.g.cs +++ b/Brizco.Domain/Mappers/ActivityMapper.g.cs @@ -2,7 +2,10 @@ using System; using System.Linq.Expressions; using Brizco.Domain.Dtos.LargDtos; using Brizco.Domain.Dtos.SmallDtos; +using Brizco.Domain.Entities.Shift; using Brizco.Domain.Entities.Task; +using Brizco.Domain.Entities.User; +using Mapster.Models; namespace Brizco.Domain.Mappers { @@ -17,6 +20,13 @@ namespace Brizco.Domain.Mappers IsDone = p1.IsDone, UnDoneReason = p1.UnDoneReason, PerformanceDescription = p1.PerformanceDescription, + User = new ApplicationUser() + { + FirstName = p1.UserFirstName, + LastName = p1.UserLastName + }, + ShiftId = p1.ShiftId, + Shift = new Shift() {Id = p1.ShiftId}, Type = p1.Type, Title = p1.Title, Description = p1.Description, @@ -42,6 +52,9 @@ namespace Brizco.Domain.Mappers result.IsDone = p2.IsDone; result.UnDoneReason = p2.UnDoneReason; result.PerformanceDescription = p2.PerformanceDescription; + result.User = funcMain1(new Never(), result.User, p2); + result.ShiftId = p2.ShiftId; + result.Shift = funcMain2(new Never(), result.Shift, p2); result.Type = p2.Type; result.Title = p2.Title; result.Description = p2.Description; @@ -55,73 +68,20 @@ namespace Brizco.Domain.Mappers return result; } - public static Expression> ProjectToActivity => p4 => new Activity() + public static Expression> ProjectToActivity => p8 => new Activity() { - Status = p4.Status, - DoneAt = p4.DoneAt, - IsDone = p4.IsDone, - UnDoneReason = p4.UnDoneReason, - PerformanceDescription = p4.PerformanceDescription, - Type = p4.Type, - Title = p4.Title, - Description = p4.Description, - IsDisposable = p4.IsDisposable, - SetFor = p4.SetFor, - HasDisposed = p4.HasDisposed, - ScheduleType = p4.ScheduleType, - Amount = p4.Amount, - AmountType = p4.AmountType, - Id = p4.Id - }; - public static ActivitySDto AdaptToSDto(this Activity p5) - { - return p5 == null ? null : new ActivitySDto() + Status = p8.Status, + DoneAt = p8.DoneAt, + IsDone = p8.IsDone, + UnDoneReason = p8.UnDoneReason, + PerformanceDescription = p8.PerformanceDescription, + User = new ApplicationUser() { - Type = p5.Type, - Title = p5.Title, - Description = p5.Description, - IsDisposable = p5.IsDisposable, - SetFor = p5.SetFor, - HasDisposed = p5.HasDisposed, - ScheduleType = p5.ScheduleType, - UnDoneReason = p5.UnDoneReason, - Status = p5.Status, - DoneAt = p5.DoneAt, - IsDone = p5.IsDone, - PerformanceDescription = p5.PerformanceDescription, - Amount = p5.Amount, - AmountType = p5.AmountType, - Id = p5.Id - }; - } - public static ActivitySDto AdaptTo(this Activity p6, ActivitySDto p7) - { - if (p6 == null) - { - return null; - } - ActivitySDto result = p7 ?? new ActivitySDto(); - - result.Type = p6.Type; - result.Title = p6.Title; - result.Description = p6.Description; - result.IsDisposable = p6.IsDisposable; - result.SetFor = p6.SetFor; - result.HasDisposed = p6.HasDisposed; - result.ScheduleType = p6.ScheduleType; - result.UnDoneReason = p6.UnDoneReason; - result.Status = p6.Status; - result.DoneAt = p6.DoneAt; - result.IsDone = p6.IsDone; - result.PerformanceDescription = p6.PerformanceDescription; - result.Amount = p6.Amount; - result.AmountType = p6.AmountType; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new ActivitySDto() - { + FirstName = p8.UserFirstName, + LastName = p8.UserLastName + }, + ShiftId = p8.ShiftId, + Shift = new Shift() {Id = p8.ShiftId}, Type = p8.Type, Title = p8.Title, Description = p8.Description, @@ -129,132 +89,220 @@ namespace Brizco.Domain.Mappers SetFor = p8.SetFor, HasDisposed = p8.HasDisposed, ScheduleType = p8.ScheduleType, - UnDoneReason = p8.UnDoneReason, - Status = p8.Status, - DoneAt = p8.DoneAt, - IsDone = p8.IsDone, - PerformanceDescription = p8.PerformanceDescription, Amount = p8.Amount, AmountType = p8.AmountType, Id = p8.Id }; - public static Activity AdaptToActivity(this ActivityLDto p9) + public static ActivitySDto AdaptToSDto(this Activity p9) { - return p9 == null ? null : new Activity() + return p9 == null ? null : new ActivitySDto() { - Status = p9.Status, - DoneAt = p9.DoneAt, - IsDone = p9.IsDone, - PerformanceDescription = p9.PerformanceDescription, Type = p9.Type, Title = p9.Title, Description = p9.Description, IsDisposable = p9.IsDisposable, SetFor = p9.SetFor, HasDisposed = p9.HasDisposed, + ScheduleType = p9.ScheduleType, + UnDoneReason = p9.UnDoneReason, + Status = p9.Status, + DoneAt = p9.DoneAt, + IsDone = p9.IsDone, + PerformanceDescription = p9.PerformanceDescription, + UserFirstName = p9.User != null ? p9.User.FirstName : string.Empty, + UserLastName = p9.User != null ? p9.User.LastName : string.Empty, Amount = p9.Amount, + ShiftId = p9.ShiftId, AmountType = p9.AmountType, Id = p9.Id }; } - public static Activity AdaptTo(this ActivityLDto p10, Activity p11) + public static ActivitySDto AdaptTo(this Activity p10, ActivitySDto p11) { if (p10 == null) { return null; } - Activity result = p11 ?? new Activity(); + ActivitySDto result = p11 ?? new ActivitySDto(); - result.Status = p10.Status; - result.DoneAt = p10.DoneAt; - result.IsDone = p10.IsDone; - result.PerformanceDescription = p10.PerformanceDescription; result.Type = p10.Type; result.Title = p10.Title; result.Description = p10.Description; result.IsDisposable = p10.IsDisposable; result.SetFor = p10.SetFor; result.HasDisposed = p10.HasDisposed; + result.ScheduleType = p10.ScheduleType; + result.UnDoneReason = p10.UnDoneReason; + result.Status = p10.Status; + result.DoneAt = p10.DoneAt; + result.IsDone = p10.IsDone; + 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.Amount = p10.Amount; + result.ShiftId = p10.ShiftId; result.AmountType = p10.AmountType; result.Id = p10.Id; return result; } - public static Expression> ProjectLDtoToActivity => p12 => new Activity() + public static Expression> ProjectToSDto => p12 => new ActivitySDto() { - Status = p12.Status, - DoneAt = p12.DoneAt, - IsDone = p12.IsDone, - PerformanceDescription = p12.PerformanceDescription, Type = p12.Type, Title = p12.Title, Description = p12.Description, IsDisposable = p12.IsDisposable, SetFor = p12.SetFor, HasDisposed = p12.HasDisposed, + ScheduleType = p12.ScheduleType, + UnDoneReason = p12.UnDoneReason, + Status = p12.Status, + DoneAt = p12.DoneAt, + IsDone = p12.IsDone, + PerformanceDescription = p12.PerformanceDescription, + UserFirstName = p12.User != null ? p12.User.FirstName : string.Empty, + UserLastName = p12.User != null ? p12.User.LastName : string.Empty, Amount = p12.Amount, + ShiftId = p12.ShiftId, AmountType = p12.AmountType, Id = p12.Id }; - public static ActivityLDto AdaptToLDto(this Activity p13) + public static Activity AdaptToActivity(this ActivityLDto p13) { - return p13 == null ? null : new ActivityLDto() + return p13 == null ? null : new Activity() { + Status = p13.Status, + DoneAt = p13.DoneAt, + IsDone = p13.IsDone, + PerformanceDescription = p13.PerformanceDescription, Type = p13.Type, Title = p13.Title, Description = p13.Description, IsDisposable = p13.IsDisposable, SetFor = p13.SetFor, HasDisposed = p13.HasDisposed, - Status = p13.Status, - DoneAt = p13.DoneAt, - IsDone = p13.IsDone, - PerformanceDescription = p13.PerformanceDescription, Amount = p13.Amount, AmountType = p13.AmountType, Id = p13.Id }; } - public static ActivityLDto AdaptTo(this Activity p14, ActivityLDto p15) + public static Activity AdaptTo(this ActivityLDto p14, Activity p15) { if (p14 == null) { return null; } - ActivityLDto result = p15 ?? new ActivityLDto(); + Activity result = p15 ?? new Activity(); + result.Status = p14.Status; + result.DoneAt = p14.DoneAt; + result.IsDone = p14.IsDone; + result.PerformanceDescription = p14.PerformanceDescription; result.Type = p14.Type; result.Title = p14.Title; result.Description = p14.Description; result.IsDisposable = p14.IsDisposable; result.SetFor = p14.SetFor; result.HasDisposed = p14.HasDisposed; - result.Status = p14.Status; - result.DoneAt = p14.DoneAt; - result.IsDone = p14.IsDone; - result.PerformanceDescription = p14.PerformanceDescription; result.Amount = p14.Amount; result.AmountType = p14.AmountType; result.Id = p14.Id; return result; } - public static Expression> ProjectToLDto => p16 => new ActivityLDto() + public static Expression> ProjectLDtoToActivity => p16 => new Activity() { + Status = p16.Status, + DoneAt = p16.DoneAt, + IsDone = p16.IsDone, + PerformanceDescription = p16.PerformanceDescription, Type = p16.Type, Title = p16.Title, Description = p16.Description, IsDisposable = p16.IsDisposable, SetFor = p16.SetFor, HasDisposed = p16.HasDisposed, - Status = p16.Status, - DoneAt = p16.DoneAt, - IsDone = p16.IsDone, - PerformanceDescription = p16.PerformanceDescription, Amount = p16.Amount, AmountType = p16.AmountType, Id = p16.Id }; + public static ActivityLDto AdaptToLDto(this Activity p17) + { + return p17 == null ? null : new ActivityLDto() + { + Type = p17.Type, + Title = p17.Title, + Description = p17.Description, + IsDisposable = p17.IsDisposable, + SetFor = p17.SetFor, + HasDisposed = p17.HasDisposed, + Status = p17.Status, + DoneAt = p17.DoneAt, + IsDone = p17.IsDone, + PerformanceDescription = p17.PerformanceDescription, + Amount = p17.Amount, + AmountType = p17.AmountType, + Id = p17.Id + }; + } + public static ActivityLDto AdaptTo(this Activity p18, ActivityLDto p19) + { + if (p18 == null) + { + return null; + } + ActivityLDto result = p19 ?? new ActivityLDto(); + + result.Type = p18.Type; + result.Title = p18.Title; + result.Description = p18.Description; + result.IsDisposable = p18.IsDisposable; + result.SetFor = p18.SetFor; + result.HasDisposed = p18.HasDisposed; + result.Status = p18.Status; + result.DoneAt = p18.DoneAt; + result.IsDone = p18.IsDone; + result.PerformanceDescription = p18.PerformanceDescription; + result.Amount = p18.Amount; + result.AmountType = p18.AmountType; + result.Id = p18.Id; + return result; + + } + public static Expression> ProjectToLDto => p20 => new ActivityLDto() + { + Type = p20.Type, + Title = p20.Title, + Description = p20.Description, + IsDisposable = p20.IsDisposable, + SetFor = p20.SetFor, + HasDisposed = p20.HasDisposed, + Status = p20.Status, + DoneAt = p20.DoneAt, + IsDone = p20.IsDone, + PerformanceDescription = p20.PerformanceDescription, + Amount = p20.Amount, + AmountType = p20.AmountType, + Id = p20.Id + }; + + private static ApplicationUser funcMain1(Never p4, ApplicationUser p5, ActivitySDto p2) + { + ApplicationUser result = p5 ?? new ApplicationUser(); + + result.FirstName = p2.UserFirstName; + result.LastName = p2.UserLastName; + return result; + + } + + private static Shift funcMain2(Never p6, Shift p7, ActivitySDto p2) + { + Shift result = p7 ?? new Shift(); + + result.Id = p2.ShiftId; + return result; + + } } } \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs index 2add83a..b28615d 100644 --- a/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftPlanMapper.g.cs @@ -14,6 +14,9 @@ namespace Brizco.Domain.Mappers { return p1 == null ? null : new ShiftPlan() { + IsCompleted = p1.IsCompleted, + CompletePercent = p1.CompletePercent, + CompleteDescription = p1.CompleteDescription, ShiftId = p1.ShiftId, Id = p1.Id }; @@ -26,6 +29,9 @@ namespace Brizco.Domain.Mappers } ShiftPlan result = p3 ?? new ShiftPlan(); + result.IsCompleted = p2.IsCompleted; + result.CompletePercent = p2.CompletePercent; + result.CompleteDescription = p2.CompleteDescription; result.ShiftId = p2.ShiftId; result.Id = p2.Id; return result; @@ -33,6 +39,9 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectToShiftPlan => p4 => new ShiftPlan() { + IsCompleted = p4.IsCompleted, + CompletePercent = p4.CompletePercent, + CompleteDescription = p4.CompleteDescription, ShiftId = p4.ShiftId, Id = p4.Id }; @@ -40,6 +49,9 @@ namespace Brizco.Domain.Mappers { return p5 == null ? null : new ShiftPlanSDto() { + IsCompleted = p5.IsCompleted, + CompletePercent = p5.CompletePercent, + CompleteDescription = p5.CompleteDescription, ShiftId = p5.ShiftId, ShiftTitle = p5.Shift == null ? null : p5.Shift.Title, Id = p5.Id @@ -53,6 +65,9 @@ namespace Brizco.Domain.Mappers } ShiftPlanSDto result = p7 ?? new ShiftPlanSDto(); + result.IsCompleted = p6.IsCompleted; + result.CompletePercent = p6.CompletePercent; + result.CompleteDescription = p6.CompleteDescription; result.ShiftId = p6.ShiftId; result.ShiftTitle = p6.Shift == null ? null : p6.Shift.Title; result.Id = p6.Id; @@ -61,6 +76,9 @@ namespace Brizco.Domain.Mappers } public static Expression> ProjectToSDto => p8 => new ShiftPlanSDto() { + IsCompleted = p8.IsCompleted, + CompletePercent = p8.CompletePercent, + CompleteDescription = p8.CompleteDescription, ShiftId = p8.ShiftId, ShiftTitle = p8.Shift.Title, Id = p8.Id @@ -70,6 +88,9 @@ namespace Brizco.Domain.Mappers return p9 == null ? null : new ShiftPlan() { PlanFor = p9.PlanFor, + IsCompleted = p9.IsCompleted, + CompletePercent = p9.CompletePercent, + CompleteDescription = p9.CompleteDescription, ShiftId = p9.ShiftId, RoutineId = p9.RoutineId, Users = funcMain1(p9.Users), @@ -85,6 +106,9 @@ namespace Brizco.Domain.Mappers ShiftPlan result = p12 ?? new ShiftPlan(); result.PlanFor = p11.PlanFor; + result.IsCompleted = p11.IsCompleted; + result.CompletePercent = p11.CompletePercent; + result.CompleteDescription = p11.CompleteDescription; result.ShiftId = p11.ShiftId; result.RoutineId = p11.RoutineId; result.Users = funcMain2(p11.Users, result.Users); @@ -95,6 +119,9 @@ namespace Brizco.Domain.Mappers public static Expression> ProjectLDtoToShiftPlan => p15 => new ShiftPlan() { PlanFor = p15.PlanFor, + IsCompleted = p15.IsCompleted, + CompletePercent = p15.CompletePercent, + CompleteDescription = p15.CompleteDescription, ShiftId = p15.ShiftId, RoutineId = p15.RoutineId, Users = p15.Users.Select(p16 => new ShiftPlanUser() @@ -112,6 +139,9 @@ namespace Brizco.Domain.Mappers { PlanFor = p17.PlanFor, RoutineId = p17.RoutineId, + IsCompleted = p17.IsCompleted, + CompletePercent = p17.CompletePercent, + CompleteDescription = p17.CompleteDescription, ShiftId = p17.ShiftId, Users = funcMain3(p17.Users), Id = p17.Id @@ -127,6 +157,9 @@ namespace Brizco.Domain.Mappers result.PlanFor = p19.PlanFor; result.RoutineId = p19.RoutineId; + result.IsCompleted = p19.IsCompleted; + result.CompletePercent = p19.CompletePercent; + result.CompleteDescription = p19.CompleteDescription; result.ShiftId = p19.ShiftId; result.Users = funcMain4(p19.Users, result.Users); result.Id = p19.Id; @@ -137,6 +170,9 @@ namespace Brizco.Domain.Mappers { PlanFor = p23.PlanFor, RoutineId = p23.RoutineId, + IsCompleted = p23.IsCompleted, + CompletePercent = p23.CompletePercent, + CompleteDescription = p23.CompleteDescription, ShiftId = p23.ShiftId, Users = p23.Users.Select(p24 => new ShiftPlanUserSDto() { diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index c5c3329..0cb1f9e 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -1,7 +1,4 @@ -using Brizco.Domain.Entities.Complex; -using Brizco.Domain.Entities.Shift; -using Mapster; -using Task = Brizco.Domain.Entities.Task.Task; +using Task = Brizco.Domain.Entities.Task.Task; namespace Brizco.Domain; @@ -16,6 +13,10 @@ public class MapsterRegister : IRegister .Map("Positions", o => o.Positions.Select(d => d.Position != null ? d.Position.Name : string.Empty)) .TwoWays(); + config.NewConfig() + .Map("UserFirstName", o => o.User !=null ? o.User.FirstName : string.Empty) + .Map("UserLastName", o => o.User != null ? o.User.LastName : string.Empty) + .TwoWays(); config.NewConfig() .Map("SetFor", o => DateTimeExtensions.DateTimeToUnixTimeStamp(o.SetFor)) diff --git a/Brizco.Infrastructure/Services/SmsService.cs b/Brizco.Infrastructure/Services/SmsService.cs index 8dc0b82..5f9600b 100644 --- a/Brizco.Infrastructure/Services/SmsService.cs +++ b/Brizco.Infrastructure/Services/SmsService.cs @@ -45,6 +45,13 @@ public class SmsService : ISmsService else _logger.LogError(apiException.Message); } + catch (Exception apiException) + { + if (_environment.IsProduction()) + throw; + else + _logger.LogError(apiException.Message); + } } } \ No newline at end of file diff --git a/Brizco.Repository/Abstracts/ICurrentUserService.cs b/Brizco.Repository/Abstracts/ICurrentUserService.cs index a53ba6d..d64db08 100644 --- a/Brizco.Repository/Abstracts/ICurrentUserService.cs +++ b/Brizco.Repository/Abstracts/ICurrentUserService.cs @@ -6,4 +6,6 @@ public interface ICurrentUserService : IScopedDependency string? RoleName { get; } string? ComplexId { get; } string? UserName { get; } + string? RoleId { get; } + List? Permissions { get; } } \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs index 658195b..d259eae 100644 --- a/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs +++ b/Brizco.Repository/Handlers/Activity/GetActivitiesQueryHandler.cs @@ -17,18 +17,32 @@ public class GetActivitiesQueryHandler : IRequestHandler().TableNoTracking - .Where(a=>a.UserId == userId) - .OrderByDescending(s => s.CreatedAt) + + IQueryable activites = _repositoryWrapper.SetRepository().TableNoTracking; + + + if (request.SelectedDate > 0) + { + var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); + activites = activites.Where(a => a.ComplexId == complexId && a.SetFor.Date == selectedDate.Date); + } + + if (request.SelectedShift != default) + activites = activites.Where(a => a.ComplexId == complexId && a.ShiftId == request.SelectedShift); + + if (request.SelectedDate == 0 && request.SelectedShift == default) + activites = activites.Where(a => a.UserId == userId); + + + + return await activites.OrderByDescending(s => s.CreatedAt) .Skip(request.Page * 15).Take(15) .Select(ActivityMapper.ProjectToSDto) .ToListAsync(cancellationToken); - - return tasks; } } \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs index 32b0920..90da826 100644 --- a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs @@ -1,4 +1,6 @@ -namespace Brizco.Repository.Handlers.Shift; +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Repository.Handlers.Shift; public class GetShiftPlansQueryHandler : IRequestHandler> { @@ -16,13 +18,49 @@ public class GetShiftPlansQueryHandler : IRequestHandler shifts = new List(); + if (request.SelectedDate > 0) + { + var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); - var shifts = await _repositoryWrapper.SetRepository().TableNoTracking - .Where(s=>s.ComplexId==complexId) - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftMapper.ProjectToSDto) - .ToListAsync(cancellationToken); + 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 + select shift; + + shifts = await originalShifts.AsNoTracking().Select(ShiftMapper.ProjectToSDto).ToListAsync(cancellationToken); + foreach (var shift in shifts) + { + var activitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken); + var doneActivitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken); + var undoneActivitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftId == shift.Id, cancellationToken); + shift.UndoneActivitiesCount = undoneActivitiesCount; + shift.DoneActivitiesCount = doneActivitiesCount; + shift.TotalActivitiesCount = activitiesCount; + + var existedShiftPlan = await _repositoryWrapper.SetRepository() + .TableNoTracking + .FirstOrDefaultAsync(s => s.ShiftId == shift.Id && s.PlanFor.Date == selectedDate.Date, cancellationToken); + shift.IsCompleted = existedShiftPlan is { IsCompleted : true }; + } + } + else + { + + shifts = await _repositoryWrapper.SetRepository().TableNoTracking + .Where(s => s.ComplexId == complexId) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } + return shifts; diff --git a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs index b848884..ae05e16 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/CreateShiftPlanCommandHandler.cs @@ -3,9 +3,12 @@ public class CreateShiftPlanCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; - public CreateShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper) + private readonly ICurrentUserService _currentUserService; + + public CreateShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; + _currentUserService = currentUserService; } public async Task Handle(CreateShiftPlanCommand request, CancellationToken cancellationToken) { @@ -15,11 +18,18 @@ public class CreateShiftPlanCommandHandler : IRequestHandler() + .TableNoTracking + .FirstOrDefaultAsync(s => s.ShiftId == request.ShiftId && s.PlanFor.Date == planFor.Date, cancellationToken); + + if (existedShiftPlan != null) + throw new AppException("Shift plan is exist for this date , you can update existed shift plan", ApiResultStatusCode.BadRequest); try { await _repositoryWrapper.BeginTransaction(cancellationToken); - var shiftPlan = shift.AddPlan(DateTimeExtensions.UnixTimeStampToDateTime(request.PlanDate),request.RoutineId); + var shiftPlan = shift.AddPlan(planFor , request.RoutineId); if (request.UserAndPositionIds.Count == 0) throw new AppException("شیفت بندی مورد نظر باید حداقل متشکل از یک فرد باشد", ApiResultStatusCode.BadRequest); diff --git a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs index 7601205..43dcb90 100644 --- a/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs +++ b/Brizco.Repository/Handlers/ShiftPlan/GetShiftPlansQueryHandler.cs @@ -1,4 +1,6 @@ -namespace Brizco.Repository.Handlers.ShiftPlan; +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Repository.Handlers.ShiftPlan; public class GetShiftPlansQueryHandler : IRequestHandler> { @@ -12,14 +14,43 @@ public class GetShiftPlansQueryHandler : IRequestHandler> Handle(GetShiftPlansQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + List shiftPlans; + if (request.SelectedDate > 0) + { + var selectedDate = DateTimeExtensions.UnixTimeStampToDateTime(request.SelectedDate); + shiftPlans = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(s => s.PlanFor.Date == selectedDate.Date) + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + foreach (var shiftPlan in shiftPlans) + { + var activitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.SetFor.Date == selectedDate.Date && a.ShiftId == shiftPlan.Id, cancellationToken); + var doneActivitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.Status == ActivityStatus.Done && a.SetFor.Date == selectedDate.Date && a.ShiftId == shiftPlan.Id, cancellationToken); + var undoneActivitiesCount = await _repositoryWrapper.SetRepository() + .TableNoTracking + .CountAsync(a => a.Status == ActivityStatus.UnDone && a.SetFor.Date == selectedDate.Date && a.ShiftId == shiftPlan.Id, cancellationToken); + shiftPlan.UndoneActivitiesCount = undoneActivitiesCount; + shiftPlan.DoneActivitiesCount = doneActivitiesCount; + shiftPlan.TotalActivitiesCount = activitiesCount; + } - var shifts = await _repositoryWrapper.SetRepository().TableNoTracking - .OrderByDescending(s => s.CreatedAt) - .Skip(request.Page * 15).Take(15) - .Select(ShiftPlanMapper.ProjectToSDto) - .ToListAsync(cancellationToken); + } + else + { + shiftPlans = await _repositoryWrapper.SetRepository().TableNoTracking + .OrderByDescending(s => s.CreatedAt) + .Skip(request.Page * 15).Take(15) + .Select(ShiftPlanMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + } - return shifts; + return shiftPlans; } } \ No newline at end of file diff --git a/Brizco.Repository/Migrations/20231210101559_editShiftPlanAddComplexId.Designer.cs b/Brizco.Repository/Migrations/20231210101559_editShiftPlanAddComplexId.Designer.cs new file mode 100644 index 0000000..0b4fc7b --- /dev/null +++ b/Brizco.Repository/Migrations/20231210101559_editShiftPlanAddComplexId.Designer.cs @@ -0,0 +1,1476 @@ +// +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("20231210101559_editShiftPlanAddComplexId")] + partial class editShiftPlanAddComplexId + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.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.Complex.ComplexUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("UserId"); + + b.ToTable("ComplexUsers", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.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.Complex.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.Complex.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.Routine.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.Shift.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.Shift.ShiftDay", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.ToTable("ShiftDays", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", 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("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.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + 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 => + { + 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.Task.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.Task.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.Task.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.Task.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.Task.TaskShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskShifts", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.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.User.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .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.Task.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UnDoneReason") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("ShiftId"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Users") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser") + .WithMany("Roles") + .HasForeignKey("ComplexUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ComplexUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("ShiftPlan"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Shifts") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Days") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Tasks") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.Navigation("Positions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + + b.Navigation("Routines"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.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/20231210101559_editShiftPlanAddComplexId.cs b/Brizco.Repository/Migrations/20231210101559_editShiftPlanAddComplexId.cs new file mode 100644 index 0000000..37dcc22 --- /dev/null +++ b/Brizco.Repository/Migrations/20231210101559_editShiftPlanAddComplexId.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editShiftPlanAddComplexId : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ComplexId", + schema: "public", + table: "ShiftPlans", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.CreateIndex( + name: "IX_ShiftPlans_ComplexId", + schema: "public", + table: "ShiftPlans", + column: "ComplexId"); + + migrationBuilder.AddForeignKey( + name: "FK_ShiftPlans_Complexes_ComplexId", + schema: "public", + table: "ShiftPlans", + column: "ComplexId", + principalSchema: "public", + principalTable: "Complexes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ShiftPlans_Complexes_ComplexId", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropIndex( + name: "IX_ShiftPlans_ComplexId", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropColumn( + name: "ComplexId", + schema: "public", + table: "ShiftPlans"); + } + } +} diff --git a/Brizco.Repository/Migrations/20231210132016_editShiftPlanAddComplete.Designer.cs b/Brizco.Repository/Migrations/20231210132016_editShiftPlanAddComplete.Designer.cs new file mode 100644 index 0000000..7b6023a --- /dev/null +++ b/Brizco.Repository/Migrations/20231210132016_editShiftPlanAddComplete.Designer.cs @@ -0,0 +1,1486 @@ +// +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("20231210132016_editShiftPlanAddComplete")] + partial class editShiftPlanAddComplete + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.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.Complex.ComplexUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ComplexId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("UserId"); + + b.ToTable("ComplexUsers", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.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.Complex.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.Complex.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.Routine.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.Shift.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.Shift.ShiftDay", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("DayOfWeek") + .HasColumnType("integer"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.ToTable("ShiftDays", "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.HasKey("Id"); + + b.HasIndex("ComplexId"); + + b.HasIndex("RoutineId"); + + b.HasIndex("ShiftId"); + + 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 => + { + 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.Task.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.Task.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.Task.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.Task.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.Task.TaskShift", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskShifts", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.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.User.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp without time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .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.Task.Activity", b => + { + b.HasBaseType("Brizco.Domain.Entities.Task.Task"); + + b.Property("DoneAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("PerformanceDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UnDoneReason") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasIndex("ShiftId"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("Activity"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Users") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.ComplexUser", "ComplexUser") + .WithMany("Roles") + .HasForeignKey("ComplexUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ComplexUser"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Position", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Complex.Section", "Section") + .WithMany("Positions") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Shifts") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftDay", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Days") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany() + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("ShiftPlan"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Shifts") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany("Routines") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Tasks") + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskDay", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Days") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskPosition", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Position", "Position") + .WithMany() + .HasForeignKey("PositionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Positions") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskRoutine", b => + { + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") + .WithMany("Tasks") + .HasForeignKey("RoutineId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Routines") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Routine"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.User.ApplicationRole", b => + { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany("Roles") + .HasForeignKey("ComplexId"); + + b.Navigation("Complex"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Activity", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.ComplexUser", b => + { + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Section", b => + { + b.Navigation("Positions"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Routine.Routine", b => + { + b.Navigation("Shifts"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + + b.Navigation("Routines"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.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/20231210132016_editShiftPlanAddComplete.cs b/Brizco.Repository/Migrations/20231210132016_editShiftPlanAddComplete.cs new file mode 100644 index 0000000..d59714b --- /dev/null +++ b/Brizco.Repository/Migrations/20231210132016_editShiftPlanAddComplete.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editShiftPlanAddComplete : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CompleteDescription", + schema: "public", + table: "ShiftPlans", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "CompletePercent", + schema: "public", + table: "ShiftPlans", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "IsCompleted", + schema: "public", + table: "ShiftPlans", + type: "boolean", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CompleteDescription", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropColumn( + name: "CompletePercent", + schema: "public", + table: "ShiftPlans"); + + migrationBuilder.DropColumn( + name: "IsCompleted", + schema: "public", + table: "ShiftPlans"); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index 5b23fb0..d822c6d 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -412,6 +412,16 @@ namespace Brizco.Repository.Migrations .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"); @@ -419,6 +429,9 @@ namespace Brizco.Repository.Migrations .IsRequired() .HasColumnType("text"); + b.Property("IsCompleted") + .HasColumnType("boolean"); + b.Property("IsRemoved") .HasColumnType("boolean"); @@ -447,6 +460,8 @@ namespace Brizco.Repository.Migrations b.HasKey("Id"); + b.HasIndex("ComplexId"); + b.HasIndex("RoutineId"); b.HasIndex("ShiftId"); @@ -1181,6 +1196,12 @@ namespace Brizco.Repository.Migrations modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => { + b.HasOne("Brizco.Domain.Entities.Complex.Complex", "Complex") + .WithMany() + .HasForeignKey("ComplexId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("Brizco.Domain.Entities.Routine.Routine", "Routine") .WithMany() .HasForeignKey("RoutineId") @@ -1193,6 +1214,8 @@ namespace Brizco.Repository.Migrations .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.Navigation("Complex"); + b.Navigation("Routine"); b.Navigation("Shift");