From 4a775c9373212029b7359b5b45c0eebac8bcee3e Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Thu, 26 Oct 2023 01:24:04 +0330 Subject: [PATCH] complete login response and user services --- Brizco.Api/Controllers/ShiftController.cs | 2 +- Brizco.Api/Controllers/UserController.cs | 11 + Brizco.Core/CoreServices/AccountService.cs | 72 +- .../EntityServices/Abstracts/IUserService.cs | 2 + Brizco.Core/EntityServices/UserService.cs | 63 + Brizco.Domain/Brizco.Domain.csproj | 1 - .../CommandQueries/Commands/ShiftCommands.cs | 2 +- .../Dtos/SmallDtos/ComplexUserRoleSDto.cs | 6 +- .../Entities/User/ApplicationUser.cs | 3 + .../Mappers/ComplexUserRoleMapper.g.cs | 80 +- Brizco.Domain/Mappers/ShiftMapper.g.cs | 6 +- Brizco.Domain/MapsterRegister.cs | 7 +- .../Shift/CreateShiftCommandHandler.cs | 6 +- .../Handlers/Shift/GetShiftsQueryHandler.cs | 5 + .../Shift/UpdateShiftCommandHandler.cs | 28 +- .../20231025193834_editUser.Designer.cs | 1141 +++++++++++++++++ .../Migrations/20231025193834_editUser.cs | 32 + .../ApplicationContextModelSnapshot.cs | 3 + 18 files changed, 1414 insertions(+), 56 deletions(-) create mode 100644 Brizco.Repository/Migrations/20231025193834_editUser.Designer.cs create mode 100644 Brizco.Repository/Migrations/20231025193834_editUser.cs diff --git a/Brizco.Api/Controllers/ShiftController.cs b/Brizco.Api/Controllers/ShiftController.cs index f416ed1..64d6572 100644 --- a/Brizco.Api/Controllers/ShiftController.cs +++ b/Brizco.Api/Controllers/ShiftController.cs @@ -24,7 +24,7 @@ public class ShiftController : ICarterModule group.MapPut("", Put) .HasApiVersion(1.0); - group.MapDelete("", Delete) + group.MapDelete("{id}", Delete) .HasApiVersion(1.0); diff --git a/Brizco.Api/Controllers/UserController.cs b/Brizco.Api/Controllers/UserController.cs index b732fa5..d6e3532 100644 --- a/Brizco.Api/Controllers/UserController.cs +++ b/Brizco.Api/Controllers/UserController.cs @@ -19,6 +19,14 @@ public class UserController : ICarterModule .WithDisplayName("GetOneUser") .HasApiVersion(1.0); + group.MapGet("/profile", GetUserProfileAsync) + .WithDisplayName("GetUserProfile") + .HasApiVersion(1.0); + + group.MapGet("/profile/role", GetUserProfileAsync) + .WithDisplayName("GetUserProfileRoles") + .HasApiVersion(1.0); + group.MapPost("", Post) .HasApiVersion(1.0); @@ -29,6 +37,9 @@ public class UserController : ICarterModule .HasApiVersion(1.0); } + public async Task GetUserProfileAsync(IUserService userService, CancellationToken cancellationToken) + => TypedResults.Ok(await userService.GetUserProfileAsync(cancellationToken)); + // GET:Get All Entity public async Task GetAllAsync([FromQuery]int page, IUserService userService, CancellationToken cancellationToken) => TypedResults.Ok(await userService.GetUsersAsync(page,cancellationToken)); diff --git a/Brizco.Core/CoreServices/AccountService.cs b/Brizco.Core/CoreServices/AccountService.cs index 7803edc..611e808 100644 --- a/Brizco.Core/CoreServices/AccountService.cs +++ b/Brizco.Core/CoreServices/AccountService.cs @@ -1,4 +1,7 @@ -namespace Brizco.Core.CoreServices; +using Brizco.Domain.Entities.Complex; +using Brizco.Domain.Mappers; + +namespace Brizco.Core.CoreServices; public class AccountService : IAccountService { @@ -154,25 +157,58 @@ public class AccountService : IAccountService private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken) { - - var complexUsers = await _repositoryWrapper.SetRepository() - .TableNoTracking - .Where(mcu => mcu.UserId == user.Id) - .OrderByDescending(o => o.CreatedAt) - .FirstOrDefaultAsync(cancellationToken); - if(complexUsers == null) - return await _jwtService.Generate(user); - - var complexUserRoles = await _repositoryWrapper.SetRepository() - .TableNoTracking - .Where(c=>c.ComplexUserId==complexUsers.Id) - .OrderByDescending(o => o.CreatedAt) - .FirstOrDefaultAsync(cancellationToken); AccessToken jwt; - if (complexUserRoles != null) - jwt = await _jwtService.Generate(user, complexUsers.ComplexId, complexUserRoles.RoleId); + if (user.SelectedComplexUserRoleId != Guid.Empty) + { + var complexUserRole = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.Id == user.SelectedComplexUserRoleId) + .Select(ComplexUserRoleMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + var complexUser = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.Id == complexUserRole!.ComplexUserId) + .Select(ComplexUserMapper.ProjectToSDto) + .FirstOrDefaultAsync( cancellationToken); + + jwt = await _jwtService.Generate(user, complexUser!.ComplexId, complexUserRole!.RoleId); + jwt.User.SelectedComplexName = complexUser.ComplexName; + jwt.User.SelectedRoleName = complexUserRole.RoleName; + } else - jwt = await _jwtService.Generate(user); + { + var complexUser = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(mcu => mcu.UserId == user.Id) + .OrderByDescending(o => o.CreatedAt) + .Select(ComplexUserMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (complexUser == null) + return await _jwtService.Generate(user); + + var complexUserRole = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.ComplexUserId == complexUser.Id) + .OrderByDescending(o => o.CreatedAt) + .Select(ComplexUserRoleMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + + + if (complexUserRole != null) + { + + user.SelectedComplexUserRoleId = complexUserRole.Id; + await _userManager.UpdateAsync(user); + jwt = await _jwtService.Generate(user, complexUser.ComplexId, complexUserRole.RoleId); + jwt.User.SelectedComplexName = complexUser.ComplexName; + jwt.User.SelectedRoleName = complexUserRole.RoleName; + } + else + jwt = await _jwtService.Generate(user); + + } return jwt; } diff --git a/Brizco.Core/EntityServices/Abstracts/IUserService.cs b/Brizco.Core/EntityServices/Abstracts/IUserService.cs index 7a2451d..2df29b3 100644 --- a/Brizco.Core/EntityServices/Abstracts/IUserService.cs +++ b/Brizco.Core/EntityServices/Abstracts/IUserService.cs @@ -2,6 +2,8 @@ public interface IUserService : IScopedDependency { + Task GetUserProfileAsync(CancellationToken cancellationToken); + Task> GetUserRolesAsync(CancellationToken cancellationToken); Task> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default); Task GetUserAsync(Guid userId); Task CreateUserAsync(string phoneNumber); diff --git a/Brizco.Core/EntityServices/UserService.cs b/Brizco.Core/EntityServices/UserService.cs index b7fcf5f..923ec75 100644 --- a/Brizco.Core/EntityServices/UserService.cs +++ b/Brizco.Core/EntityServices/UserService.cs @@ -27,6 +27,69 @@ public class UserService : IUserService _repositoryWrapper = repositoryWrapper; } + + public async Task GetUserProfileAsync(CancellationToken cancellationToken) + { + if (!Guid.TryParse(_currentUserService.UserId, out var userId)) + throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized); + var user = await _userManager.FindByIdAsync(userId.ToString()); + if (user == null) + throw new AppException("User NotFound", ApiResultStatusCode.NotFound); + var response = user.AdaptToSDto(); + + if (user.SelectedComplexUserRoleId != Guid.Empty) + { + var complexUserRole = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.Id == user.SelectedComplexUserRoleId) + .Select(ComplexUserRoleMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + var complexUser = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.Id == complexUserRole!.ComplexUserId) + .Select(ComplexUserMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + + response.SelectedComplexName = complexUser!.ComplexName; + response.SelectedRoleName = complexUserRole!.RoleName; + } + + return response; + } + + public async Task> GetUserRolesAsync(CancellationToken cancellationToken) + { + if (!Guid.TryParse(_currentUserService.UserId, out var userId)) + throw new AppException("Wrong Token", ApiResultStatusCode.UnAuthorized); + var user = await _userManager.FindByIdAsync(userId.ToString()); + if (user == null) + throw new AppException("User NotFound", ApiResultStatusCode.NotFound); + var response = new List(); + var complexUsers = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(mcu => mcu.UserId == user.Id) + .Select(ComplexUserMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + if (complexUsers.Count == 0) + return response; + + foreach (var complexUser in complexUsers) + { + var complexUserRoles = await _repositoryWrapper.SetRepository() + .TableNoTracking + .Where(c => c.ComplexUserId == complexUser.Id) + .Select(ComplexUserRoleMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + foreach (var userRole in complexUserRoles) + { + userRole.ComplexName = complexUser.ComplexName; + response.Add(userRole); + } + } + + 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 61404bd..0e21ee4 100644 --- a/Brizco.Domain/Brizco.Domain.csproj +++ b/Brizco.Domain/Brizco.Domain.csproj @@ -67,7 +67,6 @@ - diff --git a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs index 75873b6..63d54a2 100644 --- a/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs +++ b/Brizco.Domain/CommandQueries/Commands/ShiftCommands.cs @@ -3,7 +3,7 @@ namespace Brizco.Domain.CommandQueries.Commands; public sealed record CreateShiftCommand(string Title, TimeSpan StartAt, TimeSpan EndAt, string Description , List DayOfWeeks) - : IRequest; + : IRequest; public sealed record UpdateShiftCommand(Guid Id,string Title, TimeSpan StartAt, TimeSpan EndAt, string Description, List DayOfWeeks) : IRequest; diff --git a/Brizco.Domain/Dtos/SmallDtos/ComplexUserRoleSDto.cs b/Brizco.Domain/Dtos/SmallDtos/ComplexUserRoleSDto.cs index 874b3b0..400d1b4 100644 --- a/Brizco.Domain/Dtos/SmallDtos/ComplexUserRoleSDto.cs +++ b/Brizco.Domain/Dtos/SmallDtos/ComplexUserRoleSDto.cs @@ -7,8 +7,6 @@ public class ComplexUserRoleSDto : BaseDto public Guid RoleId { get; set; } public Guid ComplexUserId { get; set; } - - public Guid UserId { get; set; } - public Guid ComplexId { get; set; } - + public string RoleName { get; set; } = string.Empty; + public string ComplexName { get; set; } = string.Empty; } \ No newline at end of file diff --git a/Brizco.Domain/Entities/User/ApplicationUser.cs b/Brizco.Domain/Entities/User/ApplicationUser.cs index 4febed0..00d1dc1 100644 --- a/Brizco.Domain/Entities/User/ApplicationUser.cs +++ b/Brizco.Domain/Entities/User/ApplicationUser.cs @@ -7,6 +7,9 @@ public class ApplicationUser : IdentityUser public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; public string NationalId { get; set; } = string.Empty; + + public Guid SelectedComplexUserRoleId { get; set; } + public DateTime BirthDate { get; set; } public Gender Gender { get; set; } public SignUpStatus SignUpStatus { get; set; } diff --git a/Brizco.Domain/Mappers/ComplexUserRoleMapper.g.cs b/Brizco.Domain/Mappers/ComplexUserRoleMapper.g.cs index f8d3e92..66f021c 100644 --- a/Brizco.Domain/Mappers/ComplexUserRoleMapper.g.cs +++ b/Brizco.Domain/Mappers/ComplexUserRoleMapper.g.cs @@ -2,6 +2,8 @@ using System; using System.Linq.Expressions; using Brizco.Domain.Dtos.SmallDtos; using Brizco.Domain.Entities.Complex; +using Brizco.Domain.Entities.User; +using Mapster.Models; namespace Brizco.Domain.Mappers { @@ -12,7 +14,13 @@ namespace Brizco.Domain.Mappers return p1 == null ? null : new ComplexUserRole() { ComplexUserId = p1.ComplexUserId, + ComplexUser = new ComplexUser() {Id = p1.ComplexUserId}, RoleId = p1.RoleId, + Role = new ApplicationRole() + { + Id = p1.RoleId, + Name = p1.RoleName + }, Id = p1.Id }; } @@ -25,45 +33,75 @@ namespace Brizco.Domain.Mappers ComplexUserRole result = p3 ?? new ComplexUserRole(); result.ComplexUserId = p2.ComplexUserId; + result.ComplexUser = funcMain1(new Never(), result.ComplexUser, p2); result.RoleId = p2.RoleId; + result.Role = funcMain2(new Never(), result.Role, p2); result.Id = p2.Id; return result; } - public static Expression> ProjectToComplexUserRole => p4 => new ComplexUserRole() + public static Expression> ProjectToComplexUserRole => p8 => new ComplexUserRole() { - ComplexUserId = p4.ComplexUserId, - RoleId = p4.RoleId, - Id = p4.Id - }; - public static ComplexUserRoleSDto AdaptToSDto(this ComplexUserRole p5) - { - return p5 == null ? null : new ComplexUserRoleSDto() + ComplexUserId = p8.ComplexUserId, + ComplexUser = new ComplexUser() {Id = p8.ComplexUserId}, + RoleId = p8.RoleId, + Role = new ApplicationRole() { - RoleId = p5.RoleId, - ComplexUserId = p5.ComplexUserId, - Id = p5.Id + Id = p8.RoleId, + Name = p8.RoleName + }, + Id = p8.Id + }; + public static ComplexUserRoleSDto AdaptToSDto(this ComplexUserRole p9) + { + return p9 == null ? null : new ComplexUserRoleSDto() + { + RoleId = p9.RoleId, + ComplexUserId = p9.ComplexUserId, + RoleName = p9.Role == null ? null : p9.Role.PersianName, + Id = p9.Id }; } - public static ComplexUserRoleSDto AdaptTo(this ComplexUserRole p6, ComplexUserRoleSDto p7) + public static ComplexUserRoleSDto AdaptTo(this ComplexUserRole p10, ComplexUserRoleSDto p11) { - if (p6 == null) + if (p10 == null) { return null; } - ComplexUserRoleSDto result = p7 ?? new ComplexUserRoleSDto(); + ComplexUserRoleSDto result = p11 ?? new ComplexUserRoleSDto(); - result.RoleId = p6.RoleId; - result.ComplexUserId = p6.ComplexUserId; - result.Id = p6.Id; + result.RoleId = p10.RoleId; + result.ComplexUserId = p10.ComplexUserId; + result.RoleName = p10.Role == null ? null : p10.Role.PersianName; + result.Id = p10.Id; return result; } - public static Expression> ProjectToSDto => p8 => new ComplexUserRoleSDto() + public static Expression> ProjectToSDto => p12 => new ComplexUserRoleSDto() { - RoleId = p8.RoleId, - ComplexUserId = p8.ComplexUserId, - Id = p8.Id + RoleId = p12.RoleId, + ComplexUserId = p12.ComplexUserId, + RoleName = p12.Role.PersianName, + Id = p12.Id }; + + private static ComplexUser funcMain1(Never p4, ComplexUser p5, ComplexUserRoleSDto p2) + { + ComplexUser result = p5 ?? new ComplexUser(); + + result.Id = p2.ComplexUserId; + return result; + + } + + private static ApplicationRole funcMain2(Never p6, ApplicationRole p7, ComplexUserRoleSDto p2) + { + ApplicationRole result = p7 ?? new ApplicationRole(); + + result.Id = p2.RoleId; + result.Name = p2.RoleName; + return result; + + } } } \ No newline at end of file diff --git a/Brizco.Domain/Mappers/ShiftMapper.g.cs b/Brizco.Domain/Mappers/ShiftMapper.g.cs index b27f6f6..dd7f8a9 100644 --- a/Brizco.Domain/Mappers/ShiftMapper.g.cs +++ b/Brizco.Domain/Mappers/ShiftMapper.g.cs @@ -63,7 +63,7 @@ namespace Brizco.Domain.Mappers Description = p11.Description, StartAt = p11.StartAt, EndAt = p11.EndAt, - Days = funcMain4(p11.Days != null ? p11.Days.Select(funcMain5).ToList() : new List()), + Days = funcMain4(p11.Days.Select(funcMain5).ToList()), ComplexId = p11.ComplexId, Id = p11.Id }; @@ -80,7 +80,7 @@ namespace Brizco.Domain.Mappers result.Description = p13.Description; result.StartAt = p13.StartAt; result.EndAt = p13.EndAt; - result.Days = funcMain6(p13.Days != null ? p13.Days.Select(funcMain5).ToList() : new List(), result.Days); + result.Days = funcMain6(p13.Days.Select(funcMain5).ToList(), result.Days); result.ComplexId = p13.ComplexId; result.Id = p13.Id; return result; @@ -92,7 +92,7 @@ namespace Brizco.Domain.Mappers Description = p17.Description, StartAt = p17.StartAt, EndAt = p17.EndAt, - Days = p17.Days != null ? p17.Days.Select(d => d.DayOfWeek).ToList() : new List(), + Days = p17.Days.Select(d => d.DayOfWeek).ToList(), ComplexId = p17.ComplexId, Id = p17.Id }; diff --git a/Brizco.Domain/MapsterRegister.cs b/Brizco.Domain/MapsterRegister.cs index 7d9b8cf..7362425 100644 --- a/Brizco.Domain/MapsterRegister.cs +++ b/Brizco.Domain/MapsterRegister.cs @@ -9,7 +9,12 @@ public class MapsterRegister : IRegister public void Register(TypeAdapterConfig config) { config.NewConfig() - .Map("Days", org => org.Days != null ? org.Days.Select(d=>d.DayOfWeek).ToList() : new List()) + .Map("Days", org => org.Days.Select(d=>d.DayOfWeek).ToList()) + .TwoWays(); + + + config.NewConfig() + .Map("RoleName", org => org.Role!.PersianName) .TwoWays(); config.NewConfig() diff --git a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs index 44f5a4a..265f885 100644 --- a/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shift/CreateShiftCommandHandler.cs @@ -1,6 +1,6 @@ namespace Brizco.Repository.Handlers.Shift; -public class CreateShiftCommandHandler : IRequestHandler +public class CreateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; private readonly ICurrentUserService _currentUserService; @@ -10,7 +10,7 @@ public class CreateShiftCommandHandler : IRequestHandler Handle(CreateShiftCommand request, CancellationToken cancellationToken) + public async Task Handle(CreateShiftCommand request, CancellationToken cancellationToken) { if (_currentUserService.ComplexId == null) @@ -33,7 +33,7 @@ public class CreateShiftCommandHandler : IRequestHandler().Add(shift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.CommitAsync(cancellationToken); - return shift; + return shift.AdaptToSDto(); } catch (Exception ) { diff --git a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs index 679393a..8249b54 100644 --- a/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs +++ b/Brizco.Repository/Handlers/Shift/GetShiftsQueryHandler.cs @@ -16,6 +16,11 @@ public class GetShiftPlansQueryHandler : IRequestHandler + { + s.Days = s.Days.OrderBy(d=>d).ToList(); + }); + return shifts; } } \ No newline at end of file diff --git a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs index 43ff0b5..4ac5a6d 100644 --- a/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs +++ b/Brizco.Repository/Handlers/Shift/UpdateShiftCommandHandler.cs @@ -1,11 +1,13 @@ -namespace Brizco.Repository.Handlers.Shift; +using Brizco.Domain.Entities.Shift; + +namespace Brizco.Repository.Handlers.Shift; public class UpdateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; private readonly ICurrentUserService _currentUserService; - public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) + public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) { _repositoryWrapper = repositoryWrapper; _currentUserService = currentUserService; @@ -14,7 +16,7 @@ public class UpdateShiftCommandHandler : IRequestHandler Handle(UpdateShiftCommand request, CancellationToken cancellationToken) { var shift = await _repositoryWrapper.SetRepository() - .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id); + .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shift == null) throw new AppException("Shift not found", ApiResultStatusCode.NotFound); @@ -29,6 +31,26 @@ public class UpdateShiftCommandHandler : IRequestHandler() + .TableNoTracking.Where(sd => sd.ShiftId == request.Id) + .ToListAsync(cancellationToken); + + foreach (var shiftDay in shiftDays.Where(shiftDay => !request.DayOfWeeks.Contains(shiftDay.DayOfWeek))) + { + _repositoryWrapper.SetRepository() + .Delete(shiftDay); + await _repositoryWrapper.SaveChangesAsync(cancellationToken); + } + + foreach (var dayOfWeek in request.DayOfWeeks) + { + var findDay = shiftDays.FirstOrDefault(sf => sf.DayOfWeek == dayOfWeek); + if (findDay != null) + shift.SetDay(dayOfWeek); + } + + _repositoryWrapper.SetRepository() .Update(newShift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/Brizco.Repository/Migrations/20231025193834_editUser.Designer.cs b/Brizco.Repository/Migrations/20231025193834_editUser.Designer.cs new file mode 100644 index 0000000..4ff48d6 --- /dev/null +++ b/Brizco.Repository/Migrations/20231025193834_editUser.Designer.cs @@ -0,0 +1,1141 @@ +// +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("20231025193834_editUser")] + partial class editUser + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("public") + .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Brizco.Domain.Entities.Complex.Complex", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .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.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("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndAt") + .HasColumnType("timestamp without time zone"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftId") + .HasColumnType("uuid"); + + b.Property("StartAt") + .HasColumnType("timestamp without time zone"); + + b.HasKey("Id"); + + b.HasIndex("ShiftId"); + + b.ToTable("ShiftPlans", "public"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationUserId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShiftPlanId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationUserId"); + + b.HasIndex("ShiftPlanId"); + + b.ToTable("ShiftPlanUsers", "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() + .HasColumnType("text"); + + b.Property("HasDisposed") + .HasColumnType("boolean"); + + b.Property("IsDisposable") + .HasColumnType("boolean"); + + b.Property("IsRelatedToPerson") + .HasColumnType("boolean"); + + b.Property("IsRelatedToRole") + .HasColumnType("boolean"); + + b.Property("IsRelatedToShift") + .HasColumnType("boolean"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("SetFor") + .HasColumnType("timestamp without time zone"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.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.TaskRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskRoles", "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.Task.TaskUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsRemoved") + .HasColumnType("boolean"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("RemovedAt") + .HasColumnType("timestamp without time zone"); + + b.Property("RemovedBy") + .IsRequired() + .HasColumnType("text"); + + b.Property("TaskId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TaskId"); + + b.HasIndex("UserId"); + + b.ToTable("TaskUsers", "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("Status") + .HasColumnType("integer"); + + 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.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.Shift.Shift", "Shift") + .WithMany("Plans") + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlanUser", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "ApplicationUser") + .WithMany() + .HasForeignKey("ApplicationUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Shift.ShiftPlan", "ShiftPlan") + .WithMany("Users") + .HasForeignKey("ShiftPlanId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ApplicationUser"); + + b.Navigation("ShiftPlan"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.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.TaskRole", b => + { + b.HasOne("Brizco.Domain.Entities.User.ApplicationRole", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Roles") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskShift", b => + { + b.HasOne("Brizco.Domain.Entities.Shift.Shift", "Shift") + .WithMany() + .HasForeignKey("ShiftId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Shifts") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Shift"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.TaskUser", b => + { + b.HasOne("Brizco.Domain.Entities.Task.Task", "Task") + .WithMany("Users") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Brizco.Domain.Entities.User.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Task"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("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.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.Shift.Shift", b => + { + b.Navigation("Days"); + + b.Navigation("Plans"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Shift.ShiftPlan", b => + { + b.Navigation("Users"); + }); + + modelBuilder.Entity("Brizco.Domain.Entities.Task.Task", b => + { + b.Navigation("Days"); + + b.Navigation("Roles"); + + b.Navigation("Shifts"); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Brizco.Repository/Migrations/20231025193834_editUser.cs b/Brizco.Repository/Migrations/20231025193834_editUser.cs new file mode 100644 index 0000000..1242147 --- /dev/null +++ b/Brizco.Repository/Migrations/20231025193834_editUser.cs @@ -0,0 +1,32 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Brizco.Repository.Migrations +{ + /// + public partial class editUser : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SelectedComplexUserRoleId", + schema: "public", + table: "Users", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SelectedComplexUserRoleId", + schema: "public", + table: "Users"); + } + } +} diff --git a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs index bccedd3..e43712c 100644 --- a/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ b/Brizco.Repository/Migrations/ApplicationContextModelSnapshot.cs @@ -717,6 +717,9 @@ namespace Brizco.Repository.Migrations b.Property("SecurityStamp") .HasColumnType("text"); + b.Property("SelectedComplexUserRoleId") + .HasColumnType("uuid"); + b.Property("SignUpStatus") .HasColumnType("integer");