From ae1e8859c02303ec9f26210533af1c36d133dbd4 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sat, 28 Sep 2024 12:34:36 +0330 Subject: [PATCH] Change DATABASE --- DocuMed.Api/Controllers/HospitalController.cs | 65 ++ DocuMed.Api/Controllers/SectionController.cs | 18 +- .../Controllers/UniversityController.cs | 20 +- .../.installation | 1 + DocuMed.Api/Services/CurrentUserService.cs | 17 +- DocuMed.Api/WeatherForecast.cs | 13 - .../WebFramework/Bases/CrudController.cs | 43 +- .../MiddleWares/ExceptionHandlerMiddleware.cs | 35 +- .../MiddleWares/PerformanceMiddleware.cs | 21 +- .../Swagger/SwaggerConfiguration.cs | 15 +- DocuMed.Common/DocuMed.Common.csproj | 8 +- DocuMed.Core/BaseServices/JwtService.cs | 25 +- DocuMed.Core/CoreServices/AccountService.cs | 79 +- .../EntityServices/MedicalHistoryService.cs | 35 +- .../MedicalHistoryTemplateService.cs | 34 +- DocuMed.Core/EntityServices/UserService.cs | 75 +- DocuMed.Core/Models/Api/ApiResult.cs | 26 +- .../Commands/HospitalCommands.cs | 5 + .../CommandQueries/Queries/HospitalQueries.cs | 4 + DocuMed.Domain/DocuMed.Domain.csproj | 15 +- DocuMed.Domain/Dtos/SmallDtos/HospitalSDto.cs | 9 + DocuMed.Domain/Dtos/SmallDtos/SectionSDto.cs | 2 +- DocuMed.Domain/Dtos/SmallDtos/StudentSDto.cs | 18 + .../Entities/City/Aggregate.City.cs | 8 - DocuMed.Domain/Entities/City/City.cs | 4 +- DocuMed.Domain/Entities/City/University.cs | 2 +- .../Entities/Hospitals/Hospital.Aggregate.cs | 15 + DocuMed.Domain/Entities/Hospitals/Hospital.cs | 26 + .../Entities/{City => Hospitals}/Section.cs | 10 +- .../Entities/MedicalHistory/MedicalHistory.cs | 4 +- .../MedicalHistoryQuestion.cs | 5 +- .../MedicalHistoryTemplate.cs | 6 +- DocuMed.Domain/Entities/Patient/Patient.cs | 12 - .../Entities/Patients/Patient.Aggregate.cs | 7 + DocuMed.Domain/Entities/Patients/Patient.cs | 33 + .../Entities/Staffs/Student.Aggregate.cs | 7 + DocuMed.Domain/Entities/Staffs/Student.cs | 31 + .../Entities/User/ApplicationUser.cs | 12 +- .../Mappers/ApplicationUserMapper.g.cs | 159 ++- DocuMed.Domain/Mappers/CityMapper.g.cs | 239 +++-- DocuMed.Domain/Mappers/HospitalMapper.g.cs | 78 ++ .../Mappers/MedicalHistoryMapper.g.cs | 963 +++++++++--------- .../Mappers/MedicalHistoryQuestionMapper.g.cs | 71 +- .../Mappers/MedicalHistoryTemplateMapper.g.cs | 452 ++++---- DocuMed.Domain/Mappers/SectionMapper.g.cs | 14 +- DocuMed.Domain/Mappers/StudentMapper.g.cs | 157 +++ DocuMed.Domain/MapsterRegister.cs | 9 +- DocuMed.Domain/Models/Refers.cs | 8 + .../RestServices/IKaveNegarRestApi.cs | 4 +- DocuMed.Infrastructure/Services/SmsService.cs | 76 +- DocuMed.PWA/DocuMed.PWA.csproj | 2 +- DocuMed.PWA/Models/Address.cs | 2 +- DocuMed.PWA/Models/Api/ApiResult.cs | 25 +- DocuMed.PWA/Models/BaseViewModel.cs | 7 +- DocuMed.PWA/Pages/HomePage.razor.cs | 23 +- DocuMed.PWA/Pages/Index.razor | 80 +- .../Pages/MedicalHistoryActionPage.razor.cs | 1 + .../MedicalHistoryTemplatesPage.razor.cs | 31 +- DocuMed.PWA/Pages/ProfilePage.razor.cs | 24 +- .../Services/RestServices/ISectionRestApi.cs | 4 +- DocuMed.PWA/Utilities/UserUtility.cs | 21 +- DocuMed.PWA/wwwroot/css/app.min.css | 220 ++-- .../DocuMed - Backup.Repository.csproj | 69 ++ DocuMed.Repository/DocuMed.Repository.csproj | 92 +- .../DbContextOptionCustomExtensionsInfo.cs | 7 +- .../Hospitals/CreateHospitalCommandHandler.cs | 16 + .../Hospitals/DeleteHospitalCommandHandler.cs | 19 + .../Hospitals/GetHospitalQueryHandler.cs | 16 + .../Hospitals/GetHospitalsQueryHandler.cs | 16 + .../Hospitals/UpdateHospitalCommandHandler.cs | 23 + .../20231031084330_init.Designer.cs | 863 ---------------- .../Migrations/20231031084330_init.cs | 600 ----------- .../20231105123131_editMhAddGa.Designer.cs | 867 ---------------- .../Migrations/20231105123131_editMhAddGa.cs | 31 - ...20231112120230_editMHAddDouble.Designer.cs | 867 ---------------- .../20231112120230_editMHAddDouble.cs | 108 -- .../20231128085153_editMHAddCode.Designer.cs | 871 ---------------- .../20231128085153_editMHAddCode.cs | 31 - .../ApplicationContextModelSnapshot.cs | 868 ---------------- .../Models/ApplicationContext.cs | 16 +- .../Repositories/Base/BaseRepository.cs | 11 +- .../Repositories/Base/ReadRepository.cs | 9 +- .../Repositories/Base/RepositoryWrapper.cs | 28 +- .../Repositories/Base/WriteRepository.cs | 8 +- .../Entities/MedicalHistoryRepository.cs | 7 +- .../MedicalHistoryTemplateRepository.cs | 7 +- .../Repositories/UnitOfWork/UnitOfWork.cs | 13 +- .../Services/DbInitializerService.cs | 50 +- 88 files changed, 2094 insertions(+), 6854 deletions(-) create mode 100644 DocuMed.Api/Controllers/HospitalController.cs create mode 100644 DocuMed.Api/Sentry/9DC334EC83D3BBA80249F4426A4CB422C68089AE/.installation delete mode 100644 DocuMed.Api/WeatherForecast.cs create mode 100644 DocuMed.Domain/CommandQueries/Commands/HospitalCommands.cs create mode 100644 DocuMed.Domain/CommandQueries/Queries/HospitalQueries.cs create mode 100644 DocuMed.Domain/Dtos/SmallDtos/HospitalSDto.cs create mode 100644 DocuMed.Domain/Dtos/SmallDtos/StudentSDto.cs create mode 100644 DocuMed.Domain/Entities/Hospitals/Hospital.Aggregate.cs create mode 100644 DocuMed.Domain/Entities/Hospitals/Hospital.cs rename DocuMed.Domain/Entities/{City => Hospitals}/Section.cs (63%) delete mode 100644 DocuMed.Domain/Entities/Patient/Patient.cs create mode 100644 DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs create mode 100644 DocuMed.Domain/Entities/Patients/Patient.cs create mode 100644 DocuMed.Domain/Entities/Staffs/Student.Aggregate.cs create mode 100644 DocuMed.Domain/Entities/Staffs/Student.cs create mode 100644 DocuMed.Domain/Mappers/HospitalMapper.g.cs create mode 100644 DocuMed.Domain/Mappers/StudentMapper.g.cs create mode 100644 DocuMed.Domain/Models/Refers.cs create mode 100644 DocuMed.Repository/DocuMed - Backup.Repository.csproj create mode 100644 DocuMed.Repository/Handlers/Hospitals/CreateHospitalCommandHandler.cs create mode 100644 DocuMed.Repository/Handlers/Hospitals/DeleteHospitalCommandHandler.cs create mode 100644 DocuMed.Repository/Handlers/Hospitals/GetHospitalQueryHandler.cs create mode 100644 DocuMed.Repository/Handlers/Hospitals/GetHospitalsQueryHandler.cs create mode 100644 DocuMed.Repository/Handlers/Hospitals/UpdateHospitalCommandHandler.cs delete mode 100644 DocuMed.Repository/Migrations/20231031084330_init.Designer.cs delete mode 100644 DocuMed.Repository/Migrations/20231031084330_init.cs delete mode 100644 DocuMed.Repository/Migrations/20231105123131_editMhAddGa.Designer.cs delete mode 100644 DocuMed.Repository/Migrations/20231105123131_editMhAddGa.cs delete mode 100644 DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.Designer.cs delete mode 100644 DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.cs delete mode 100644 DocuMed.Repository/Migrations/20231128085153_editMHAddCode.Designer.cs delete mode 100644 DocuMed.Repository/Migrations/20231128085153_editMHAddCode.cs delete mode 100644 DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs diff --git a/DocuMed.Api/Controllers/HospitalController.cs b/DocuMed.Api/Controllers/HospitalController.cs new file mode 100644 index 0000000..3b4ac3a --- /dev/null +++ b/DocuMed.Api/Controllers/HospitalController.cs @@ -0,0 +1,65 @@ +using DocuMed.Domain.Entities.MedicalHistory; + +namespace DocuMed.Api.Controllers; + +public class HospitalController : ICarterModule +{ + public void AddRoutes(IEndpointRouteBuilder app) + { + var group = app.NewVersionedApi("Hospital") + .MapGroup("api/hospital") + .RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); + + + group.MapGet("", GetAllAsync) + .WithDisplayName("GetAll") + .HasApiVersion(1.0); + + group.MapGet("{id}", GetAsync) + .WithDisplayName("GetOne") + .HasApiVersion(1.0); + + group.MapPost("", Post) + .HasApiVersion(1.0); + + group.MapPut("", Put) + .HasApiVersion(1.0); + + group.MapDelete("", Delete) + .HasApiVersion(1.0); + } + + // GET:Get All Entity + public virtual async Task GetAllAsync([FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken) + { + return TypedResults.Ok(await repository.GetMedicalHistoriesAsync(page, cancellationToken)); + } + + // GET:Get An Entity By Id + public async Task GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken) + { + + return TypedResults.Ok(await repository.GetMedicalHistoryAsync(id, cancellationToken)); + } + + // POST:Add New Entity + public virtual async Task Post([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await service.AddAsync(dto, cancellationToken)); + } + + // PUT:Update Entity + public virtual async Task Put([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await service.EditAsync(dto, cancellationToken)); + } + + // DELETE:Delete Entity + public virtual async Task Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().GetByIdAsync(cancellationToken, id); + repositoryWrapper.SetRepository().Delete(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + return TypedResults.Ok(); + } +} \ No newline at end of file diff --git a/DocuMed.Api/Controllers/SectionController.cs b/DocuMed.Api/Controllers/SectionController.cs index dcad33d..7833f50 100644 --- a/DocuMed.Api/Controllers/SectionController.cs +++ b/DocuMed.Api/Controllers/SectionController.cs @@ -1,19 +1,18 @@ using Microsoft.IdentityModel.Tokens; +using Section = DocuMed.Domain.Entities.Hospitals.Section; namespace DocuMed.Api.Controllers; public class SectionController : ICarterModule { public virtual void AddRoutes(IEndpointRouteBuilder app) { - var group = app.NewVersionedApi("Section").MapGroup($"api/section"); + var group = app.NewVersionedApi("Section").MapGroup($"api/section") + .RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser()); group.MapGet("", GetAllAsync) .WithDisplayName("GetAll") .HasApiVersion(1.0); - group.MapGet("University/{universityId}", GetAllByUniversityAsync) - .WithDisplayName("GetAllByUniversityId") - .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) .WithDisplayName("GetOne") @@ -37,13 +36,6 @@ public class SectionController : ICarterModule .Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken)); } - // GET:Get All Entity - public virtual async Task GetAllByUniversityAsync(Guid universityId, IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, CancellationToken cancellationToken) - { - return TypedResults.Ok(await repositoryWrapper.SetRepository
().TableNoTracking - .Where(s => s.UniversityId == universityId) - .Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken)); - } // GET:Get An Entity By Id public async Task GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) @@ -53,7 +45,7 @@ public class SectionController : ICarterModule // POST:Add New Entity public virtual async Task Post([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) { - var ent = Section.Create(dto.Name,dto.Detail,dto.UniversityId); + var ent = Section.Create(dto.Name,dto.Detail,dto.HospitalId); repositoryWrapper.SetRepository
().Add(ent); await repositoryWrapper.SaveChangesAsync(cancellationToken); return TypedResults.Ok(ent); @@ -62,7 +54,7 @@ public class SectionController : ICarterModule // PUT:Update Entity public virtual async Task Put([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) { - var ent = Section.Create(dto.Name,dto.Detail, dto.UniversityId); + var ent = Section.Create(dto.Name,dto.Detail, dto.HospitalId); ent.Id = dto.Id; repositoryWrapper.SetRepository
().Update(ent); await repositoryWrapper.SaveChangesAsync(cancellationToken); diff --git a/DocuMed.Api/Controllers/UniversityController.cs b/DocuMed.Api/Controllers/UniversityController.cs index 123c21b..7518bb2 100644 --- a/DocuMed.Api/Controllers/UniversityController.cs +++ b/DocuMed.Api/Controllers/UniversityController.cs @@ -1,4 +1,6 @@ -namespace DocuMed.Api.Controllers; +using DocuMed.Domain.Entities.Hospitals; + +namespace DocuMed.Api.Controllers; public class UniversityController : ICarterModule { @@ -9,11 +11,15 @@ public class UniversityController : ICarterModule .MapGroup($"api/university"); group.MapGet("", GetAllAsync) - .WithDisplayName("GetAll") + .WithDisplayName("Get All") + .HasApiVersion(1.0); + + group.MapGet("{id}/section", GetAllByUniversityAsync) + .WithDisplayName("Get All Sections") .HasApiVersion(1.0); group.MapGet("{id}", GetAsync) - .WithDisplayName("GetOne") + .WithDisplayName("Get One") .HasApiVersion(1.0); group.MapPost("", Post) @@ -27,6 +33,14 @@ public class UniversityController : ICarterModule } + // GET:Get All Sections + public virtual async Task GetAllByUniversityAsync(Guid id, IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, CancellationToken cancellationToken) + { + return TypedResults.Ok(await repositoryWrapper.SetRepository
().TableNoTracking + .Where(s => s.HospitalId == id) + .Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken)); + } + // GET:Get All Entity public virtual async Task GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) => TypedResults.Ok(await repositoryWrapper.SetRepository() diff --git a/DocuMed.Api/Sentry/9DC334EC83D3BBA80249F4426A4CB422C68089AE/.installation b/DocuMed.Api/Sentry/9DC334EC83D3BBA80249F4426A4CB422C68089AE/.installation new file mode 100644 index 0000000..67f2337 --- /dev/null +++ b/DocuMed.Api/Sentry/9DC334EC83D3BBA80249F4426A4CB422C68089AE/.installation @@ -0,0 +1 @@ +c777781b-a540-4f02-854f-d0412869e3eb \ No newline at end of file diff --git a/DocuMed.Api/Services/CurrentUserService.cs b/DocuMed.Api/Services/CurrentUserService.cs index 42fb456..80d87b4 100644 --- a/DocuMed.Api/Services/CurrentUserService.cs +++ b/DocuMed.Api/Services/CurrentUserService.cs @@ -1,16 +1,9 @@ namespace DocuMed.Api.Services; -public class CurrentUserService : ICurrentUserService +public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService { - private readonly IHttpContextAccessor _httpContextAccessor; - - public CurrentUserService(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor; - } - - public string? UserId => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier); - public string? RoleName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role); - public string? UserName => _httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name); - public string? UniversityId => _httpContextAccessor.HttpContext?.User?.FindFirstValue("UniversityId"); + public string? UserId => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier); + public string? RoleName => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role); + public string? UserName => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name); + public string? UniversityId => httpContextAccessor.HttpContext?.User?.FindFirstValue("UniversityId"); } \ No newline at end of file diff --git a/DocuMed.Api/WeatherForecast.cs b/DocuMed.Api/WeatherForecast.cs deleted file mode 100644 index 836e493..0000000 --- a/DocuMed.Api/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace DocuMed.Api -{ - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} \ No newline at end of file diff --git a/DocuMed.Api/WebFramework/Bases/CrudController.cs b/DocuMed.Api/WebFramework/Bases/CrudController.cs index 9e191bf..5f017f5 100644 --- a/DocuMed.Api/WebFramework/Bases/CrudController.cs +++ b/DocuMed.Api/WebFramework/Bases/CrudController.cs @@ -7,18 +7,13 @@ using Microsoft.EntityFrameworkCore; namespace DocuMed.Api.WebFramework.Bases; -public class CrudEndpoint where TEntity : ApiEntity, new() +public class CrudEndpoint( + string endpointName) + where TEntity : ApiEntity, new() { - private readonly string _endpointName; - - public CrudEndpoint(string endpointName) - { - _endpointName = endpointName; - } - public virtual void AddRoutes(IEndpointRouteBuilder app) { - var group = app.NewVersionedApi(_endpointName).MapGroup($"api/{_endpointName}"); + var group = app.NewVersionedApi(endpointName).MapGroup($"api/{endpointName}"); group.MapGet("", GetAllAsync) .WithDisplayName("GetAll") @@ -74,18 +69,12 @@ public class CrudEndpoint where TEntity : ApiEntity, new() +public class CrudEndpoint(string endpointName) + where TEntity : ApiEntity, new() { - private readonly string _endpointName; - - public CrudEndpoint(string endpointName) - { - _endpointName = endpointName; - } - public virtual void AddRoutes(IEndpointRouteBuilder app) { - var group = app.NewVersionedApi(_endpointName).MapGroup($"api/{_endpointName.ToLower()}"); + var group = app.NewVersionedApi(endpointName).MapGroup($"api/{endpointName.ToLower()}"); group.MapGet("", GetAllAsync) .WithDisplayName("GetAll") @@ -151,16 +140,11 @@ public class BaseController : ControllerBase } [Authorize(AuthenticationSchemes = "Bearer")] -public class CrudController : BaseController +public class CrudController(IRepositoryWrapper repositoryWrapper) : BaseController where TDto : BaseDto, new() where TEntity : ApiEntity, new() { - protected readonly IRepositoryWrapper _repositoryWrapper; - - public CrudController(IRepositoryWrapper repositoryWrapper) - { - _repositoryWrapper = repositoryWrapper; - } + protected readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; // GET:Get All Entity [HttpGet] @@ -236,15 +220,10 @@ public class CrudController : BaseController } [Authorize(AuthenticationSchemes = "Bearer")] -public class CrudController : BaseController +public class CrudController(IRepositoryWrapper repositoryWrapper) : BaseController where TEntity : ApiEntity, new() { - protected readonly IRepositoryWrapper _repositoryWrapper; - - public CrudController(IRepositoryWrapper repositoryWrapper) - { - _repositoryWrapper = repositoryWrapper; - } + protected readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; // GET:Get All Entity [HttpGet] diff --git a/DocuMed.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs b/DocuMed.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs index e9d6c1a..e5b4713 100644 --- a/DocuMed.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs +++ b/DocuMed.Api/WebFramework/MiddleWares/ExceptionHandlerMiddleware.cs @@ -15,22 +15,11 @@ public static class ExceptionHandlerMiddlewareExtensions } } -public class ExceptionHandlerMiddleware +public class ExceptionHandlerMiddleware( + RequestDelegate next, + IWebHostEnvironment env, + ILogger logger) { - private readonly IWebHostEnvironment _env; - private readonly ILogger _logger; - private readonly RequestDelegate _next; - - public ExceptionHandlerMiddleware( - RequestDelegate next, - IWebHostEnvironment env, - ILogger logger) - { - _next = next; - _env = env; - _logger = logger; - } - public async Task Invoke(HttpContext context) { string message = null; @@ -39,15 +28,15 @@ public class ExceptionHandlerMiddleware try { - await _next(context); + await next(context); } catch (BaseApiException exception) { - _logger.LogError(exception, exception.Message); + logger.LogError(exception, exception.Message); httpStatusCode = exception.HttpStatusCode; apiStatusCode = exception.ApiStatusCode; - if (_env.IsDevelopment()) + if (env.IsDevelopment()) { var dic = new Dictionary { @@ -84,22 +73,22 @@ public class ExceptionHandlerMiddleware } catch (SecurityTokenExpiredException exception) { - _logger.LogError(exception, exception.Message); + logger.LogError(exception, exception.Message); SetUnAuthorizeResponse(exception); await WriteToResponseAsync(); } catch (UnauthorizedAccessException exception) { - _logger.LogError(exception, exception.Message); + logger.LogError(exception, exception.Message); SetUnAuthorizeResponse(exception); await WriteToResponseAsync(); } catch (Exception exception) { - _logger.LogError(exception, exception.Message); + logger.LogError(exception, exception.Message); - if (_env.IsDevelopment()) + if (env.IsDevelopment()) { var dic = new Dictionary { @@ -168,7 +157,7 @@ public class ExceptionHandlerMiddleware httpStatusCode = HttpStatusCode.Unauthorized; apiStatusCode = ApiResultStatusCode.UnAuthorized; - if (_env.IsDevelopment()) + if (env.IsDevelopment()) { var dic = new Dictionary { diff --git a/DocuMed.Api/WebFramework/MiddleWares/PerformanceMiddleware.cs b/DocuMed.Api/WebFramework/MiddleWares/PerformanceMiddleware.cs index 18b42ca..7a06273 100644 --- a/DocuMed.Api/WebFramework/MiddleWares/PerformanceMiddleware.cs +++ b/DocuMed.Api/WebFramework/MiddleWares/PerformanceMiddleware.cs @@ -10,28 +10,19 @@ public static class PerformanceMiddlewareExtensions } } -public class PerformanceMiddleware +public class PerformanceMiddleware( + RequestDelegate next, + ILogger logger) { - private readonly ILogger _logger; - private readonly RequestDelegate _next; - private readonly Stopwatch _timer; - - public PerformanceMiddleware( - RequestDelegate next, - ILogger logger) - { - _next = next; - _logger = logger; - _timer = new Stopwatch(); - } + private readonly Stopwatch _timer = new(); public async System.Threading.Tasks.Task Invoke(HttpContext context) { _timer.Start(); - await _next(context); + await next(context); _timer.Stop(); var elapsedMilliseconds = _timer.ElapsedMilliseconds; - _logger.LogWarning($"REQUEST TIMER : {elapsedMilliseconds}"); + logger.LogWarning($"REQUEST TIMER : {elapsedMilliseconds}"); } } \ No newline at end of file diff --git a/DocuMed.Api/WebFramework/Swagger/SwaggerConfiguration.cs b/DocuMed.Api/WebFramework/Swagger/SwaggerConfiguration.cs index e861908..9de3497 100644 --- a/DocuMed.Api/WebFramework/Swagger/SwaggerConfiguration.cs +++ b/DocuMed.Api/WebFramework/Swagger/SwaggerConfiguration.cs @@ -139,17 +139,12 @@ public class SetVersionInPaths : IDocumentFilter } } -public class UnauthorizedResponsesOperationFilter : IOperationFilter +public class UnauthorizedResponsesOperationFilter( + bool includeUnauthorizedAndForbiddenResponses, + string schemeName = "Bearer") + : IOperationFilter { - private readonly bool includeUnauthorizedAndForbiddenResponses; - private readonly string schemeName; - - public UnauthorizedResponsesOperationFilter(bool includeUnauthorizedAndForbiddenResponses, - string schemeName = "Bearer") - { - this.includeUnauthorizedAndForbiddenResponses = includeUnauthorizedAndForbiddenResponses; - this.schemeName = schemeName; - } + private readonly string schemeName = schemeName; public void Apply(OpenApiOperation operation, OperationFilterContext context) { diff --git a/DocuMed.Common/DocuMed.Common.csproj b/DocuMed.Common/DocuMed.Common.csproj index db34240..348c66a 100644 --- a/DocuMed.Common/DocuMed.Common.csproj +++ b/DocuMed.Common/DocuMed.Common.csproj @@ -1,5 +1,5 @@ - + - + diff --git a/DocuMed.Core/BaseServices/JwtService.cs b/DocuMed.Core/BaseServices/JwtService.cs index 1662991..eb042a3 100644 --- a/DocuMed.Core/BaseServices/JwtService.cs +++ b/DocuMed.Core/BaseServices/JwtService.cs @@ -5,21 +5,14 @@ using System.Text; namespace DocuMed.Core.BaseServices; -public class JwtService : IJwtService +public class JwtService( + IOptionsSnapshot siteSettings, + SignInManager userSignInManager, + RoleManager roleManager) + : IJwtService { - private readonly SignInManager _signInManager; - private readonly RoleManager _roleManager; - private readonly SiteSettings _siteSettings; + private readonly SiteSettings _siteSettings = siteSettings.Value; - public JwtService( - IOptionsSnapshot siteSettings, - SignInManager userSignInManager, - RoleManager roleManager) - { - _signInManager = userSignInManager; - _roleManager = roleManager; - _siteSettings = siteSettings.Value; - } public async Task> Generate(TUser user) where TUser : ApplicationUser { var tokenId = StringExtensions.GetId(8); @@ -82,7 +75,7 @@ public class JwtService : IJwtService private async Task> GetClaims(TUser baseUser, string jwtId) where TUser : ApplicationUser { - var clFac = (await _signInManager.ClaimsFactory.CreateAsync(baseUser)); + var clFac = (await userSignInManager.ClaimsFactory.CreateAsync(baseUser)); var claims = new List(); claims.Add(new Claim("JwtID", jwtId)); claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName)); @@ -98,8 +91,8 @@ public class JwtService : IJwtService private async Task> GetClaims(TUser baseUser, string jwtId, string roleId) where TUser : ApplicationUser { - var applicationRole = await _roleManager.FindByIdAsync(roleId); - var roleClaims = await _roleManager.GetClaimsAsync(applicationRole); + var applicationRole = await roleManager.FindByIdAsync(roleId); + var roleClaims = await roleManager.GetClaimsAsync(applicationRole); var claims = new List(); claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName)); claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString())); diff --git a/DocuMed.Core/CoreServices/AccountService.cs b/DocuMed.Core/CoreServices/AccountService.cs index 262cb2c..187c9c4 100644 --- a/DocuMed.Core/CoreServices/AccountService.cs +++ b/DocuMed.Core/CoreServices/AccountService.cs @@ -1,55 +1,34 @@ using DocuMed.Domain.Entities.City; +using Section = DocuMed.Domain.Entities.Hospitals.Section; namespace DocuMed.Core.CoreServices; - -public class AccountService : IAccountService +public class AccountService( + UserManager userManager, + SignInManager userSignInManager, + IJwtService jwtService, + ICurrentUserService currentUserService, + IUserService userService, + ISmsService smsService, + IRepositoryWrapper repositoryWrapper) + : IAccountService { - - private readonly UserManager _userManager; - private readonly SignInManager _userSignInManager; - private readonly IJwtService _jwtService; - private readonly ICurrentUserService _currentUserService; - private readonly IUserService _userService; - private readonly ISmsService _smsService; - private readonly IRepositoryWrapper _repositoryWrapper; - - public AccountService( - UserManager userManager, - SignInManager userSignInManager, - IJwtService jwtService, - ICurrentUserService currentUserService, - IUserService userService, - ISmsService smsService, - IRepositoryWrapper repositoryWrapper) - { - _userManager = userManager; - _userSignInManager = userSignInManager; - _jwtService = jwtService; - _currentUserService = currentUserService; - _userService = userService; - _smsService = smsService; - _repositoryWrapper = repositoryWrapper; - } - - - public async Task ForgetPasswordAsync(string phoneNumber) { - var user = await _userManager.FindByNameAsync(phoneNumber); + var user = await userManager.FindByNameAsync(phoneNumber); if (user != null) { var rand = new Random(DateTime.Now.Millisecond); var newPass = rand.Next(1000000, 9000000).ToString(); if (!user.PhoneNumberConfirmed) throw new AppException("شماره تلفن شما تایید نشده است و قابلیت استفاده از فراموشی رمز عبور را ندارید"); - var rp = await _userManager.RemovePasswordAsync(user); + var rp = await userManager.RemovePasswordAsync(user); if (!rp.Succeeded) throw new AppException(string.Join('-', rp.Errors.Select(e => e.Description))); - var ap = await _userManager.AddPasswordAsync(user, newPass); + var ap = await userManager.AddPasswordAsync(user, newPass); if (!ap.Succeeded) throw new AppException(string.Join('-', ap.Errors.Select(e => e.Description))); - await _smsService.SendForgerPasswordAsync(user.PhoneNumber, newPass); + await smsService.SendForgerPasswordAsync(user.PhoneNumber, newPass); return true; } @@ -58,7 +37,7 @@ public class AccountService : IAccountService public async Task CheckMemberShipAsync(string phoneNumber) { - var user = await _userManager.FindByNameAsync(phoneNumber); + var user = await userManager.FindByNameAsync(phoneNumber); if (user == null) return false; return true; @@ -69,23 +48,23 @@ public class AccountService : IAccountService var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber); if (!PhoneNumberExtensions.CheckPhoneNumber(newPhoneNumber)) throw new AppException("شماره تلفن ارسالی اشتباه است"); - var user = await _userManager.FindByNameAsync(newPhoneNumber); + var user = await userManager.FindByNameAsync(newPhoneNumber); if (user == null) - user = await _userService.CreateUserAsync(phoneNumber); + user = await userService.CreateUserAsync(phoneNumber); - var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone"); - await _smsService.SendVerifyCodeAsync(newPhoneNumber, token); + var token = await userManager.GenerateTwoFactorTokenAsync(user, "Phone"); + await smsService.SendVerifyCodeAsync(newPhoneNumber, token); return user.SignUpStatus; } public async Task> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken) { - var result = await _userSignInManager.PasswordSignInAsync(userName, password, false, false); + var result = await userSignInManager.PasswordSignInAsync(userName, password, false, false); if (!result.Succeeded) throw new AppException("رمز عبور یا نام کاربری اشتباه است"); - var admin = await _userManager.FindByNameAsync(userName); + var admin = await userManager.FindByNameAsync(userName); if (admin == null) throw new AppException("نام کاربری یا رمز عبور اشتباه است"); return await CompleteLogin(admin, cancellationToken); @@ -93,11 +72,11 @@ public class AccountService : IAccountService public async Task> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken) { - var user = await _userManager.FindByNameAsync(userName); + var user = await userManager.FindByNameAsync(userName); if (user == null) throw new AppException("نام کاربری یا کد ارسالی اشتباه است", ApiResultStatusCode.NotFound); - var verifyResult = await _userManager.VerifyTwoFactorTokenAsync(user, "Phone", verifyCode); + var verifyResult = await userManager.VerifyTwoFactorTokenAsync(user, "Phone", verifyCode); if (verifyCode == "859585") verifyResult = true; if (!verifyResult) @@ -106,7 +85,7 @@ public class AccountService : IAccountService { user.PhoneNumberConfirmed = true; user.SignUpStatus = SignUpStatus.PhoneNumberVerified; - var result = await _userManager.UpdateAsync(user); + var result = await userManager.UpdateAsync(user); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); } @@ -115,9 +94,9 @@ public class AccountService : IAccountService public async Task> CompleteSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken) { - if (_currentUserService.UserId == null) + if (currentUserService.UserId == null) throw new AppException("User Id is null"); - var user = await _userManager.FindByIdAsync(_currentUserService.UserId); + var user = await userManager.FindByIdAsync(currentUserService.UserId); if (user == null) throw new AppException("User not found", ApiResultStatusCode.NotFound); @@ -131,7 +110,7 @@ public class AccountService : IAccountService user.LastName = requestDto.LastName; user.SignUpStatus = SignUpStatus.SignUpCompleted; user.UniversityId = requestDto.UniversityId; - var result = await _userManager.UpdateAsync(user); + var result = await userManager.UpdateAsync(user); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); @@ -141,11 +120,11 @@ public class AccountService : IAccountService private async Task> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken) { - var token = await _jwtService.Generate(user); + var token = await jwtService.Generate(user); if (token.User.SectionId != Guid.Empty) { - var section = await _repositoryWrapper.SetRepository
().TableNoTracking + var section = await repositoryWrapper.SetRepository
().TableNoTracking .FirstOrDefaultAsync(s => s.Id == user.SectionId, cancellationToken); if (section != null) { diff --git a/DocuMed.Core/EntityServices/MedicalHistoryService.cs b/DocuMed.Core/EntityServices/MedicalHistoryService.cs index 8ae0ab8..376cf7d 100644 --- a/DocuMed.Core/EntityServices/MedicalHistoryService.cs +++ b/DocuMed.Core/EntityServices/MedicalHistoryService.cs @@ -1,21 +1,14 @@ namespace DocuMed.Core.EntityServices; -public class MedicalHistoryService : IMedicalHistoryService +public class MedicalHistoryService( + IRepositoryWrapper repositoryWrapper, + ICurrentUserService currentUserService, + IMedicalHistoryRepository medicalHistoryRepository) + : IMedicalHistoryService { - private readonly IRepositoryWrapper _repositoryWrapper; - private readonly ICurrentUserService _currentUserService; - private readonly IMedicalHistoryRepository _medicalHistoryRepository; - - public MedicalHistoryService(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, IMedicalHistoryRepository medicalHistoryRepository) - { - _repositoryWrapper = repositoryWrapper; - _currentUserService = currentUserService; - _medicalHistoryRepository = medicalHistoryRepository; - } - public async Task EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken) { - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); if (template.Id == Guid.Empty) throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound); @@ -37,27 +30,27 @@ public class MedicalHistoryService : IMedicalHistoryService foreach (var answer in template.Answers.Where(a => a.Id != Guid.Empty)) { - var dbAnswer = await _repositoryWrapper.SetRepository().TableNoTracking + var dbAnswer = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(a => a.Id == answer.Id, cancellationToken); if (dbAnswer != null && dbAnswer.Answer != answer.Answer && answer.Answer != null) { dbAnswer = MedicalHistoryAnswer.Create(answer.Answer, answer.Question, answer.Part, answer.QuestionType, dbAnswer.MedicalHistoryId); dbAnswer.Id = answer.Id; - _repositoryWrapper.SetRepository().Update(dbAnswer); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + repositoryWrapper.SetRepository().Update(dbAnswer); + await repositoryWrapper.SaveChangesAsync(cancellationToken); } } - _medicalHistoryRepository.Update(ent); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + medicalHistoryRepository.Update(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } public async Task AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken) { - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, template.FirstName, template.LastName, template.FatherName, template.NationalId, template.Age, template.BirthDate, @@ -70,8 +63,8 @@ public class MedicalHistoryService : IMedicalHistoryService foreach (var answer in template.Answers) ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType); - _medicalHistoryRepository.Add(ent); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + medicalHistoryRepository.Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } } \ No newline at end of file diff --git a/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs b/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs index 3bd6c09..5c1a3b1 100644 --- a/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs +++ b/DocuMed.Core/EntityServices/MedicalHistoryTemplateService.cs @@ -5,28 +5,22 @@ using System.Threading; namespace DocuMed.Core.EntityServices; -public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService +public class MedicalHistoryTemplateService( + IRepositoryWrapper repositoryWrapper, + ICurrentUserService currentUserService, + IMedicalHistoryTemplateRepository medicalHistoryTemplateRepository) + : IMedicalHistoryTemplateService { - private readonly IRepositoryWrapper _repositoryWrapper; - private readonly ICurrentUserService _currentUserService; - private readonly IMedicalHistoryTemplateRepository _medicalHistoryTemplateRepository; - - public MedicalHistoryTemplateService(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService,IMedicalHistoryTemplateRepository medicalHistoryTemplateRepository) - { - _repositoryWrapper = repositoryWrapper; - _currentUserService = currentUserService; - _medicalHistoryTemplateRepository = medicalHistoryTemplateRepository; - } public async Task EditAsync(MedicalHistoryTemplateLDto template, CancellationToken cancellationToken) { - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); if (template.Id==Guid.Empty) throw new AppException("پیش نویس پیدا نشد", ApiResultStatusCode.NotFound); var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId); ent.Id = template.Id; - var questions = await _repositoryWrapper.SetRepository() + var questions = await repositoryWrapper.SetRepository() .TableNoTracking .Where(q => q.MedicalHistoryTemplateId == ent.Id) .ToListAsync(cancellationToken); @@ -34,28 +28,28 @@ public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService { if (template.Questions.FirstOrDefault(q => q.Id == question.Id) == null) { - _repositoryWrapper.SetRepository() + repositoryWrapper.SetRepository() .Delete(question); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + await repositoryWrapper.SaveChangesAsync(cancellationToken); } } foreach (var question in template.Questions.Where(q=>q.Id==Guid.Empty)) ent.AddQuestion(question.Question, question.Part, question.QuestionType,question.BodySystem,question.IsSign,question.IsSymptom); - _medicalHistoryTemplateRepository.Update(ent); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + medicalHistoryTemplateRepository.Update(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } public async Task AddAsync(MedicalHistoryTemplateLDto template,CancellationToken cancellationToken) { - if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) + if (!Guid.TryParse(currentUserService.UserId, out Guid userId)) throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized); var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId); foreach (var question in template.Questions) ent.AddQuestion(question.Question, question.Part, question.QuestionType, question.BodySystem, question.IsSign, question.IsSymptom); - _medicalHistoryTemplateRepository.Add(ent); - await _repositoryWrapper.SaveChangesAsync(cancellationToken); + medicalHistoryTemplateRepository.Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } } \ No newline at end of file diff --git a/DocuMed.Core/EntityServices/UserService.cs b/DocuMed.Core/EntityServices/UserService.cs index ec43969..6c972bf 100644 --- a/DocuMed.Core/EntityServices/UserService.cs +++ b/DocuMed.Core/EntityServices/UserService.cs @@ -1,33 +1,24 @@ namespace DocuMed.Core.EntityServices; -public class UserService : IUserService +public class UserService( + ICurrentUserService currentUserService, + UserManager userManager, + RoleManager roleManager, + IRepositoryWrapper repositoryWrapper) + : IUserService { - private readonly ICurrentUserService _currentUserService; - private readonly UserManager _userManager; - private readonly RoleManager _roleManager; - private readonly IRepositoryWrapper _repositoryWrapper; - - public UserService(ICurrentUserService currentUserService, - UserManager userManager, - RoleManager roleManager, - IRepositoryWrapper repositoryWrapper) - { - _currentUserService = currentUserService; - _userManager = userManager; - _roleManager = roleManager; - _repositoryWrapper = repositoryWrapper; - } + private readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; public async Task> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default) { - var users = await _userManager.Users.Select(ApplicationUserMapper.ProjectToSDto).ToListAsync(cancellationToken); + var users = await userManager.Users.Select(ApplicationUserMapper.ProjectToSDto).ToListAsync(cancellationToken); return users; } public async Task GetUserAsync(Guid userId) - => (await _userManager.FindByIdAsync(userId.ToString())).AdaptToSDto(); + => (await userManager.FindByIdAsync(userId.ToString())).AdaptToSDto(); public async Task CreateUserAsync(string phoneNumber) { @@ -37,7 +28,7 @@ public class UserService : IUserService PhoneNumber = phoneNumber, SignUpStatus = SignUpStatus.StartSignUp }; - var result = await _userManager.CreateAsync(user); + var result = await userManager.CreateAsync(user); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); return user; @@ -59,18 +50,18 @@ public class UserService : IUserService }; if (!request.Password.IsNullOrEmpty()) { - var result = await _userManager.CreateAsync(user, request.Password); + var result = await userManager.CreateAsync(user, request.Password); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); } else { - var result = await _userManager.CreateAsync(user); + var result = await userManager.CreateAsync(user); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); } - var roleResult = await _userManager.AddToRoleAsync(user, RoleNames.Student); + var roleResult = await userManager.AddToRoleAsync(user, RoleNames.Student); if (!roleResult.Succeeded) throw new AppException(string.Join('|', roleResult.Errors)); @@ -79,10 +70,10 @@ public class UserService : IUserService public async Task EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken) { - if (_currentUserService.UserId == null) + if (currentUserService.UserId == null) throw new AppException("Wrong authorize token , UserId needed"); - var user = await _userManager.FindByIdAsync(_currentUserService.UserId); + var user = await userManager.FindByIdAsync(currentUserService.UserId); if (user == null) throw new AppException("User not found", ApiResultStatusCode.NotFound); user.LastName = request.LastName; @@ -100,15 +91,15 @@ public class UserService : IUserService if (request.SectionId != Guid.Empty) user.SectionId = request.SectionId; - var result = await _userManager.UpdateAsync(user); + var result = await userManager.UpdateAsync(user); if (!result.Succeeded) throw new AppException(string.Join('|', result.Errors)); if (!request.Password.IsNullOrEmpty()) { - if (await _userManager.HasPasswordAsync(user)) - await _userManager.RemovePasswordAsync(user); + if (await userManager.HasPasswordAsync(user)) + await userManager.RemovePasswordAsync(user); - var addPassResult = await _userManager.AddPasswordAsync(user, request.Password); + var addPassResult = await userManager.AddPasswordAsync(user, request.Password); if (!addPassResult.Succeeded) throw new AppException(string.Join('|', addPassResult.Errors)); } @@ -117,10 +108,10 @@ public class UserService : IUserService public async Task RemoveUserAsync(Guid userId, CancellationToken cancellationToken) { - var user = await _userManager.FindByIdAsync(userId.ToString()); + var user = await userManager.FindByIdAsync(userId.ToString()); if (user == null) throw new AppException("User not found", ApiResultStatusCode.NotFound); - var removeResult = await _userManager.DeleteAsync(user); + var removeResult = await userManager.DeleteAsync(user); if (!removeResult.Succeeded) throw new AppException(string.Join('|', removeResult.Errors)); return true; @@ -131,7 +122,7 @@ public class UserService : IUserService public async Task> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default) { - var roles = await _roleManager.Roles + var roles = await roleManager.Roles .Skip(page * 15) .Take(15) .ToListAsync(cancellationToken); @@ -140,12 +131,12 @@ public class UserService : IUserService public async Task GetRoleAsync(Guid roleId) { - var role = (await _roleManager.FindByIdAsync(roleId.ToString())); + var role = (await roleManager.FindByIdAsync(roleId.ToString())); if (role == null) throw new AppException("نقش پیدا نشد", ApiResultStatusCode.NotFound); var roleDto = role.Adapt(); - roleDto.Permissions = (await _roleManager.GetClaimsAsync(role)) + roleDto.Permissions = (await roleManager.GetClaimsAsync(role)) .Where(c => c.Type == CustomClaimType.Permission) .Select(c => c.Value) .ToList(); @@ -164,12 +155,12 @@ public class UserService : IUserService Description = request.Description, Name = $"{request.EnglishName}" }; - var createRoleResult = await _roleManager.CreateAsync(applicationRole); + var createRoleResult = await roleManager.CreateAsync(applicationRole); if (!createRoleResult.Succeeded) throw new AppException(string.Join('|', createRoleResult.Errors)); foreach (var claim in request.Permissions) - await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim)); + await roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim)); return applicationRole; } @@ -177,7 +168,7 @@ public class UserService : IUserService { if (request.EnglishName.IsNullOrEmpty()) throw new AppException("لطفا نام انگلیسی را وارد کنید"); - var applicationRole = await _roleManager.FindByIdAsync(request.RoleId.ToString()); + var applicationRole = await roleManager.FindByIdAsync(request.RoleId.ToString()); if (applicationRole == null) throw new AppException("نقش پیدا نشد"); @@ -186,10 +177,10 @@ public class UserService : IUserService applicationRole.Description = request.Description; applicationRole.Name = $"{request.EnglishName}"; - var createRoleResult = await _roleManager.UpdateAsync(applicationRole); + var createRoleResult = await roleManager.UpdateAsync(applicationRole); if (!createRoleResult.Succeeded) throw new AppException(string.Join('|', createRoleResult.Errors)); - var roleClaims = (await _roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList(); + var roleClaims = (await roleManager.GetClaimsAsync(applicationRole)).Where(c => c.Type == CustomClaimType.Permission).ToList(); foreach (var roleClaim in roleClaims.ToList()) { if (request.Permissions.Contains(roleClaim.Value)) @@ -200,20 +191,20 @@ public class UserService : IUserService } foreach (var claim in request.Permissions) - await _roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim)); + await roleManager.AddClaimAsync(applicationRole, new Claim(CustomClaimType.Permission, claim)); foreach (var claim in roleClaims) - await _roleManager.RemoveClaimAsync(applicationRole, claim); + await roleManager.RemoveClaimAsync(applicationRole, claim); return true; } public async Task RemoveRoleAsync(Guid roleId) { - var applicationRole = await _roleManager.FindByIdAsync(roleId.ToString()); + var applicationRole = await roleManager.FindByIdAsync(roleId.ToString()); if (applicationRole == null) throw new AppException("User not found", ApiResultStatusCode.NotFound); - var removeResult = await _roleManager.DeleteAsync(applicationRole); + var removeResult = await roleManager.DeleteAsync(applicationRole); if (!removeResult.Succeeded) throw new AppException(string.Join('|', removeResult.Errors)); return true; diff --git a/DocuMed.Core/Models/Api/ApiResult.cs b/DocuMed.Core/Models/Api/ApiResult.cs index 89cc760..123b6f6 100644 --- a/DocuMed.Core/Models/Api/ApiResult.cs +++ b/DocuMed.Core/Models/Api/ApiResult.cs @@ -1,19 +1,12 @@ namespace DocuMed.Core.Models.Api; -public class ApiResult +public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) { - public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) - { - IsSuccess = isSuccess; - StatusCode = statusCode; - Message = message ?? statusCode.ToDisplay(); - } - - public bool IsSuccess { get; set; } - public ApiResultStatusCode StatusCode { get; set; } + public bool IsSuccess { get; set; } = isSuccess; + public ApiResultStatusCode StatusCode { get; set; } = statusCode; [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string Message { get; set; } + public string Message { get; set; } = message ?? statusCode.ToDisplay(); #region Implicit Operators @@ -62,17 +55,12 @@ public class ApiResult #endregion } -public class ApiResult : ApiResult +public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) + : ApiResult(isSuccess, statusCode, message) where TData : class { - public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) - : base(isSuccess, statusCode, message) - { - Data = data; - } - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public TData Data { get; set; } + public TData Data { get; set; } = data; #region Implicit Operators diff --git a/DocuMed.Domain/CommandQueries/Commands/HospitalCommands.cs b/DocuMed.Domain/CommandQueries/Commands/HospitalCommands.cs new file mode 100644 index 0000000..f01f95e --- /dev/null +++ b/DocuMed.Domain/CommandQueries/Commands/HospitalCommands.cs @@ -0,0 +1,5 @@ +namespace DocuMed.Domain.CommandQueries.Commands; + +public sealed record CreateHospitalCommand(string Name, string Detail, string Address, Guid UniversityId) : IRequest; +public sealed record UpdateHospitalCommand(Guid Id,string Name, string Detail, string Address, Guid UniversityId) : IRequest; +public sealed record DeleteHospitalCommand(Guid Id) : IRequest; \ No newline at end of file diff --git a/DocuMed.Domain/CommandQueries/Queries/HospitalQueries.cs b/DocuMed.Domain/CommandQueries/Queries/HospitalQueries.cs new file mode 100644 index 0000000..e44548b --- /dev/null +++ b/DocuMed.Domain/CommandQueries/Queries/HospitalQueries.cs @@ -0,0 +1,4 @@ +namespace DocuMed.Domain.CommandQueries.Queries; + +public sealed record GetHospitalsQuery(int Page = 0 , int Size = Refers.SizeM) : IRequest>; +public sealed record GetHospitalQuery(Guid Id) : IRequest; \ No newline at end of file diff --git a/DocuMed.Domain/DocuMed.Domain.csproj b/DocuMed.Domain/DocuMed.Domain.csproj index f0ac7ca..498e132 100644 --- a/DocuMed.Domain/DocuMed.Domain.csproj +++ b/DocuMed.Domain/DocuMed.Domain.csproj @@ -1,6 +1,6 @@  - + - + @@ -42,11 +42,10 @@ - - + @@ -56,11 +55,15 @@ + + + + diff --git a/DocuMed.Domain/Dtos/SmallDtos/HospitalSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/HospitalSDto.cs new file mode 100644 index 0000000..4997987 --- /dev/null +++ b/DocuMed.Domain/Dtos/SmallDtos/HospitalSDto.cs @@ -0,0 +1,9 @@ +namespace DocuMed.Domain.Dtos.SmallDtos; + +public class HospitalSDto : BaseDto +{ + public string Name { get; set; } = string.Empty; + public string Detail { get; set; } = string.Empty; + public string Address { get; set; } = string.Empty; + public string UniversityName { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/DocuMed.Domain/Dtos/SmallDtos/SectionSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/SectionSDto.cs index 1c14469..1f6c835 100644 --- a/DocuMed.Domain/Dtos/SmallDtos/SectionSDto.cs +++ b/DocuMed.Domain/Dtos/SmallDtos/SectionSDto.cs @@ -4,5 +4,5 @@ public class SectionSDto : BaseDto { public string Name { get; set; } = string.Empty; public string Detail { get; set; } = string.Empty; - public Guid UniversityId { get; set; } + public Guid HospitalId { get; set; } } \ No newline at end of file diff --git a/DocuMed.Domain/Dtos/SmallDtos/StudentSDto.cs b/DocuMed.Domain/Dtos/SmallDtos/StudentSDto.cs new file mode 100644 index 0000000..4a60086 --- /dev/null +++ b/DocuMed.Domain/Dtos/SmallDtos/StudentSDto.cs @@ -0,0 +1,18 @@ +namespace DocuMed.Domain.Dtos.SmallDtos; + +public class StudentSDto : BaseDto +{ + public string StudentId { get; set; } = string.Empty; + + public Guid UniversityId { get; set; } + public string UniversityName { get; set; } = string.Empty; + + public Guid SectionId { get; set; } + public string SectionName { get; set; } = string.Empty; + + public Guid UserId { get; set; } + public string PhoneNumber { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string NationalId { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/City/Aggregate.City.cs b/DocuMed.Domain/Entities/City/Aggregate.City.cs index 10642b0..942dae3 100644 --- a/DocuMed.Domain/Entities/City/Aggregate.City.cs +++ b/DocuMed.Domain/Entities/City/Aggregate.City.cs @@ -22,12 +22,4 @@ public partial class University { return new University(name, address, cityId); } -} - -public partial class Section -{ - public static Section Create(string name, string detail, Guid universityId) - { - return new Section(name, detail, universityId); - } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/City/City.cs b/DocuMed.Domain/Entities/City/City.cs index 35ab1b2..8e1f731 100644 --- a/DocuMed.Domain/Entities/City/City.cs +++ b/DocuMed.Domain/Entities/City/City.cs @@ -1,8 +1,10 @@ namespace DocuMed.Domain.Entities.City; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] [GenerateMapper] + public partial class City : ApiEntity { public City() diff --git a/DocuMed.Domain/Entities/City/University.cs b/DocuMed.Domain/Entities/City/University.cs index 6192125..7ccc8b6 100644 --- a/DocuMed.Domain/Entities/City/University.cs +++ b/DocuMed.Domain/Entities/City/University.cs @@ -22,5 +22,5 @@ public partial class University : ApiEntity public Guid CityId { get; internal set; } public City? City { get; internal set; } - public List
Sections { get; internal set; } = new(); + public List Sections { get; internal set; } = new(); } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Hospitals/Hospital.Aggregate.cs b/DocuMed.Domain/Entities/Hospitals/Hospital.Aggregate.cs new file mode 100644 index 0000000..f3fb294 --- /dev/null +++ b/DocuMed.Domain/Entities/Hospitals/Hospital.Aggregate.cs @@ -0,0 +1,15 @@ +namespace DocuMed.Domain.Entities.Hospitals; + +public partial class Hospital +{ + public static Hospital Create(string name, string detail, string address, Guid universityId) + => new Hospital(name, detail, address, universityId); +} + +public partial class Section +{ + public static Hospitals.Section Create(string name, string detail, Guid universityId) + { + return new Hospitals.Section(name, detail, universityId); + } +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Hospitals/Hospital.cs b/DocuMed.Domain/Entities/Hospitals/Hospital.cs new file mode 100644 index 0000000..bb3e018 --- /dev/null +++ b/DocuMed.Domain/Entities/Hospitals/Hospital.cs @@ -0,0 +1,26 @@ +namespace DocuMed.Domain.Entities.Hospitals; + +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] +public partial class Hospital : ApiEntity +{ + public Hospital() + { + + } + + public Hospital(string name, string detail, string address, Guid universityId) + { + Name = name; + Detail = detail; + Address = address; + UniversityId = universityId; + } + public string Name { get; internal set; } = string.Empty; + public string Detail { get; internal set; } = string.Empty; + public string Address { get; internal set; } = string.Empty; + public Guid UniversityId { get; internal set; } + public University? University { get; internal set; } + + public virtual List
Sections { get; internal set; } = new (); +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/City/Section.cs b/DocuMed.Domain/Entities/Hospitals/Section.cs similarity index 63% rename from DocuMed.Domain/Entities/City/Section.cs rename to DocuMed.Domain/Entities/Hospitals/Section.cs index f75cbda..52c5726 100644 --- a/DocuMed.Domain/Entities/City/Section.cs +++ b/DocuMed.Domain/Entities/Hospitals/Section.cs @@ -1,4 +1,4 @@ -namespace DocuMed.Domain.Entities.City; +namespace DocuMed.Domain.Entities.Hospitals; [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] @@ -10,16 +10,16 @@ public partial class Section : ApiEntity } - public Section(string name, string detail, Guid universityId) + public Section(string name, string detail, Guid hospitalId) { Name = name; Detail = detail; - UniversityId = universityId; + HospitalId = hospitalId; } public string Name { get; internal set; } = string.Empty; public string Detail { get; internal set; } = string.Empty; - public Guid UniversityId { get; internal set; } - public University? University { get; internal set; } + public Guid HospitalId { get; internal set; } + public Hospital? Hospital { get; internal set; } } \ No newline at end of file diff --git a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs index a43d9ee..0595f28 100644 --- a/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs +++ b/DocuMed.Domain/Entities/MedicalHistory/MedicalHistory.cs @@ -1,9 +1,11 @@ namespace DocuMed.Domain.Entities.MedicalHistory; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] [GenerateMapper] + public partial class MedicalHistory : ApiEntity { public MedicalHistory() diff --git a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs index af01062..1c9658e 100644 --- a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs +++ b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryQuestion.cs @@ -1,7 +1,10 @@ namespace DocuMed.Domain.Entities.MedicalHistoryTemplate; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] [GenerateMapper] + public partial class MedicalHistoryQuestion : ApiEntity { public MedicalHistoryQuestion() diff --git a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs index c295e40..4529d16 100644 --- a/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs +++ b/DocuMed.Domain/Entities/MedicalHistoryTemplate/MedicalHistoryTemplate.cs @@ -1,11 +1,9 @@ namespace DocuMed.Domain.Entities.MedicalHistoryTemplate; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]LDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)] +[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)] [GenerateMapper] - - - public partial class MedicalHistoryTemplate : ApiEntity { public MedicalHistoryTemplate() diff --git a/DocuMed.Domain/Entities/Patient/Patient.cs b/DocuMed.Domain/Entities/Patient/Patient.cs deleted file mode 100644 index 1a3fb91..0000000 --- a/DocuMed.Domain/Entities/Patient/Patient.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace DocuMed.Domain.Entities.Patient; -[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] -[GenerateMapper] -public class Patient -{ - public string FirstName { get; internal set; } = string.Empty; - public string LastName { get; internal set; } = string.Empty; - public string FatherName { get; internal set; } = string.Empty; - public string NationalId { get; internal set; } = string.Empty; - public int Age { get; internal set; } - public DateTime BirthDate { get; internal set; } -} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs b/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs new file mode 100644 index 0000000..ba40025 --- /dev/null +++ b/DocuMed.Domain/Entities/Patients/Patient.Aggregate.cs @@ -0,0 +1,7 @@ +namespace DocuMed.Domain.Entities.Patients; + +public partial class Patient +{ + public static Patient Create(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId) + => new Patient(unitNumber, room, bed, admissionAt, sectionId, userId); +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Patients/Patient.cs b/DocuMed.Domain/Entities/Patients/Patient.cs new file mode 100644 index 0000000..c06ea6a --- /dev/null +++ b/DocuMed.Domain/Entities/Patients/Patient.cs @@ -0,0 +1,33 @@ +using Section = DocuMed.Domain.Entities.Hospitals.Section; + +namespace DocuMed.Domain.Entities.Patients; + +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] +public partial class Patient : ApiEntity +{ + public Patient() + { + + } + + public Patient(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId) + { + UnitNumber = unitNumber; + Room = room; + Bed = bed; + AdmissionAt = admissionAt; + SectionId = sectionId; + UserId = userId; + } + public string UnitNumber { get; internal set; } = string.Empty; + public string Room { get; internal set; } = string.Empty; + public string Bed { get; internal set; } = string.Empty; + public DateTime AdmissionAt { get; internal set; } + + public Guid SectionId { get; internal set; } + public Section? Section { get; internal set; } + + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Staffs/Student.Aggregate.cs b/DocuMed.Domain/Entities/Staffs/Student.Aggregate.cs new file mode 100644 index 0000000..12058f5 --- /dev/null +++ b/DocuMed.Domain/Entities/Staffs/Student.Aggregate.cs @@ -0,0 +1,7 @@ +namespace DocuMed.Domain.Entities.Staffs; + +public partial class Student +{ + public static Student Create(Guid universityId, Guid sectionId, Guid userId) + => new Student(universityId, sectionId, userId); +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/Staffs/Student.cs b/DocuMed.Domain/Entities/Staffs/Student.cs new file mode 100644 index 0000000..f5cfec2 --- /dev/null +++ b/DocuMed.Domain/Entities/Staffs/Student.cs @@ -0,0 +1,31 @@ +using Section = DocuMed.Domain.Entities.Hospitals.Section; + +namespace DocuMed.Domain.Entities.Staffs; + +[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] +[GenerateMapper] +public partial class Student : ApiEntity +{ + public Student() + { + + } + + public Student(Guid universityId, Guid sectionId, Guid userId) + { + UniversityId = universityId; + SectionId = sectionId; + UserId = userId; + } + + public string StudentId { get; set; } = string.Empty; + + public Guid UniversityId { get; internal set; } + public University? University { get; internal set; } + + public Guid SectionId { get; internal set; } + public Section? Section { get; internal set; } + + public Guid UserId { get; internal set; } + public ApplicationUser? User { get; internal set; } +} \ No newline at end of file diff --git a/DocuMed.Domain/Entities/User/ApplicationUser.cs b/DocuMed.Domain/Entities/User/ApplicationUser.cs index ae75da4..dfb1346 100644 --- a/DocuMed.Domain/Entities/User/ApplicationUser.cs +++ b/DocuMed.Domain/Entities/User/ApplicationUser.cs @@ -1,4 +1,6 @@ -namespace DocuMed.Domain.Entities.User; +using DocuMed.Domain.Entities.Patients; + +namespace DocuMed.Domain.Entities.User; [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [GenerateMapper] @@ -7,14 +9,10 @@ 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 string StudentId { get; set; } = string.Empty; public DateTime BirthDate { get; set; } public Gender Gender { get; set; } public SignUpStatus SignUpStatus { get; set; } - public Guid? UniversityId { get; set; } - public University? University { get; set; } - - public Guid? SectionId { get; set; } - public Section? Section { get; set; } + public Student? Student { get; set; } + public Patient? Patient { get; set; } } diff --git a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs index 85ba834..76463b8 100644 --- a/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs +++ b/DocuMed.Domain/Mappers/ApplicationUserMapper.g.cs @@ -1,9 +1,7 @@ using System; using System.Linq.Expressions; using DocuMed.Domain.Dtos.SmallDtos; -using DocuMed.Domain.Entities.City; using DocuMed.Domain.Entities.User; -using Mapster.Models; namespace DocuMed.Domain.Mappers { @@ -16,18 +14,9 @@ namespace DocuMed.Domain.Mappers FirstName = p1.FirstName, LastName = p1.LastName, NationalId = p1.NationalId, - StudentId = p1.StudentId, BirthDate = p1.BirthDate, Gender = p1.Gender, SignUpStatus = p1.SignUpStatus, - UniversityId = (Guid?)p1.UniversityId, - University = new University() {Id = p1.UniversityId}, - SectionId = (Guid?)p1.SectionId, - Section = new Section() - { - Name = p1.SectionName, - Id = p1.SectionId - }, Id = p1.Id, UserName = p1.UserName, Email = p1.Email, @@ -46,14 +35,9 @@ namespace DocuMed.Domain.Mappers result.FirstName = p2.FirstName; result.LastName = p2.LastName; result.NationalId = p2.NationalId; - result.StudentId = p2.StudentId; result.BirthDate = p2.BirthDate; result.Gender = p2.Gender; result.SignUpStatus = p2.SignUpStatus; - result.UniversityId = (Guid?)p2.UniversityId; - result.University = funcMain1(new Never(), result.University, p2); - result.SectionId = (Guid?)p2.SectionId; - result.Section = funcMain2(new Never(), result.Section, p2); result.Id = p2.Id; result.UserName = p2.UserName; result.Email = p2.Email; @@ -62,112 +46,85 @@ namespace DocuMed.Domain.Mappers return result; } - public static Expression> ProjectToApplicationUser => p8 => new ApplicationUser() + public static Expression> ProjectToApplicationUser => p4 => new ApplicationUser() { - FirstName = p8.FirstName, - LastName = p8.LastName, - NationalId = p8.NationalId, - StudentId = p8.StudentId, - BirthDate = p8.BirthDate, - Gender = p8.Gender, - SignUpStatus = p8.SignUpStatus, - UniversityId = (Guid?)p8.UniversityId, - University = new University() {Id = p8.UniversityId}, - SectionId = (Guid?)p8.SectionId, - Section = new Section() - { - Name = p8.SectionName, - Id = p8.SectionId - }, - Id = p8.Id, - UserName = p8.UserName, - Email = p8.Email, - PhoneNumber = p8.PhoneNumber, - PhoneNumberConfirmed = p8.PhoneNumberConfirmed + FirstName = p4.FirstName, + LastName = p4.LastName, + NationalId = p4.NationalId, + BirthDate = p4.BirthDate, + Gender = p4.Gender, + SignUpStatus = p4.SignUpStatus, + Id = p4.Id, + UserName = p4.UserName, + Email = p4.Email, + PhoneNumber = p4.PhoneNumber, + PhoneNumberConfirmed = p4.PhoneNumberConfirmed }; - public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p9) + public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5) { - return p9 == null ? null : new ApplicationUserSDto() + return p5 == null ? null : new ApplicationUserSDto() { - FirstName = p9.FirstName, - LastName = p9.LastName, - UserName = p9.UserName, - Email = p9.Email, - PhoneNumber = p9.PhoneNumber, - PhoneNumberConfirmed = p9.PhoneNumberConfirmed, - NationalId = p9.NationalId, - StudentId = p9.StudentId, - BirthDate = p9.BirthDate, - Gender = p9.Gender, - SignUpStatus = p9.SignUpStatus, - UniversityId = p9.UniversityId == null ? default(Guid) : (Guid)p9.UniversityId, - SectionId = p9.SectionId == null ? default(Guid) : (Guid)p9.SectionId, - SectionName = p9.Section != null ? p9.Section.Name : string.Empty, - Id = p9.Id + FirstName = p5.FirstName, + LastName = p5.LastName, + UserName = p5.UserName, + Email = p5.Email, + PhoneNumber = p5.PhoneNumber, + PhoneNumberConfirmed = p5.PhoneNumberConfirmed, + NationalId = p5.NationalId, + StudentId = funcMain1(p5.Student == null ? null : (Guid?)p5.Student.Id), + BirthDate = p5.BirthDate, + Gender = p5.Gender, + SignUpStatus = p5.SignUpStatus, + Id = p5.Id }; } - public static ApplicationUserSDto AdaptTo(this ApplicationUser p10, ApplicationUserSDto p11) + public static ApplicationUserSDto AdaptTo(this ApplicationUser p7, ApplicationUserSDto p8) { - if (p10 == null) + if (p7 == null) { return null; } - ApplicationUserSDto result = p11 ?? new ApplicationUserSDto(); + ApplicationUserSDto result = p8 ?? new ApplicationUserSDto(); - result.FirstName = p10.FirstName; - result.LastName = p10.LastName; - result.UserName = p10.UserName; - result.Email = p10.Email; - result.PhoneNumber = p10.PhoneNumber; - result.PhoneNumberConfirmed = p10.PhoneNumberConfirmed; - result.NationalId = p10.NationalId; - result.StudentId = p10.StudentId; - result.BirthDate = p10.BirthDate; - result.Gender = p10.Gender; - result.SignUpStatus = p10.SignUpStatus; - result.UniversityId = p10.UniversityId == null ? default(Guid) : (Guid)p10.UniversityId; - result.SectionId = p10.SectionId == null ? default(Guid) : (Guid)p10.SectionId; - result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty; - result.Id = p10.Id; + result.FirstName = p7.FirstName; + result.LastName = p7.LastName; + result.UserName = p7.UserName; + result.Email = p7.Email; + result.PhoneNumber = p7.PhoneNumber; + result.PhoneNumberConfirmed = p7.PhoneNumberConfirmed; + result.NationalId = p7.NationalId; + result.StudentId = funcMain2(p7.Student == null ? null : (Guid?)p7.Student.Id, result.StudentId); + result.BirthDate = p7.BirthDate; + result.Gender = p7.Gender; + result.SignUpStatus = p7.SignUpStatus; + result.Id = p7.Id; return result; } - public static Expression> ProjectToSDto => p12 => new ApplicationUserSDto() + public static Expression> ProjectToSDto => p11 => new ApplicationUserSDto() { - FirstName = p12.FirstName, - LastName = p12.LastName, - UserName = p12.UserName, - Email = p12.Email, - PhoneNumber = p12.PhoneNumber, - PhoneNumberConfirmed = p12.PhoneNumberConfirmed, - NationalId = p12.NationalId, - StudentId = p12.StudentId, - BirthDate = p12.BirthDate, - Gender = p12.Gender, - SignUpStatus = p12.SignUpStatus, - UniversityId = p12.UniversityId == null ? default(Guid) : (Guid)p12.UniversityId, - SectionId = p12.SectionId == null ? default(Guid) : (Guid)p12.SectionId, - SectionName = p12.Section != null ? p12.Section.Name : string.Empty, - Id = p12.Id + FirstName = p11.FirstName, + LastName = p11.LastName, + UserName = p11.UserName, + Email = p11.Email, + PhoneNumber = p11.PhoneNumber, + PhoneNumberConfirmed = p11.PhoneNumberConfirmed, + NationalId = p11.NationalId, + StudentId = p11.Student.Id.ToString(), + BirthDate = p11.BirthDate, + Gender = p11.Gender, + SignUpStatus = p11.SignUpStatus, + Id = p11.Id }; - private static University funcMain1(Never p4, University p5, ApplicationUserSDto p2) + private static string funcMain1(Guid? p6) { - University result = p5 ?? new University(); - - result.Id = p2.UniversityId; - return result; - + return p6 == null ? null : ((Guid)p6).ToString(); } - private static Section funcMain2(Never p6, Section p7, ApplicationUserSDto p2) + private static string funcMain2(Guid? p9, string p10) { - Section result = p7 ?? new Section(); - - result.Name = p2.SectionName; - result.Id = p2.SectionId; - return result; - + return p9 == null ? null : ((Guid)p9).ToString(); } } } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/CityMapper.g.cs b/DocuMed.Domain/Mappers/CityMapper.g.cs index 9003355..fd30af8 100644 --- a/DocuMed.Domain/Mappers/CityMapper.g.cs +++ b/DocuMed.Domain/Mappers/CityMapper.g.cs @@ -10,197 +10,192 @@ namespace DocuMed.Domain.Mappers { public static partial class CityMapper { - public static City AdaptToCity(this CitySDto p1) + public static City AdaptToCity(this CityLDto p1) { return p1 == null ? null : new City() { Name = p1.Name, + Universities = funcMain1(p1.Universities), Id = p1.Id }; } - public static City AdaptTo(this CitySDto p2, City p3) + public static City AdaptTo(this CityLDto p3, City p4) { - if (p2 == null) + if (p3 == null) { return null; } - City result = p3 ?? new City(); + City result = p4 ?? new City(); - result.Name = p2.Name; - result.Id = p2.Id; + result.Name = p3.Name; + result.Universities = funcMain2(p3.Universities, result.Universities); + result.Id = p3.Id; return result; } - public static Expression> ProjectToCity => p4 => new City() + public static Expression> ProjectToCity => p7 => new City() { - Name = p4.Name, - Id = p4.Id - }; - public static CitySDto AdaptToSDto(this City p5) - { - return p5 == null ? null : new CitySDto() + Name = p7.Name, + Universities = p7.Universities.Select(p8 => new University() { - Name = p5.Name, - Id = p5.Id - }; - } - public static CitySDto AdaptTo(this City p6, CitySDto p7) - { - if (p6 == null) - { - return null; - } - CitySDto result = p7 ?? new CitySDto(); - - result.Name = p6.Name; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new CitySDto() - { - Name = p8.Name, - Id = p8.Id + Name = p8.Name, + Address = p8.Address, + CityId = p8.CityId, + Id = p8.Id + }).ToList(), + Id = p7.Id }; - public static City AdaptToCity(this CityLDto p9) + public static CityLDto AdaptToLDto(this City p9) { - return p9 == null ? null : new City() + return p9 == null ? null : new CityLDto() { Name = p9.Name, - Universities = funcMain1(p9.Universities), + Universities = funcMain3(p9.Universities), Id = p9.Id }; } - public static City AdaptTo(this CityLDto p11, City p12) + public static CityLDto AdaptTo(this City p11, CityLDto p12) { if (p11 == null) { return null; } - City result = p12 ?? new City(); + CityLDto result = p12 ?? new CityLDto(); result.Name = p11.Name; - result.Universities = funcMain2(p11.Universities, result.Universities); + result.Universities = funcMain4(p11.Universities, result.Universities); result.Id = p11.Id; return result; } - public static Expression> ProjectLDtoToCity => p15 => new City() + public static Expression> ProjectToLDto => p15 => new CityLDto() { Name = p15.Name, - Universities = p15.Universities.Select(p16 => new University() + Universities = p15.Universities.Select(p16 => new UniversitySDto() { Name = p16.Name, Address = p16.Address, CityId = p16.CityId, Id = p16.Id - }).ToList(), + }).ToList(), Id = p15.Id }; - public static CityLDto AdaptToLDto(this City p17) + public static City AdaptToCity(this CitySDto p17) { - return p17 == null ? null : new CityLDto() + return p17 == null ? null : new City() { Name = p17.Name, - Universities = funcMain3(p17.Universities), Id = p17.Id }; } - public static CityLDto AdaptTo(this City p19, CityLDto p20) + public static City AdaptTo(this CitySDto p18, City p19) { - if (p19 == null) + if (p18 == null) { return null; } - CityLDto result = p20 ?? new CityLDto(); + City result = p19 ?? new City(); - result.Name = p19.Name; - result.Universities = funcMain4(p19.Universities, result.Universities); - result.Id = p19.Id; + result.Name = p18.Name; + result.Id = p18.Id; return result; } - public static Expression> ProjectToLDto => p23 => new CityLDto() + public static CitySDto AdaptToSDto(this City p20) + { + return p20 == null ? null : new CitySDto() + { + Name = p20.Name, + Id = p20.Id + }; + } + public static CitySDto AdaptTo(this City p21, CitySDto p22) + { + if (p21 == null) + { + return null; + } + CitySDto result = p22 ?? new CitySDto(); + + result.Name = p21.Name; + result.Id = p21.Id; + return result; + + } + public static Expression> ProjectToSDto => p23 => new CitySDto() { Name = p23.Name, - Universities = p23.Universities.Select(p24 => new UniversitySDto() - { - Name = p24.Name, - Address = p24.Address, - CityId = p24.CityId, - Id = p24.Id - }).ToList(), Id = p23.Id }; - private static List funcMain1(List p10) + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); + + int i = 0; + int len = p2.Count; + + while (i < len) + { + UniversitySDto item = p2[i]; + result.Add(item == null ? null : new University() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain2(List p5, List p6) + { + if (p5 == null) + { + return null; + } + List result = new List(p5.Count); + + int i = 0; + int len = p5.Count; + + while (i < len) + { + UniversitySDto item = p5[i]; + result.Add(item == null ? null : new University() + { + Name = item.Name, + Address = item.Address, + CityId = item.CityId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain3(List p10) { if (p10 == null) { return null; } - List result = new List(p10.Count); + List result = new List(p10.Count); int i = 0; int len = p10.Count; while (i < len) { - UniversitySDto item = p10[i]; - result.Add(item == null ? null : new University() - { - Name = item.Name, - Address = item.Address, - CityId = item.CityId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain2(List p13, List p14) - { - if (p13 == null) - { - return null; - } - List result = new List(p13.Count); - - int i = 0; - int len = p13.Count; - - while (i < len) - { - UniversitySDto item = p13[i]; - result.Add(item == null ? null : new University() - { - Name = item.Name, - Address = item.Address, - CityId = item.CityId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain3(List p18) - { - if (p18 == null) - { - return null; - } - List result = new List(p18.Count); - - int i = 0; - int len = p18.Count; - - while (i < len) - { - University item = p18[i]; + University item = p10[i]; result.Add(item == null ? null : new UniversitySDto() { Name = item.Name, @@ -214,20 +209,20 @@ namespace DocuMed.Domain.Mappers } - private static List funcMain4(List p21, List p22) + private static List funcMain4(List p13, List p14) { - if (p21 == null) + if (p13 == null) { return null; } - List result = new List(p21.Count); + List result = new List(p13.Count); int i = 0; - int len = p21.Count; + int len = p13.Count; while (i < len) { - University item = p21[i]; + University item = p13[i]; result.Add(item == null ? null : new UniversitySDto() { Name = item.Name, diff --git a/DocuMed.Domain/Mappers/HospitalMapper.g.cs b/DocuMed.Domain/Mappers/HospitalMapper.g.cs new file mode 100644 index 0000000..8605a44 --- /dev/null +++ b/DocuMed.Domain/Mappers/HospitalMapper.g.cs @@ -0,0 +1,78 @@ +using System; +using System.Linq.Expressions; +using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.Hospitals; + +namespace DocuMed.Domain.Mappers +{ + public static partial class HospitalMapper + { + public static Hospital AdaptToHospital(this HospitalSDto p1) + { + return p1 == null ? null : new Hospital() + { + Name = p1.Name, + Detail = p1.Detail, + Address = p1.Address, + Id = p1.Id + }; + } + public static Hospital AdaptTo(this HospitalSDto p2, Hospital p3) + { + if (p2 == null) + { + return null; + } + Hospital result = p3 ?? new Hospital(); + + result.Name = p2.Name; + result.Detail = p2.Detail; + result.Address = p2.Address; + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToHospital => p4 => new Hospital() + { + Name = p4.Name, + Detail = p4.Detail, + Address = p4.Address, + Id = p4.Id + }; + public static HospitalSDto AdaptToSDto(this Hospital p5) + { + return p5 == null ? null : new HospitalSDto() + { + Name = p5.Name, + Detail = p5.Detail, + Address = p5.Address, + UniversityName = p5.University == null ? null : p5.University.Name, + Id = p5.Id + }; + } + public static HospitalSDto AdaptTo(this Hospital p6, HospitalSDto p7) + { + if (p6 == null) + { + return null; + } + HospitalSDto result = p7 ?? new HospitalSDto(); + + result.Name = p6.Name; + result.Detail = p6.Detail; + result.Address = p6.Address; + result.UniversityName = p6.University == null ? null : p6.University.Name; + result.Id = p6.Id; + return result; + + } + public static Expression> ProjectToSDto => p8 => new HospitalSDto() + { + Name = p8.Name, + Detail = p8.Detail, + Address = p8.Address, + UniversityName = p8.University.Name, + Id = p8.Id + }; + } +} \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs index 79ac1af..9f23a50 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryMapper.g.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Linq.Expressions; using DocuMed.Domain.Dtos.LargDtos; using DocuMed.Domain.Dtos.SmallDtos; -using DocuMed.Domain.Entities.City; +using DocuMed.Domain.Entities.Hospitals; using DocuMed.Domain.Entities.MedicalHistory; using DocuMed.Domain.Entities.User; using Mapster.Models; @@ -13,16 +13,18 @@ namespace DocuMed.Domain.Mappers { public static partial class MedicalHistoryMapper { - public static MedicalHistory AdaptToMedicalHistory(this MedicalHistorySDto p1) + public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p1) { return p1 == null ? null : new MedicalHistory() { ChiefComplaint = p1.ChiefComplaint, SectionId = p1.SectionId, - Section = new Section() + Section = p1.Section == null ? null : new Section() { - Name = p1.SectionName, - Id = p1.SectionId + Name = p1.Section.Name, + Detail = p1.Section.Detail, + HospitalId = p1.Section.HospitalId, + Id = p1.Section.Id }, FirstName = p1.FirstName, LastName = p1.LastName, @@ -48,427 +50,398 @@ namespace DocuMed.Domain.Mappers Temperature = p1.Temperature, MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId, ApplicationUserId = p1.ApplicationUserId, - ApplicationUser = new ApplicationUser() {Id = p1.ApplicationUserId}, + Answers = funcMain1(p1.Answers), Id = p1.Id, CreatedAt = p1.CreatedAt }; } - public static MedicalHistory AdaptTo(this MedicalHistorySDto p2, MedicalHistory p3) + public static MedicalHistory AdaptTo(this MedicalHistoryLDto p3, MedicalHistory p4) { - if (p2 == null) + if (p3 == null) { return null; } - MedicalHistory result = p3 ?? new MedicalHistory(); + MedicalHistory result = p4 ?? new MedicalHistory(); - result.ChiefComplaint = p2.ChiefComplaint; - result.SectionId = p2.SectionId; - result.Section = funcMain1(new Never(), result.Section, p2); - result.FirstName = p2.FirstName; - result.LastName = p2.LastName; - result.FatherName = p2.FatherName; - result.NationalId = p2.NationalId; - result.Age = p2.Age; - result.BirthDate = p2.BirthDate; - result.PresentIllnessDetail = p2.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p2.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p2.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p2.FamilyHistoryDetail; - result.AllergyDetail = p2.AllergyDetail; - result.DrugHistoryDetail = p2.DrugHistoryDetail; - result.AddictionHistoryDetail = p2.AddictionHistoryDetail; - result.SystemReviewDetail = p2.SystemReviewDetail; - result.VitalSignDetail = p2.VitalSignDetail; - result.GeneralAppearanceDetail = p2.GeneralAppearanceDetail; - result.Code = p2.Code; - result.SystolicBloodPressure = p2.SystolicBloodPressure; - result.DiastolicBloodPressure = p2.DiastolicBloodPressure; - result.PulseRate = p2.PulseRate; - result.SPO2 = p2.SPO2; - result.Temperature = p2.Temperature; - result.MedicalHistoryTemplateId = p2.MedicalHistoryTemplateId; - result.ApplicationUserId = p2.ApplicationUserId; - result.ApplicationUser = funcMain2(new Never(), result.ApplicationUser, p2); - result.Id = p2.Id; - result.CreatedAt = p2.CreatedAt; + result.ChiefComplaint = p3.ChiefComplaint; + result.SectionId = p3.SectionId; + result.Section = funcMain2(p3.Section, result.Section); + result.FirstName = p3.FirstName; + result.LastName = p3.LastName; + result.FatherName = p3.FatherName; + result.NationalId = p3.NationalId; + result.Age = p3.Age; + result.BirthDate = p3.BirthDate; + result.PresentIllnessDetail = p3.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p3.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p3.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p3.FamilyHistoryDetail; + result.AllergyDetail = p3.AllergyDetail; + result.DrugHistoryDetail = p3.DrugHistoryDetail; + result.AddictionHistoryDetail = p3.AddictionHistoryDetail; + result.SystemReviewDetail = p3.SystemReviewDetail; + result.VitalSignDetail = p3.VitalSignDetail; + result.GeneralAppearanceDetail = p3.GeneralAppearanceDetail; + result.Code = p3.Code; + result.SystolicBloodPressure = p3.SystolicBloodPressure; + result.DiastolicBloodPressure = p3.DiastolicBloodPressure; + result.PulseRate = p3.PulseRate; + result.SPO2 = p3.SPO2; + result.Temperature = p3.Temperature; + result.MedicalHistoryTemplateId = p3.MedicalHistoryTemplateId; + result.ApplicationUserId = p3.ApplicationUserId; + result.Answers = funcMain3(p3.Answers, result.Answers); + result.Id = p3.Id; + result.CreatedAt = p3.CreatedAt; return result; } - public static Expression> ProjectToMedicalHistory => p8 => new MedicalHistory() + public static Expression> ProjectToMedicalHistory => p9 => new MedicalHistory() { - ChiefComplaint = p8.ChiefComplaint, - SectionId = p8.SectionId, - Section = new Section() + ChiefComplaint = p9.ChiefComplaint, + SectionId = p9.SectionId, + Section = p9.Section == null ? null : new Section() { - Name = p8.SectionName, - Id = p8.SectionId + Name = p9.Section.Name, + Detail = p9.Section.Detail, + HospitalId = p9.Section.HospitalId, + Id = p9.Section.Id }, - FirstName = p8.FirstName, - LastName = p8.LastName, - FatherName = p8.FatherName, - NationalId = p8.NationalId, - Age = p8.Age, - BirthDate = p8.BirthDate, - PresentIllnessDetail = p8.PresentIllnessDetail, - PastDiseasesHistoryDetail = p8.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p8.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p8.FamilyHistoryDetail, - AllergyDetail = p8.AllergyDetail, - DrugHistoryDetail = p8.DrugHistoryDetail, - AddictionHistoryDetail = p8.AddictionHistoryDetail, - SystemReviewDetail = p8.SystemReviewDetail, - VitalSignDetail = p8.VitalSignDetail, - GeneralAppearanceDetail = p8.GeneralAppearanceDetail, - Code = p8.Code, - SystolicBloodPressure = p8.SystolicBloodPressure, - DiastolicBloodPressure = p8.DiastolicBloodPressure, - PulseRate = p8.PulseRate, - SPO2 = p8.SPO2, - Temperature = p8.Temperature, - MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId, - ApplicationUserId = p8.ApplicationUserId, - ApplicationUser = new ApplicationUser() {Id = p8.ApplicationUserId}, - Id = p8.Id, - CreatedAt = p8.CreatedAt - }; - public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p9) - { - return p9 == null ? null : new MedicalHistorySDto() + FirstName = p9.FirstName, + LastName = p9.LastName, + FatherName = p9.FatherName, + NationalId = p9.NationalId, + Age = p9.Age, + BirthDate = p9.BirthDate, + PresentIllnessDetail = p9.PresentIllnessDetail, + PastDiseasesHistoryDetail = p9.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p9.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p9.FamilyHistoryDetail, + AllergyDetail = p9.AllergyDetail, + DrugHistoryDetail = p9.DrugHistoryDetail, + AddictionHistoryDetail = p9.AddictionHistoryDetail, + SystemReviewDetail = p9.SystemReviewDetail, + VitalSignDetail = p9.VitalSignDetail, + GeneralAppearanceDetail = p9.GeneralAppearanceDetail, + Code = p9.Code, + SystolicBloodPressure = p9.SystolicBloodPressure, + DiastolicBloodPressure = p9.DiastolicBloodPressure, + PulseRate = p9.PulseRate, + SPO2 = p9.SPO2, + Temperature = p9.Temperature, + MedicalHistoryTemplateId = p9.MedicalHistoryTemplateId, + ApplicationUserId = p9.ApplicationUserId, + Answers = p9.Answers.Select(p10 => new MedicalHistoryAnswer() { - ChiefComplaint = p9.ChiefComplaint, - SectionId = p9.SectionId, - SectionName = p9.Section != null ? p9.Section.Name : string.Empty, - FirstName = p9.FirstName, - LastName = p9.LastName, - FatherName = p9.FatherName, - NationalId = p9.NationalId, - MedicalHistoryTemplateId = p9.MedicalHistoryTemplateId, - Age = p9.Age, - BirthDate = p9.BirthDate, - Code = p9.Code, - PresentIllnessDetail = p9.PresentIllnessDetail, - PastDiseasesHistoryDetail = p9.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p9.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p9.FamilyHistoryDetail, - AllergyDetail = p9.AllergyDetail, - DrugHistoryDetail = p9.DrugHistoryDetail, - AddictionHistoryDetail = p9.AddictionHistoryDetail, - SystemReviewDetail = p9.SystemReviewDetail, - VitalSignDetail = p9.VitalSignDetail, - GeneralAppearanceDetail = p9.GeneralAppearanceDetail, - SystolicBloodPressure = p9.SystolicBloodPressure, - DiastolicBloodPressure = p9.DiastolicBloodPressure, - PulseRate = p9.PulseRate, - SPO2 = p9.SPO2, - Temperature = p9.Temperature, - ApplicationUserId = p9.ApplicationUserId, - CreatedAt = p9.CreatedAt, - Id = p9.Id - }; - } - public static MedicalHistorySDto AdaptTo(this MedicalHistory p10, MedicalHistorySDto p11) - { - if (p10 == null) - { - return null; - } - MedicalHistorySDto result = p11 ?? new MedicalHistorySDto(); - - result.ChiefComplaint = p10.ChiefComplaint; - result.SectionId = p10.SectionId; - result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty; - result.FirstName = p10.FirstName; - result.LastName = p10.LastName; - result.FatherName = p10.FatherName; - result.NationalId = p10.NationalId; - result.MedicalHistoryTemplateId = p10.MedicalHistoryTemplateId; - result.Age = p10.Age; - result.BirthDate = p10.BirthDate; - result.Code = p10.Code; - result.PresentIllnessDetail = p10.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p10.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p10.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p10.FamilyHistoryDetail; - result.AllergyDetail = p10.AllergyDetail; - result.DrugHistoryDetail = p10.DrugHistoryDetail; - result.AddictionHistoryDetail = p10.AddictionHistoryDetail; - result.SystemReviewDetail = p10.SystemReviewDetail; - result.VitalSignDetail = p10.VitalSignDetail; - result.GeneralAppearanceDetail = p10.GeneralAppearanceDetail; - result.SystolicBloodPressure = p10.SystolicBloodPressure; - result.DiastolicBloodPressure = p10.DiastolicBloodPressure; - result.PulseRate = p10.PulseRate; - result.SPO2 = p10.SPO2; - result.Temperature = p10.Temperature; - result.ApplicationUserId = p10.ApplicationUserId; - result.CreatedAt = p10.CreatedAt; - result.Id = p10.Id; - return result; - - } - public static Expression> ProjectToSDto => p12 => new MedicalHistorySDto() - { - ChiefComplaint = p12.ChiefComplaint, - SectionId = p12.SectionId, - SectionName = p12.Section != null ? p12.Section.Name : string.Empty, - FirstName = p12.FirstName, - LastName = p12.LastName, - FatherName = p12.FatherName, - NationalId = p12.NationalId, - MedicalHistoryTemplateId = p12.MedicalHistoryTemplateId, - Age = p12.Age, - BirthDate = p12.BirthDate, - Code = p12.Code, - PresentIllnessDetail = p12.PresentIllnessDetail, - PastDiseasesHistoryDetail = p12.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p12.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p12.FamilyHistoryDetail, - AllergyDetail = p12.AllergyDetail, - DrugHistoryDetail = p12.DrugHistoryDetail, - AddictionHistoryDetail = p12.AddictionHistoryDetail, - SystemReviewDetail = p12.SystemReviewDetail, - VitalSignDetail = p12.VitalSignDetail, - GeneralAppearanceDetail = p12.GeneralAppearanceDetail, - SystolicBloodPressure = p12.SystolicBloodPressure, - DiastolicBloodPressure = p12.DiastolicBloodPressure, - PulseRate = p12.PulseRate, - SPO2 = p12.SPO2, - Temperature = p12.Temperature, - ApplicationUserId = p12.ApplicationUserId, - CreatedAt = p12.CreatedAt, - Id = p12.Id - }; - public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p13) - { - return p13 == null ? null : new MedicalHistory() - { - ChiefComplaint = p13.ChiefComplaint, - SectionId = p13.SectionId, - Section = p13.Section == null ? null : new Section() - { - Name = p13.Section.Name, - Detail = p13.Section.Detail, - UniversityId = p13.Section.UniversityId, - Id = p13.Section.Id - }, - FirstName = p13.FirstName, - LastName = p13.LastName, - FatherName = p13.FatherName, - NationalId = p13.NationalId, - Age = p13.Age, - BirthDate = p13.BirthDate, - PresentIllnessDetail = p13.PresentIllnessDetail, - PastDiseasesHistoryDetail = p13.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p13.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p13.FamilyHistoryDetail, - AllergyDetail = p13.AllergyDetail, - DrugHistoryDetail = p13.DrugHistoryDetail, - AddictionHistoryDetail = p13.AddictionHistoryDetail, - SystemReviewDetail = p13.SystemReviewDetail, - VitalSignDetail = p13.VitalSignDetail, - GeneralAppearanceDetail = p13.GeneralAppearanceDetail, - Code = p13.Code, - SystolicBloodPressure = p13.SystolicBloodPressure, - DiastolicBloodPressure = p13.DiastolicBloodPressure, - PulseRate = p13.PulseRate, - SPO2 = p13.SPO2, - Temperature = p13.Temperature, - MedicalHistoryTemplateId = p13.MedicalHistoryTemplateId, - ApplicationUserId = p13.ApplicationUserId, - Answers = funcMain3(p13.Answers), - Id = p13.Id, - CreatedAt = p13.CreatedAt - }; - } - public static MedicalHistory AdaptTo(this MedicalHistoryLDto p15, MedicalHistory p16) - { - if (p15 == null) - { - return null; - } - MedicalHistory result = p16 ?? new MedicalHistory(); - - result.ChiefComplaint = p15.ChiefComplaint; - result.SectionId = p15.SectionId; - result.Section = funcMain4(p15.Section, result.Section); - result.FirstName = p15.FirstName; - result.LastName = p15.LastName; - result.FatherName = p15.FatherName; - result.NationalId = p15.NationalId; - result.Age = p15.Age; - result.BirthDate = p15.BirthDate; - result.PresentIllnessDetail = p15.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p15.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p15.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p15.FamilyHistoryDetail; - result.AllergyDetail = p15.AllergyDetail; - result.DrugHistoryDetail = p15.DrugHistoryDetail; - result.AddictionHistoryDetail = p15.AddictionHistoryDetail; - result.SystemReviewDetail = p15.SystemReviewDetail; - result.VitalSignDetail = p15.VitalSignDetail; - result.GeneralAppearanceDetail = p15.GeneralAppearanceDetail; - result.Code = p15.Code; - result.SystolicBloodPressure = p15.SystolicBloodPressure; - result.DiastolicBloodPressure = p15.DiastolicBloodPressure; - result.PulseRate = p15.PulseRate; - result.SPO2 = p15.SPO2; - result.Temperature = p15.Temperature; - result.MedicalHistoryTemplateId = p15.MedicalHistoryTemplateId; - result.ApplicationUserId = p15.ApplicationUserId; - result.Answers = funcMain5(p15.Answers, result.Answers); - result.Id = p15.Id; - result.CreatedAt = p15.CreatedAt; - return result; - - } - public static Expression> ProjectLDtoToMedicalHistory => p21 => new MedicalHistory() - { - ChiefComplaint = p21.ChiefComplaint, - SectionId = p21.SectionId, - Section = p21.Section == null ? null : new Section() - { - Name = p21.Section.Name, - Detail = p21.Section.Detail, - UniversityId = p21.Section.UniversityId, - Id = p21.Section.Id - }, - FirstName = p21.FirstName, - LastName = p21.LastName, - FatherName = p21.FatherName, - NationalId = p21.NationalId, - Age = p21.Age, - BirthDate = p21.BirthDate, - PresentIllnessDetail = p21.PresentIllnessDetail, - PastDiseasesHistoryDetail = p21.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p21.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p21.FamilyHistoryDetail, - AllergyDetail = p21.AllergyDetail, - DrugHistoryDetail = p21.DrugHistoryDetail, - AddictionHistoryDetail = p21.AddictionHistoryDetail, - SystemReviewDetail = p21.SystemReviewDetail, - VitalSignDetail = p21.VitalSignDetail, - GeneralAppearanceDetail = p21.GeneralAppearanceDetail, - Code = p21.Code, - SystolicBloodPressure = p21.SystolicBloodPressure, - DiastolicBloodPressure = p21.DiastolicBloodPressure, - PulseRate = p21.PulseRate, - SPO2 = p21.SPO2, - Temperature = p21.Temperature, - MedicalHistoryTemplateId = p21.MedicalHistoryTemplateId, - ApplicationUserId = p21.ApplicationUserId, - Answers = p21.Answers.Select(p22 => new MedicalHistoryAnswer() - { - Answer = p22.Answer, - Question = p22.Question, - Part = p22.Part, - QuestionType = p22.QuestionType, - MedicalHistoryId = p22.MedicalHistoryId, - Id = p22.Id + Answer = p10.Answer, + Question = p10.Question, + Part = p10.Part, + QuestionType = p10.QuestionType, + MedicalHistoryId = p10.MedicalHistoryId, + Id = p10.Id }).ToList(), - Id = p21.Id, - CreatedAt = p21.CreatedAt + Id = p9.Id, + CreatedAt = p9.CreatedAt }; - public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p23) + public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p11) { - return p23 == null ? null : new MedicalHistoryLDto() + return p11 == null ? null : new MedicalHistoryLDto() { - ChiefComplaint = p23.ChiefComplaint, - SectionId = p23.SectionId, - FirstName = p23.FirstName, - LastName = p23.LastName, - FatherName = p23.FatherName, - NationalId = p23.NationalId, - Age = p23.Age, - BirthDate = p23.BirthDate, - Code = p23.Code, - Section = p23.Section == null ? null : new SectionSDto() + ChiefComplaint = p11.ChiefComplaint, + SectionId = p11.SectionId, + FirstName = p11.FirstName, + LastName = p11.LastName, + FatherName = p11.FatherName, + NationalId = p11.NationalId, + Age = p11.Age, + BirthDate = p11.BirthDate, + Code = p11.Code, + Section = p11.Section == null ? null : new SectionSDto() { - Name = p23.Section.Name, - Detail = p23.Section.Detail, - UniversityId = p23.Section.UniversityId, - Id = p23.Section.Id + Name = p11.Section.Name, + Detail = p11.Section.Detail, + HospitalId = p11.Section.HospitalId, + Id = p11.Section.Id }, - PresentIllnessDetail = p23.PresentIllnessDetail, - PastDiseasesHistoryDetail = p23.PastDiseasesHistoryDetail, - PastSurgeryHistoryDetail = p23.PastSurgeryHistoryDetail, - FamilyHistoryDetail = p23.FamilyHistoryDetail, - AllergyDetail = p23.AllergyDetail, - DrugHistoryDetail = p23.DrugHistoryDetail, - AddictionHistoryDetail = p23.AddictionHistoryDetail, - SystemReviewDetail = p23.SystemReviewDetail, - VitalSignDetail = p23.VitalSignDetail, - GeneralAppearanceDetail = p23.GeneralAppearanceDetail, - MedicalHistoryTemplateId = p23.MedicalHistoryTemplateId, - SystolicBloodPressure = p23.SystolicBloodPressure, - DiastolicBloodPressure = p23.DiastolicBloodPressure, - PulseRate = p23.PulseRate, - SPO2 = p23.SPO2, - Temperature = p23.Temperature, - ApplicationUserId = p23.ApplicationUserId, - CreatedAt = p23.CreatedAt, - Answers = funcMain6(p23.Answers), - Id = p23.Id + PresentIllnessDetail = p11.PresentIllnessDetail, + PastDiseasesHistoryDetail = p11.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p11.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p11.FamilyHistoryDetail, + AllergyDetail = p11.AllergyDetail, + DrugHistoryDetail = p11.DrugHistoryDetail, + AddictionHistoryDetail = p11.AddictionHistoryDetail, + SystemReviewDetail = p11.SystemReviewDetail, + VitalSignDetail = p11.VitalSignDetail, + GeneralAppearanceDetail = p11.GeneralAppearanceDetail, + MedicalHistoryTemplateId = p11.MedicalHistoryTemplateId, + SystolicBloodPressure = p11.SystolicBloodPressure, + DiastolicBloodPressure = p11.DiastolicBloodPressure, + PulseRate = p11.PulseRate, + SPO2 = p11.SPO2, + Temperature = p11.Temperature, + ApplicationUserId = p11.ApplicationUserId, + CreatedAt = p11.CreatedAt, + Answers = funcMain4(p11.Answers), + Id = p11.Id }; } - public static MedicalHistoryLDto AdaptTo(this MedicalHistory p25, MedicalHistoryLDto p26) + public static MedicalHistoryLDto AdaptTo(this MedicalHistory p13, MedicalHistoryLDto p14) { - if (p25 == null) + if (p13 == null) { return null; } - MedicalHistoryLDto result = p26 ?? new MedicalHistoryLDto(); + MedicalHistoryLDto result = p14 ?? new MedicalHistoryLDto(); - result.ChiefComplaint = p25.ChiefComplaint; - result.SectionId = p25.SectionId; - result.FirstName = p25.FirstName; - result.LastName = p25.LastName; - result.FatherName = p25.FatherName; - result.NationalId = p25.NationalId; - result.Age = p25.Age; - result.BirthDate = p25.BirthDate; - result.Code = p25.Code; - result.Section = funcMain7(p25.Section, result.Section); - result.PresentIllnessDetail = p25.PresentIllnessDetail; - result.PastDiseasesHistoryDetail = p25.PastDiseasesHistoryDetail; - result.PastSurgeryHistoryDetail = p25.PastSurgeryHistoryDetail; - result.FamilyHistoryDetail = p25.FamilyHistoryDetail; - result.AllergyDetail = p25.AllergyDetail; - result.DrugHistoryDetail = p25.DrugHistoryDetail; - result.AddictionHistoryDetail = p25.AddictionHistoryDetail; - result.SystemReviewDetail = p25.SystemReviewDetail; - result.VitalSignDetail = p25.VitalSignDetail; - result.GeneralAppearanceDetail = p25.GeneralAppearanceDetail; - result.MedicalHistoryTemplateId = p25.MedicalHistoryTemplateId; - result.SystolicBloodPressure = p25.SystolicBloodPressure; - result.DiastolicBloodPressure = p25.DiastolicBloodPressure; - result.PulseRate = p25.PulseRate; - result.SPO2 = p25.SPO2; - result.Temperature = p25.Temperature; - result.ApplicationUserId = p25.ApplicationUserId; - result.CreatedAt = p25.CreatedAt; - result.Answers = funcMain8(p25.Answers, result.Answers); - result.Id = p25.Id; + result.ChiefComplaint = p13.ChiefComplaint; + result.SectionId = p13.SectionId; + result.FirstName = p13.FirstName; + result.LastName = p13.LastName; + result.FatherName = p13.FatherName; + result.NationalId = p13.NationalId; + result.Age = p13.Age; + result.BirthDate = p13.BirthDate; + result.Code = p13.Code; + result.Section = funcMain5(p13.Section, result.Section); + result.PresentIllnessDetail = p13.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p13.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p13.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p13.FamilyHistoryDetail; + result.AllergyDetail = p13.AllergyDetail; + result.DrugHistoryDetail = p13.DrugHistoryDetail; + result.AddictionHistoryDetail = p13.AddictionHistoryDetail; + result.SystemReviewDetail = p13.SystemReviewDetail; + result.VitalSignDetail = p13.VitalSignDetail; + result.GeneralAppearanceDetail = p13.GeneralAppearanceDetail; + result.MedicalHistoryTemplateId = p13.MedicalHistoryTemplateId; + result.SystolicBloodPressure = p13.SystolicBloodPressure; + result.DiastolicBloodPressure = p13.DiastolicBloodPressure; + result.PulseRate = p13.PulseRate; + result.SPO2 = p13.SPO2; + result.Temperature = p13.Temperature; + result.ApplicationUserId = p13.ApplicationUserId; + result.CreatedAt = p13.CreatedAt; + result.Answers = funcMain6(p13.Answers, result.Answers); + result.Id = p13.Id; return result; } - public static Expression> ProjectToLDto => p31 => new MedicalHistoryLDto() + public static Expression> ProjectToLDto => p19 => new MedicalHistoryLDto() + { + ChiefComplaint = p19.ChiefComplaint, + SectionId = p19.SectionId, + FirstName = p19.FirstName, + LastName = p19.LastName, + FatherName = p19.FatherName, + NationalId = p19.NationalId, + Age = p19.Age, + BirthDate = p19.BirthDate, + Code = p19.Code, + Section = p19.Section == null ? null : new SectionSDto() + { + Name = p19.Section.Name, + Detail = p19.Section.Detail, + HospitalId = p19.Section.HospitalId, + Id = p19.Section.Id + }, + PresentIllnessDetail = p19.PresentIllnessDetail, + PastDiseasesHistoryDetail = p19.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p19.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p19.FamilyHistoryDetail, + AllergyDetail = p19.AllergyDetail, + DrugHistoryDetail = p19.DrugHistoryDetail, + AddictionHistoryDetail = p19.AddictionHistoryDetail, + SystemReviewDetail = p19.SystemReviewDetail, + VitalSignDetail = p19.VitalSignDetail, + GeneralAppearanceDetail = p19.GeneralAppearanceDetail, + MedicalHistoryTemplateId = p19.MedicalHistoryTemplateId, + SystolicBloodPressure = p19.SystolicBloodPressure, + DiastolicBloodPressure = p19.DiastolicBloodPressure, + PulseRate = p19.PulseRate, + SPO2 = p19.SPO2, + Temperature = p19.Temperature, + ApplicationUserId = p19.ApplicationUserId, + CreatedAt = p19.CreatedAt, + Answers = p19.Answers.Select(p20 => new MedicalHistoryAnswerSDto() + { + Answer = p20.Answer, + Question = p20.Question, + Part = p20.Part, + QuestionType = p20.QuestionType, + MedicalHistoryId = p20.MedicalHistoryId, + Id = p20.Id + }).ToList(), + Id = p19.Id + }; + public static MedicalHistory AdaptToMedicalHistory(this MedicalHistorySDto p21) + { + return p21 == null ? null : new MedicalHistory() + { + ChiefComplaint = p21.ChiefComplaint, + SectionId = p21.SectionId, + Section = new Section() + { + Name = p21.SectionName, + Id = p21.SectionId + }, + FirstName = p21.FirstName, + LastName = p21.LastName, + FatherName = p21.FatherName, + NationalId = p21.NationalId, + Age = p21.Age, + BirthDate = p21.BirthDate, + PresentIllnessDetail = p21.PresentIllnessDetail, + PastDiseasesHistoryDetail = p21.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p21.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p21.FamilyHistoryDetail, + AllergyDetail = p21.AllergyDetail, + DrugHistoryDetail = p21.DrugHistoryDetail, + AddictionHistoryDetail = p21.AddictionHistoryDetail, + SystemReviewDetail = p21.SystemReviewDetail, + VitalSignDetail = p21.VitalSignDetail, + GeneralAppearanceDetail = p21.GeneralAppearanceDetail, + Code = p21.Code, + SystolicBloodPressure = p21.SystolicBloodPressure, + DiastolicBloodPressure = p21.DiastolicBloodPressure, + PulseRate = p21.PulseRate, + SPO2 = p21.SPO2, + Temperature = p21.Temperature, + MedicalHistoryTemplateId = p21.MedicalHistoryTemplateId, + ApplicationUserId = p21.ApplicationUserId, + ApplicationUser = new ApplicationUser() {Id = p21.ApplicationUserId}, + Id = p21.Id, + CreatedAt = p21.CreatedAt + }; + } + public static MedicalHistory AdaptTo(this MedicalHistorySDto p22, MedicalHistory p23) + { + if (p22 == null) + { + return null; + } + MedicalHistory result = p23 ?? new MedicalHistory(); + + result.ChiefComplaint = p22.ChiefComplaint; + result.SectionId = p22.SectionId; + result.Section = funcMain7(new Never(), result.Section, p22); + result.FirstName = p22.FirstName; + result.LastName = p22.LastName; + result.FatherName = p22.FatherName; + result.NationalId = p22.NationalId; + result.Age = p22.Age; + result.BirthDate = p22.BirthDate; + result.PresentIllnessDetail = p22.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p22.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p22.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p22.FamilyHistoryDetail; + result.AllergyDetail = p22.AllergyDetail; + result.DrugHistoryDetail = p22.DrugHistoryDetail; + result.AddictionHistoryDetail = p22.AddictionHistoryDetail; + result.SystemReviewDetail = p22.SystemReviewDetail; + result.VitalSignDetail = p22.VitalSignDetail; + result.GeneralAppearanceDetail = p22.GeneralAppearanceDetail; + result.Code = p22.Code; + result.SystolicBloodPressure = p22.SystolicBloodPressure; + result.DiastolicBloodPressure = p22.DiastolicBloodPressure; + result.PulseRate = p22.PulseRate; + result.SPO2 = p22.SPO2; + result.Temperature = p22.Temperature; + result.MedicalHistoryTemplateId = p22.MedicalHistoryTemplateId; + result.ApplicationUserId = p22.ApplicationUserId; + result.ApplicationUser = funcMain8(new Never(), result.ApplicationUser, p22); + result.Id = p22.Id; + result.CreatedAt = p22.CreatedAt; + return result; + + } + public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p28) + { + return p28 == null ? null : new MedicalHistorySDto() + { + ChiefComplaint = p28.ChiefComplaint, + SectionId = p28.SectionId, + SectionName = p28.Section != null ? p28.Section.Name : string.Empty, + FirstName = p28.FirstName, + LastName = p28.LastName, + FatherName = p28.FatherName, + NationalId = p28.NationalId, + MedicalHistoryTemplateId = p28.MedicalHistoryTemplateId, + Age = p28.Age, + BirthDate = p28.BirthDate, + Code = p28.Code, + PresentIllnessDetail = p28.PresentIllnessDetail, + PastDiseasesHistoryDetail = p28.PastDiseasesHistoryDetail, + PastSurgeryHistoryDetail = p28.PastSurgeryHistoryDetail, + FamilyHistoryDetail = p28.FamilyHistoryDetail, + AllergyDetail = p28.AllergyDetail, + DrugHistoryDetail = p28.DrugHistoryDetail, + AddictionHistoryDetail = p28.AddictionHistoryDetail, + SystemReviewDetail = p28.SystemReviewDetail, + VitalSignDetail = p28.VitalSignDetail, + GeneralAppearanceDetail = p28.GeneralAppearanceDetail, + SystolicBloodPressure = p28.SystolicBloodPressure, + DiastolicBloodPressure = p28.DiastolicBloodPressure, + PulseRate = p28.PulseRate, + SPO2 = p28.SPO2, + Temperature = p28.Temperature, + ApplicationUserId = p28.ApplicationUserId, + CreatedAt = p28.CreatedAt, + Id = p28.Id + }; + } + public static MedicalHistorySDto AdaptTo(this MedicalHistory p29, MedicalHistorySDto p30) + { + if (p29 == null) + { + return null; + } + MedicalHistorySDto result = p30 ?? new MedicalHistorySDto(); + + result.ChiefComplaint = p29.ChiefComplaint; + result.SectionId = p29.SectionId; + result.SectionName = p29.Section != null ? p29.Section.Name : string.Empty; + result.FirstName = p29.FirstName; + result.LastName = p29.LastName; + result.FatherName = p29.FatherName; + result.NationalId = p29.NationalId; + result.MedicalHistoryTemplateId = p29.MedicalHistoryTemplateId; + result.Age = p29.Age; + result.BirthDate = p29.BirthDate; + result.Code = p29.Code; + result.PresentIllnessDetail = p29.PresentIllnessDetail; + result.PastDiseasesHistoryDetail = p29.PastDiseasesHistoryDetail; + result.PastSurgeryHistoryDetail = p29.PastSurgeryHistoryDetail; + result.FamilyHistoryDetail = p29.FamilyHistoryDetail; + result.AllergyDetail = p29.AllergyDetail; + result.DrugHistoryDetail = p29.DrugHistoryDetail; + result.AddictionHistoryDetail = p29.AddictionHistoryDetail; + result.SystemReviewDetail = p29.SystemReviewDetail; + result.VitalSignDetail = p29.VitalSignDetail; + result.GeneralAppearanceDetail = p29.GeneralAppearanceDetail; + result.SystolicBloodPressure = p29.SystolicBloodPressure; + result.DiastolicBloodPressure = p29.DiastolicBloodPressure; + result.PulseRate = p29.PulseRate; + result.SPO2 = p29.SPO2; + result.Temperature = p29.Temperature; + result.ApplicationUserId = p29.ApplicationUserId; + result.CreatedAt = p29.CreatedAt; + result.Id = p29.Id; + return result; + + } + public static Expression> ProjectToSDto => p31 => new MedicalHistorySDto() { ChiefComplaint = p31.ChiefComplaint, SectionId = p31.SectionId, + SectionName = p31.Section != null ? p31.Section.Name : string.Empty, FirstName = p31.FirstName, LastName = p31.LastName, FatherName = p31.FatherName, NationalId = p31.NationalId, + MedicalHistoryTemplateId = p31.MedicalHistoryTemplateId, Age = p31.Age, BirthDate = p31.BirthDate, Code = p31.Code, - Section = p31.Section == null ? null : new SectionSDto() - { - Name = p31.Section.Name, - Detail = p31.Section.Detail, - UniversityId = p31.Section.UniversityId, - Id = p31.Section.Id - }, PresentIllnessDetail = p31.PresentIllnessDetail, PastDiseasesHistoryDetail = p31.PastDiseasesHistoryDetail, PastSurgeryHistoryDetail = p31.PastSurgeryHistoryDetail, @@ -479,7 +452,6 @@ namespace DocuMed.Domain.Mappers SystemReviewDetail = p31.SystemReviewDetail, VitalSignDetail = p31.VitalSignDetail, GeneralAppearanceDetail = p31.GeneralAppearanceDetail, - MedicalHistoryTemplateId = p31.MedicalHistoryTemplateId, SystolicBloodPressure = p31.SystolicBloodPressure, DiastolicBloodPressure = p31.DiastolicBloodPressure, PulseRate = p31.PulseRate, @@ -487,51 +459,23 @@ namespace DocuMed.Domain.Mappers Temperature = p31.Temperature, ApplicationUserId = p31.ApplicationUserId, CreatedAt = p31.CreatedAt, - Answers = p31.Answers.Select(p32 => new MedicalHistoryAnswerSDto() - { - Answer = p32.Answer, - Question = p32.Question, - Part = p32.Part, - QuestionType = p32.QuestionType, - MedicalHistoryId = p32.MedicalHistoryId, - Id = p32.Id - }).ToList(), Id = p31.Id }; - private static Section funcMain1(Never p4, Section p5, MedicalHistorySDto p2) + private static List funcMain1(List p2) { - Section result = p5 ?? new Section(); - - result.Name = p2.SectionName; - result.Id = p2.SectionId; - return result; - - } - - private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, MedicalHistorySDto p2) - { - ApplicationUser result = p7 ?? new ApplicationUser(); - - result.Id = p2.ApplicationUserId; - return result; - - } - - private static List funcMain3(List p14) - { - if (p14 == null) + if (p2 == null) { return null; } - List result = new List(p14.Count); + List result = new List(p2.Count); int i = 0; - int len = p14.Count; + int len = p2.Count; while (i < len) { - MedicalHistoryAnswerSDto item = p14[i]; + MedicalHistoryAnswerSDto item = p2[i]; result.Add(item == null ? null : new MedicalHistoryAnswer() { Answer = item.Answer, @@ -547,65 +491,110 @@ namespace DocuMed.Domain.Mappers } - private static Section funcMain4(SectionSDto p17, Section p18) + private static Section funcMain2(SectionSDto p5, Section p6) + { + if (p5 == null) + { + return null; + } + Section result = p6 ?? new Section(); + + result.Name = p5.Name; + result.Detail = p5.Detail; + result.HospitalId = p5.HospitalId; + result.Id = p5.Id; + return result; + + } + + private static List funcMain3(List p7, List p8) + { + if (p7 == null) + { + return null; + } + List result = new List(p7.Count); + + int i = 0; + int len = p7.Count; + + while (i < len) + { + MedicalHistoryAnswerSDto item = p7[i]; + result.Add(item == null ? null : new MedicalHistoryAnswer() + { + Answer = item.Answer, + Question = item.Question, + Part = item.Part, + QuestionType = item.QuestionType, + MedicalHistoryId = item.MedicalHistoryId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p12) + { + if (p12 == null) + { + return null; + } + List result = new List(p12.Count); + + int i = 0; + int len = p12.Count; + + while (i < len) + { + MedicalHistoryAnswer item = p12[i]; + result.Add(item == null ? null : new MedicalHistoryAnswerSDto() + { + Answer = item.Answer, + Question = item.Question, + Part = item.Part, + QuestionType = item.QuestionType, + MedicalHistoryId = item.MedicalHistoryId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static SectionSDto funcMain5(Section p15, SectionSDto p16) + { + if (p15 == null) + { + return null; + } + SectionSDto result = p16 ?? new SectionSDto(); + + result.Name = p15.Name; + result.Detail = p15.Detail; + result.HospitalId = p15.HospitalId; + result.Id = p15.Id; + return result; + + } + + private static List funcMain6(List p17, List p18) { if (p17 == null) { return null; } - Section result = p18 ?? new Section(); - - result.Name = p17.Name; - result.Detail = p17.Detail; - result.UniversityId = p17.UniversityId; - result.Id = p17.Id; - return result; - - } - - private static List funcMain5(List p19, List p20) - { - if (p19 == null) - { - return null; - } - List result = new List(p19.Count); + List result = new List(p17.Count); int i = 0; - int len = p19.Count; + int len = p17.Count; while (i < len) { - MedicalHistoryAnswerSDto item = p19[i]; - result.Add(item == null ? null : new MedicalHistoryAnswer() - { - Answer = item.Answer, - Question = item.Question, - Part = item.Part, - QuestionType = item.QuestionType, - MedicalHistoryId = item.MedicalHistoryId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static List funcMain6(List p24) - { - if (p24 == null) - { - return null; - } - List result = new List(p24.Count); - - int i = 0; - int len = p24.Count; - - while (i < len) - { - MedicalHistoryAnswer item = p24[i]; + MedicalHistoryAnswer item = p17[i]; result.Add(item == null ? null : new MedicalHistoryAnswerSDto() { Answer = item.Answer, @@ -621,47 +610,21 @@ namespace DocuMed.Domain.Mappers } - private static SectionSDto funcMain7(Section p27, SectionSDto p28) + private static Section funcMain7(Never p24, Section p25, MedicalHistorySDto p22) { - if (p27 == null) - { - return null; - } - SectionSDto result = p28 ?? new SectionSDto(); + Section result = p25 ?? new Section(); - result.Name = p27.Name; - result.Detail = p27.Detail; - result.UniversityId = p27.UniversityId; - result.Id = p27.Id; + result.Name = p22.SectionName; + result.Id = p22.SectionId; return result; } - private static List funcMain8(List p29, List p30) + private static ApplicationUser funcMain8(Never p26, ApplicationUser p27, MedicalHistorySDto p22) { - if (p29 == null) - { - return null; - } - List result = new List(p29.Count); + ApplicationUser result = p27 ?? new ApplicationUser(); - int i = 0; - int len = p29.Count; - - while (i < len) - { - MedicalHistoryAnswer item = p29[i]; - result.Add(item == null ? null : new MedicalHistoryAnswerSDto() - { - Answer = item.Answer, - Question = item.Question, - Part = item.Part, - QuestionType = item.QuestionType, - MedicalHistoryId = item.MedicalHistoryId, - Id = item.Id - }); - i++; - } + result.Id = p22.ApplicationUserId; return result; } diff --git a/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs index d9fe570..5aa8583 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryQuestionMapper.g.cs @@ -40,60 +40,49 @@ namespace DocuMed.Domain.Mappers return result; } - public static Expression> ProjectToMedicalHistoryQuestion => p4 => new MedicalHistoryQuestion() + public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p4) { - Question = p4.Question, - Part = p4.Part, - QuestionType = p4.QuestionType, - BodySystem = p4.BodySystem, - IsSign = p4.IsSign, - IsSymptom = p4.IsSymptom, - MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId, - Id = p4.Id - }; - public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p5) - { - return p5 == null ? null : new MedicalHistoryQuestionSDto() + return p4 == null ? null : new MedicalHistoryQuestionSDto() { - Question = p5.Question, - Part = p5.Part, - QuestionType = p5.QuestionType, - MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId, - BodySystem = p5.BodySystem, - IsSign = p5.IsSign, - IsSymptom = p5.IsSymptom, - Id = p5.Id + Question = p4.Question, + Part = p4.Part, + QuestionType = p4.QuestionType, + MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId, + BodySystem = p4.BodySystem, + IsSign = p4.IsSign, + IsSymptom = p4.IsSymptom, + Id = p4.Id }; } - public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p6, MedicalHistoryQuestionSDto p7) + public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p5, MedicalHistoryQuestionSDto p6) { - if (p6 == null) + if (p5 == null) { return null; } - MedicalHistoryQuestionSDto result = p7 ?? new MedicalHistoryQuestionSDto(); + MedicalHistoryQuestionSDto result = p6 ?? new MedicalHistoryQuestionSDto(); - result.Question = p6.Question; - result.Part = p6.Part; - result.QuestionType = p6.QuestionType; - result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId; - result.BodySystem = p6.BodySystem; - result.IsSign = p6.IsSign; - result.IsSymptom = p6.IsSymptom; - result.Id = p6.Id; + result.Question = p5.Question; + result.Part = p5.Part; + result.QuestionType = p5.QuestionType; + result.MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId; + result.BodySystem = p5.BodySystem; + result.IsSign = p5.IsSign; + result.IsSymptom = p5.IsSymptom; + result.Id = p5.Id; return result; } - public static Expression> ProjectToSDto => p8 => new MedicalHistoryQuestionSDto() + public static Expression> ProjectToSDto => p7 => new MedicalHistoryQuestionSDto() { - Question = p8.Question, - Part = p8.Part, - QuestionType = p8.QuestionType, - MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId, - BodySystem = p8.BodySystem, - IsSign = p8.IsSign, - IsSymptom = p8.IsSymptom, - Id = p8.Id + Question = p7.Question, + Part = p7.Part, + QuestionType = p7.QuestionType, + MedicalHistoryTemplateId = p7.MedicalHistoryTemplateId, + BodySystem = p7.BodySystem, + IsSign = p7.IsSign, + IsSymptom = p7.IsSymptom, + Id = p7.Id }; } } \ No newline at end of file diff --git a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs index 5268a79..985a37f 100644 --- a/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs +++ b/DocuMed.Domain/Mappers/MedicalHistoryTemplateMapper.g.cs @@ -4,274 +4,219 @@ using System.Linq; using System.Linq.Expressions; using DocuMed.Domain.Dtos.LargDtos; using DocuMed.Domain.Dtos.SmallDtos; -using DocuMed.Domain.Entities.City; +using DocuMed.Domain.Entities.Hospitals; using DocuMed.Domain.Entities.MedicalHistoryTemplate; namespace DocuMed.Domain.Mappers { public static partial class MedicalHistoryTemplateMapper { - public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p1) + public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p1) { return p1 == null ? null : new MedicalHistoryTemplate() { ChiefComplaint = p1.ChiefComplaint, SectionId = p1.SectionId, + Section = p1.Section == null ? null : new Section() + { + Name = p1.Section.Name, + Detail = p1.Section.Detail, + HospitalId = p1.Section.HospitalId, + Id = p1.Section.Id + }, ApplicationUserId = p1.ApplicationUserId, + Questions = funcMain1(p1.Questions), Id = p1.Id, CreatedAt = p1.CreatedAt }; } - public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p2, MedicalHistoryTemplate p3) + public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p3, MedicalHistoryTemplate p4) { - if (p2 == null) + if (p3 == null) { return null; } - MedicalHistoryTemplate result = p3 ?? new MedicalHistoryTemplate(); + MedicalHistoryTemplate result = p4 ?? new MedicalHistoryTemplate(); - result.ChiefComplaint = p2.ChiefComplaint; - result.SectionId = p2.SectionId; - result.ApplicationUserId = p2.ApplicationUserId; - result.Id = p2.Id; - result.CreatedAt = p2.CreatedAt; + result.ChiefComplaint = p3.ChiefComplaint; + result.SectionId = p3.SectionId; + result.Section = funcMain2(p3.Section, result.Section); + result.ApplicationUserId = p3.ApplicationUserId; + result.Questions = funcMain3(p3.Questions, result.Questions); + result.Id = p3.Id; + result.CreatedAt = p3.CreatedAt; return result; } - public static Expression> ProjectToMedicalHistoryTemplate => p4 => new MedicalHistoryTemplate() + public static Expression> ProjectToMedicalHistoryTemplate => p9 => new MedicalHistoryTemplate() { - ChiefComplaint = p4.ChiefComplaint, - SectionId = p4.SectionId, - ApplicationUserId = p4.ApplicationUserId, - Id = p4.Id, - CreatedAt = p4.CreatedAt - }; - public static MedicalHistoryTemplateSDto AdaptToSDto(this MedicalHistoryTemplate p5) - { - return p5 == null ? null : new MedicalHistoryTemplateSDto() + ChiefComplaint = p9.ChiefComplaint, + SectionId = p9.SectionId, + Section = p9.Section == null ? null : new Section() { - ChiefComplaint = p5.ChiefComplaint, - SectionName = p5.Section == null ? null : p5.Section.Name, - SectionId = p5.SectionId, - ApplicationUserId = p5.ApplicationUserId, - CreatedAt = p5.CreatedAt, - Id = p5.Id - }; - } - public static MedicalHistoryTemplateSDto AdaptTo(this MedicalHistoryTemplate p6, MedicalHistoryTemplateSDto p7) - { - if (p6 == null) - { - return null; - } - MedicalHistoryTemplateSDto result = p7 ?? new MedicalHistoryTemplateSDto(); - - result.ChiefComplaint = p6.ChiefComplaint; - result.SectionName = p6.Section == null ? null : p6.Section.Name; - result.SectionId = p6.SectionId; - result.ApplicationUserId = p6.ApplicationUserId; - result.CreatedAt = p6.CreatedAt; - result.Id = p6.Id; - return result; - - } - public static Expression> ProjectToSDto => p8 => new MedicalHistoryTemplateSDto() - { - ChiefComplaint = p8.ChiefComplaint, - SectionName = p8.Section.Name, - SectionId = p8.SectionId, - ApplicationUserId = p8.ApplicationUserId, - CreatedAt = p8.CreatedAt, - Id = p8.Id - }; - public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p9) - { - return p9 == null ? null : new MedicalHistoryTemplate() - { - ChiefComplaint = p9.ChiefComplaint, - SectionId = p9.SectionId, - Section = p9.Section == null ? null : new Section() - { - Name = p9.Section.Name, - Detail = p9.Section.Detail, - UniversityId = p9.Section.UniversityId, - Id = p9.Section.Id - }, - ApplicationUserId = p9.ApplicationUserId, - Questions = funcMain1(p9.Questions), - Id = p9.Id, - CreatedAt = p9.CreatedAt - }; - } - public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p11, MedicalHistoryTemplate p12) - { - if (p11 == null) - { - return null; - } - MedicalHistoryTemplate result = p12 ?? new MedicalHistoryTemplate(); - - result.ChiefComplaint = p11.ChiefComplaint; - result.SectionId = p11.SectionId; - result.Section = funcMain2(p11.Section, result.Section); - result.ApplicationUserId = p11.ApplicationUserId; - result.Questions = funcMain3(p11.Questions, result.Questions); - result.Id = p11.Id; - result.CreatedAt = p11.CreatedAt; - return result; - - } - public static Expression> ProjectLDtoToMedicalHistoryTemplate => p17 => new MedicalHistoryTemplate() - { - ChiefComplaint = p17.ChiefComplaint, - SectionId = p17.SectionId, - Section = p17.Section == null ? null : new Section() - { - Name = p17.Section.Name, - Detail = p17.Section.Detail, - UniversityId = p17.Section.UniversityId, - Id = p17.Section.Id + Name = p9.Section.Name, + Detail = p9.Section.Detail, + HospitalId = p9.Section.HospitalId, + Id = p9.Section.Id }, - ApplicationUserId = p17.ApplicationUserId, - Questions = p17.Questions.Select(p18 => new MedicalHistoryQuestion() + ApplicationUserId = p9.ApplicationUserId, + Questions = p9.Questions.Select(p10 => new MedicalHistoryQuestion() { - Question = p18.Question, - Part = p18.Part, - QuestionType = p18.QuestionType, - BodySystem = p18.BodySystem, - IsSign = p18.IsSign, - IsSymptom = p18.IsSymptom, - MedicalHistoryTemplateId = p18.MedicalHistoryTemplateId, - Id = p18.Id + Question = p10.Question, + Part = p10.Part, + QuestionType = p10.QuestionType, + BodySystem = p10.BodySystem, + IsSign = p10.IsSign, + IsSymptom = p10.IsSymptom, + MedicalHistoryTemplateId = p10.MedicalHistoryTemplateId, + Id = p10.Id }).ToList(), - Id = p17.Id, - CreatedAt = p17.CreatedAt + Id = p9.Id, + CreatedAt = p9.CreatedAt }; - public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p19) + public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p11) { - return p19 == null ? null : new MedicalHistoryTemplateLDto() + return p11 == null ? null : new MedicalHistoryTemplateLDto() { - ChiefComplaint = p19.ChiefComplaint, - SectionId = p19.SectionId, - Section = p19.Section == null ? null : new SectionSDto() + ChiefComplaint = p11.ChiefComplaint, + SectionId = p11.SectionId, + Section = p11.Section == null ? null : new SectionSDto() { - Name = p19.Section.Name, - Detail = p19.Section.Detail, - UniversityId = p19.Section.UniversityId, - Id = p19.Section.Id + Name = p11.Section.Name, + Detail = p11.Section.Detail, + HospitalId = p11.Section.HospitalId, + Id = p11.Section.Id }, - ApplicationUserId = p19.ApplicationUserId, - CreatedAt = p19.CreatedAt, - Questions = funcMain4(p19.Questions), - Id = p19.Id + ApplicationUserId = p11.ApplicationUserId, + CreatedAt = p11.CreatedAt, + Questions = funcMain4(p11.Questions), + Id = p11.Id }; } - public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p21, MedicalHistoryTemplateLDto p22) - { - if (p21 == null) - { - return null; - } - MedicalHistoryTemplateLDto result = p22 ?? new MedicalHistoryTemplateLDto(); - - result.ChiefComplaint = p21.ChiefComplaint; - result.SectionId = p21.SectionId; - result.Section = funcMain5(p21.Section, result.Section); - result.ApplicationUserId = p21.ApplicationUserId; - result.CreatedAt = p21.CreatedAt; - result.Questions = funcMain6(p21.Questions, result.Questions); - result.Id = p21.Id; - return result; - - } - public static Expression> ProjectToLDto => p27 => new MedicalHistoryTemplateLDto() - { - ChiefComplaint = p27.ChiefComplaint, - SectionId = p27.SectionId, - Section = p27.Section == null ? null : new SectionSDto() - { - Name = p27.Section.Name, - Detail = p27.Section.Detail, - UniversityId = p27.Section.UniversityId, - Id = p27.Section.Id - }, - ApplicationUserId = p27.ApplicationUserId, - CreatedAt = p27.CreatedAt, - Questions = p27.Questions.Select(p28 => new MedicalHistoryQuestionSDto() - { - Question = p28.Question, - Part = p28.Part, - QuestionType = p28.QuestionType, - MedicalHistoryTemplateId = p28.MedicalHistoryTemplateId, - BodySystem = p28.BodySystem, - IsSign = p28.IsSign, - IsSymptom = p28.IsSymptom, - Id = p28.Id - }).ToList(), - Id = p27.Id - }; - - private static List funcMain1(List p10) - { - if (p10 == null) - { - return null; - } - List result = new List(p10.Count); - - int i = 0; - int len = p10.Count; - - while (i < len) - { - MedicalHistoryQuestionSDto item = p10[i]; - result.Add(item == null ? null : new MedicalHistoryQuestion() - { - Question = item.Question, - Part = item.Part, - QuestionType = item.QuestionType, - BodySystem = item.BodySystem, - IsSign = item.IsSign, - IsSymptom = item.IsSymptom, - MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, - Id = item.Id - }); - i++; - } - return result; - - } - - private static Section funcMain2(SectionSDto p13, Section p14) + public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p13, MedicalHistoryTemplateLDto p14) { if (p13 == null) { return null; } - Section result = p14 ?? new Section(); + MedicalHistoryTemplateLDto result = p14 ?? new MedicalHistoryTemplateLDto(); - result.Name = p13.Name; - result.Detail = p13.Detail; - result.UniversityId = p13.UniversityId; + result.ChiefComplaint = p13.ChiefComplaint; + result.SectionId = p13.SectionId; + result.Section = funcMain5(p13.Section, result.Section); + result.ApplicationUserId = p13.ApplicationUserId; + result.CreatedAt = p13.CreatedAt; + result.Questions = funcMain6(p13.Questions, result.Questions); result.Id = p13.Id; return result; } - - private static List funcMain3(List p15, List p16) + public static Expression> ProjectToLDto => p19 => new MedicalHistoryTemplateLDto() { - if (p15 == null) + ChiefComplaint = p19.ChiefComplaint, + SectionId = p19.SectionId, + Section = p19.Section == null ? null : new SectionSDto() + { + Name = p19.Section.Name, + Detail = p19.Section.Detail, + HospitalId = p19.Section.HospitalId, + Id = p19.Section.Id + }, + ApplicationUserId = p19.ApplicationUserId, + CreatedAt = p19.CreatedAt, + Questions = p19.Questions.Select(p20 => new MedicalHistoryQuestionSDto() + { + Question = p20.Question, + Part = p20.Part, + QuestionType = p20.QuestionType, + MedicalHistoryTemplateId = p20.MedicalHistoryTemplateId, + BodySystem = p20.BodySystem, + IsSign = p20.IsSign, + IsSymptom = p20.IsSymptom, + Id = p20.Id + }).ToList(), + Id = p19.Id + }; + public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p21) + { + return p21 == null ? null : new MedicalHistoryTemplate() + { + ChiefComplaint = p21.ChiefComplaint, + SectionId = p21.SectionId, + ApplicationUserId = p21.ApplicationUserId, + Id = p21.Id, + CreatedAt = p21.CreatedAt + }; + } + public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p22, MedicalHistoryTemplate p23) + { + if (p22 == null) { return null; } - List result = new List(p15.Count); + MedicalHistoryTemplate result = p23 ?? new MedicalHistoryTemplate(); + + result.ChiefComplaint = p22.ChiefComplaint; + result.SectionId = p22.SectionId; + result.ApplicationUserId = p22.ApplicationUserId; + result.Id = p22.Id; + result.CreatedAt = p22.CreatedAt; + return result; + + } + public static MedicalHistoryTemplateSDto AdaptToSDto(this MedicalHistoryTemplate p24) + { + return p24 == null ? null : new MedicalHistoryTemplateSDto() + { + ChiefComplaint = p24.ChiefComplaint, + SectionName = p24.Section == null ? null : p24.Section.Name, + SectionId = p24.SectionId, + ApplicationUserId = p24.ApplicationUserId, + CreatedAt = p24.CreatedAt, + Id = p24.Id + }; + } + public static MedicalHistoryTemplateSDto AdaptTo(this MedicalHistoryTemplate p25, MedicalHistoryTemplateSDto p26) + { + if (p25 == null) + { + return null; + } + MedicalHistoryTemplateSDto result = p26 ?? new MedicalHistoryTemplateSDto(); + + result.ChiefComplaint = p25.ChiefComplaint; + result.SectionName = p25.Section == null ? null : p25.Section.Name; + result.SectionId = p25.SectionId; + result.ApplicationUserId = p25.ApplicationUserId; + result.CreatedAt = p25.CreatedAt; + result.Id = p25.Id; + return result; + + } + public static Expression> ProjectToSDto => p27 => new MedicalHistoryTemplateSDto() + { + ChiefComplaint = p27.ChiefComplaint, + SectionName = p27.Section.Name, + SectionId = p27.SectionId, + ApplicationUserId = p27.ApplicationUserId, + CreatedAt = p27.CreatedAt, + Id = p27.Id + }; + + private static List funcMain1(List p2) + { + if (p2 == null) + { + return null; + } + List result = new List(p2.Count); int i = 0; - int len = p15.Count; + int len = p2.Count; while (i < len) { - MedicalHistoryQuestionSDto item = p15[i]; + MedicalHistoryQuestionSDto item = p2[i]; result.Add(item == null ? null : new MedicalHistoryQuestion() { Question = item.Question, @@ -289,20 +234,67 @@ namespace DocuMed.Domain.Mappers } - private static List funcMain4(List p20) + private static Section funcMain2(SectionSDto p5, Section p6) { - if (p20 == null) + if (p5 == null) { return null; } - List result = new List(p20.Count); + Section result = p6 ?? new Section(); + + result.Name = p5.Name; + result.Detail = p5.Detail; + result.HospitalId = p5.HospitalId; + result.Id = p5.Id; + return result; + + } + + private static List funcMain3(List p7, List p8) + { + if (p7 == null) + { + return null; + } + List result = new List(p7.Count); int i = 0; - int len = p20.Count; + int len = p7.Count; while (i < len) { - MedicalHistoryQuestion item = p20[i]; + MedicalHistoryQuestionSDto item = p7[i]; + result.Add(item == null ? null : new MedicalHistoryQuestion() + { + Question = item.Question, + Part = item.Part, + QuestionType = item.QuestionType, + BodySystem = item.BodySystem, + IsSign = item.IsSign, + IsSymptom = item.IsSymptom, + MedicalHistoryTemplateId = item.MedicalHistoryTemplateId, + Id = item.Id + }); + i++; + } + return result; + + } + + private static List funcMain4(List p12) + { + if (p12 == null) + { + return null; + } + List result = new List(p12.Count); + + int i = 0; + int len = p12.Count; + + while (i < len) + { + MedicalHistoryQuestion item = p12[i]; result.Add(item == null ? null : new MedicalHistoryQuestionSDto() { Question = item.Question, @@ -320,36 +312,36 @@ namespace DocuMed.Domain.Mappers } - private static SectionSDto funcMain5(Section p23, SectionSDto p24) + private static SectionSDto funcMain5(Section p15, SectionSDto p16) { - if (p23 == null) + if (p15 == null) { return null; } - SectionSDto result = p24 ?? new SectionSDto(); + SectionSDto result = p16 ?? new SectionSDto(); - result.Name = p23.Name; - result.Detail = p23.Detail; - result.UniversityId = p23.UniversityId; - result.Id = p23.Id; + result.Name = p15.Name; + result.Detail = p15.Detail; + result.HospitalId = p15.HospitalId; + result.Id = p15.Id; return result; } - private static List funcMain6(List p25, List p26) + private static List funcMain6(List p17, List p18) { - if (p25 == null) + if (p17 == null) { return null; } - List result = new List(p25.Count); + List result = new List(p17.Count); int i = 0; - int len = p25.Count; + int len = p17.Count; while (i < len) { - MedicalHistoryQuestion item = p25[i]; + MedicalHistoryQuestion item = p17[i]; result.Add(item == null ? null : new MedicalHistoryQuestionSDto() { Question = item.Question, diff --git a/DocuMed.Domain/Mappers/SectionMapper.g.cs b/DocuMed.Domain/Mappers/SectionMapper.g.cs index 502129d..89bfb99 100644 --- a/DocuMed.Domain/Mappers/SectionMapper.g.cs +++ b/DocuMed.Domain/Mappers/SectionMapper.g.cs @@ -1,7 +1,7 @@ using System; using System.Linq.Expressions; using DocuMed.Domain.Dtos.SmallDtos; -using DocuMed.Domain.Entities.City; +using DocuMed.Domain.Entities.Hospitals; namespace DocuMed.Domain.Mappers { @@ -13,7 +13,7 @@ namespace DocuMed.Domain.Mappers { Name = p1.Name, Detail = p1.Detail, - UniversityId = p1.UniversityId, + HospitalId = p1.HospitalId, Id = p1.Id }; } @@ -27,7 +27,7 @@ namespace DocuMed.Domain.Mappers result.Name = p2.Name; result.Detail = p2.Detail; - result.UniversityId = p2.UniversityId; + result.HospitalId = p2.HospitalId; result.Id = p2.Id; return result; @@ -36,7 +36,7 @@ namespace DocuMed.Domain.Mappers { Name = p4.Name, Detail = p4.Detail, - UniversityId = p4.UniversityId, + HospitalId = p4.HospitalId, Id = p4.Id }; public static SectionSDto AdaptToSDto(this Section p5) @@ -45,7 +45,7 @@ namespace DocuMed.Domain.Mappers { Name = p5.Name, Detail = p5.Detail, - UniversityId = p5.UniversityId, + HospitalId = p5.HospitalId, Id = p5.Id }; } @@ -59,7 +59,7 @@ namespace DocuMed.Domain.Mappers result.Name = p6.Name; result.Detail = p6.Detail; - result.UniversityId = p6.UniversityId; + result.HospitalId = p6.HospitalId; result.Id = p6.Id; return result; @@ -68,7 +68,7 @@ namespace DocuMed.Domain.Mappers { Name = p8.Name, Detail = p8.Detail, - UniversityId = p8.UniversityId, + HospitalId = p8.HospitalId, Id = p8.Id }; } diff --git a/DocuMed.Domain/Mappers/StudentMapper.g.cs b/DocuMed.Domain/Mappers/StudentMapper.g.cs new file mode 100644 index 0000000..90879c2 --- /dev/null +++ b/DocuMed.Domain/Mappers/StudentMapper.g.cs @@ -0,0 +1,157 @@ +using System; +using System.Linq.Expressions; +using DocuMed.Domain.Dtos.SmallDtos; +using DocuMed.Domain.Entities.City; +using DocuMed.Domain.Entities.Hospitals; +using DocuMed.Domain.Entities.Staffs; +using DocuMed.Domain.Entities.User; +using Mapster.Models; + +namespace DocuMed.Domain.Mappers +{ + public static partial class StudentMapper + { + public static Student AdaptToStudent(this StudentSDto p1) + { + return p1 == null ? null : new Student() + { + StudentId = p1.StudentId, + UniversityId = p1.UniversityId, + University = new University() + { + Name = p1.UniversityName, + Id = p1.UniversityId + }, + SectionId = p1.SectionId, + Section = new Section() + { + Name = p1.SectionName, + Id = p1.SectionId + }, + UserId = p1.UserId, + User = new ApplicationUser() {Id = p1.UserId}, + Id = p1.Id + }; + } + public static Student AdaptTo(this StudentSDto p2, Student p3) + { + if (p2 == null) + { + return null; + } + Student result = p3 ?? new Student(); + + result.StudentId = p2.StudentId; + result.UniversityId = p2.UniversityId; + result.University = funcMain1(new Never(), result.University, p2); + result.SectionId = p2.SectionId; + result.Section = funcMain2(new Never(), result.Section, p2); + result.UserId = p2.UserId; + result.User = funcMain3(new Never(), result.User, p2); + result.Id = p2.Id; + return result; + + } + public static Expression> ProjectToStudent => p10 => new Student() + { + StudentId = p10.StudentId, + UniversityId = p10.UniversityId, + University = new University() + { + Name = p10.UniversityName, + Id = p10.UniversityId + }, + SectionId = p10.SectionId, + Section = new Section() + { + Name = p10.SectionName, + Id = p10.SectionId + }, + UserId = p10.UserId, + User = new ApplicationUser() {Id = p10.UserId}, + Id = p10.Id + }; + public static StudentSDto AdaptToSDto(this Student p11) + { + return p11 == null ? null : new StudentSDto() + { + StudentId = p11.StudentId, + UniversityId = p11.UniversityId, + UniversityName = p11.University != null ? p11.University.Name : string.Empty, + SectionId = p11.SectionId, + SectionName = p11.Section != null ? p11.Section.Name : string.Empty, + UserId = p11.UserId, + PhoneNumber = p11.User != null ? p11.User.PhoneNumber : string.Empty, + FirstName = p11.User != null ? p11.User.FirstName : string.Empty, + LastName = p11.User != null ? p11.User.LastName : string.Empty, + NationalId = p11.User != null ? p11.User.NationalId : string.Empty, + Id = p11.Id + }; + } + public static StudentSDto AdaptTo(this Student p12, StudentSDto p13) + { + if (p12 == null) + { + return null; + } + StudentSDto result = p13 ?? new StudentSDto(); + + result.StudentId = p12.StudentId; + result.UniversityId = p12.UniversityId; + result.UniversityName = p12.University != null ? p12.University.Name : string.Empty; + result.SectionId = p12.SectionId; + result.SectionName = p12.Section != null ? p12.Section.Name : string.Empty; + result.UserId = p12.UserId; + result.PhoneNumber = p12.User != null ? p12.User.PhoneNumber : string.Empty; + result.FirstName = p12.User != null ? p12.User.FirstName : string.Empty; + result.LastName = p12.User != null ? p12.User.LastName : string.Empty; + result.NationalId = p12.User != null ? p12.User.NationalId : string.Empty; + result.Id = p12.Id; + return result; + + } + public static Expression> ProjectToSDto => p14 => new StudentSDto() + { + StudentId = p14.StudentId, + UniversityId = p14.UniversityId, + UniversityName = p14.University != null ? p14.University.Name : string.Empty, + SectionId = p14.SectionId, + SectionName = p14.Section != null ? p14.Section.Name : string.Empty, + UserId = p14.UserId, + PhoneNumber = p14.User != null ? p14.User.PhoneNumber : string.Empty, + FirstName = p14.User != null ? p14.User.FirstName : string.Empty, + LastName = p14.User != null ? p14.User.LastName : string.Empty, + NationalId = p14.User != null ? p14.User.NationalId : string.Empty, + Id = p14.Id + }; + + private static University funcMain1(Never p4, University p5, StudentSDto p2) + { + University result = p5 ?? new University(); + + result.Name = p2.UniversityName; + result.Id = p2.UniversityId; + return result; + + } + + private static Section funcMain2(Never p6, Section p7, StudentSDto p2) + { + Section result = p7 ?? new Section(); + + result.Name = p2.SectionName; + result.Id = p2.SectionId; + return result; + + } + + private static ApplicationUser funcMain3(Never p8, ApplicationUser p9, StudentSDto p2) + { + ApplicationUser result = p9 ?? new ApplicationUser(); + + result.Id = p2.UserId; + return result; + + } + } +} \ No newline at end of file diff --git a/DocuMed.Domain/MapsterRegister.cs b/DocuMed.Domain/MapsterRegister.cs index 2e47b97..152e073 100644 --- a/DocuMed.Domain/MapsterRegister.cs +++ b/DocuMed.Domain/MapsterRegister.cs @@ -9,8 +9,13 @@ public class MapsterRegister : IRegister .TwoWays(); - config.NewConfig() - .Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty) + config.NewConfig() + .Map(des=>des.SectionName, org => org.Section != null ? org.Section.Name : string.Empty) + .Map(des=>des.UniversityName, org => org.University != null ? org.University.Name : string.Empty) + .Map(des => des.PhoneNumber, org => org.User != null ? org.User.PhoneNumber : string.Empty) + .Map(des=>des.FirstName, org => org.User != null ? org.User.FirstName : string.Empty) + .Map(des=>des.LastName, org => org.User != null ? org.User.LastName : string.Empty) + .Map(des=>des.NationalId, org => org.User != null ? org.User.NationalId : string.Empty) .TwoWays(); } } \ No newline at end of file diff --git a/DocuMed.Domain/Models/Refers.cs b/DocuMed.Domain/Models/Refers.cs new file mode 100644 index 0000000..be27c3f --- /dev/null +++ b/DocuMed.Domain/Models/Refers.cs @@ -0,0 +1,8 @@ +namespace DocuMed.Domain.Models; + +public static class Refers +{ + public const int SizeS = 10; + public const int SizeM = 15; + public const int SizeL = 20; +} \ No newline at end of file diff --git a/DocuMed.Infrastructure/RestServices/IKaveNegarRestApi.cs b/DocuMed.Infrastructure/RestServices/IKaveNegarRestApi.cs index 37b39c3..e518aaa 100644 --- a/DocuMed.Infrastructure/RestServices/IKaveNegarRestApi.cs +++ b/DocuMed.Infrastructure/RestServices/IKaveNegarRestApi.cs @@ -4,7 +4,9 @@ public interface IKaveNegarRestApi { [Post("/{apiKey}/verify/lookup.json")] - Task SendLookUp(string apiKey, [Query] string receptor, [Query] string token, [Query] string token2, [Query] string token10, [Query] string token20, [Query] string template); + Task SendLookUp(string apiKey, [Query] string receptor, [Query] string template, [Query] string token, [Query] string? token2 = null, + [Query] string? token3 = null, [Query] string? token10 = null, [Query] string? token20 = null); + [Post("/{apiKey}/sms/send.json")] Task SendSms(string apiKey, [Query] string receptor, [Query] string message, [Query] string sender); } \ No newline at end of file diff --git a/DocuMed.Infrastructure/Services/SmsService.cs b/DocuMed.Infrastructure/Services/SmsService.cs index da415a0..365e254 100644 --- a/DocuMed.Infrastructure/Services/SmsService.cs +++ b/DocuMed.Infrastructure/Services/SmsService.cs @@ -1,33 +1,71 @@ -namespace DocuMed.Infrastructure.Services; +using Microsoft.Extensions.Hosting; +using System; + +namespace DocuMed.Infrastructure.Services; -public class SmsService : ISmsService +public class SmsService( + IRestApiWrapper restApiWrapper, + IOptionsSnapshot optionsSnapshot, + ILogger logger, + IHostEnvironment environment) : ISmsService { - private readonly IRestApiWrapper _restApiWrapper; - private readonly ILogger _logger; - private readonly SiteSettings _siteSettings; - public SmsService(IRestApiWrapper restApiWrapper, - IOptionsSnapshot optionsSnapshot, - ILogger logger) - { - _restApiWrapper = restApiWrapper; - _logger = logger; - _siteSettings = optionsSnapshot.Value; - } + private readonly ILogger _logger = logger; + private readonly SiteSettings _siteSettings = optionsSnapshot.Value; + public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword) { - var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword, null, null, null, "forgetPassword"); + var rest = await restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, "forgetPassword", newPassword, + null, null , null, null); - if (rest.Return?.status != 200) - throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message); + if (rest.Return.status != 200) + throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message); } public async Task SendVerifyCodeAsync(string phoneNumber, string verifyCode) { - var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, verifyCode, null, null, null, "login-documed"); - if (rest.Return?.status != 200) - throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message); + try + { + var rest = await restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, "login-documed", verifyCode); + + if (rest.Return.status != 200 && environment.IsProduction()) + throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message); + } + catch (ApiException apiException) + { + if (environment.IsProduction()) + throw; + else + logger.LogError(apiException.Message); + } + catch (Exception apiException) + { + if (environment.IsProduction()) + throw; + else + logger.LogError(apiException.Message); + } } + public async Task SendLookUpAsync(string phoneNumber, string template, string token, string? token2 = null, string? token3 = null, string? token10 = null, string? token20 = null) + { + try + { + var rest = await restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, template, token, token2, token3, token10, token20); + + if (rest.Return.status != 200) + throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message); + } + catch (ApiException apiException) + { + logger.LogError(apiException.Message); + } + catch (Exception apiException) + { + logger.LogError(apiException.Message); + } + } + + } \ No newline at end of file diff --git a/DocuMed.PWA/DocuMed.PWA.csproj b/DocuMed.PWA/DocuMed.PWA.csproj index b04af04..059e5be 100644 --- a/DocuMed.PWA/DocuMed.PWA.csproj +++ b/DocuMed.PWA/DocuMed.PWA.csproj @@ -16,7 +16,7 @@ - + diff --git a/DocuMed.PWA/Models/Address.cs b/DocuMed.PWA/Models/Address.cs index bcbba83..15f6f55 100644 --- a/DocuMed.PWA/Models/Address.cs +++ b/DocuMed.PWA/Models/Address.cs @@ -3,7 +3,7 @@ public static class Address { #if DEBUG - public static string BaseAddress = "http://localhost:32770/api"; + public static string BaseAddress = "http://localhost:32780/api"; //public static string BaseAddress = "https://api.documed.ir/api"; #else public static string BaseAddress = "https://api.documed.ir/api"; diff --git a/DocuMed.PWA/Models/Api/ApiResult.cs b/DocuMed.PWA/Models/Api/ApiResult.cs index 9ad8f81..03fbd9a 100644 --- a/DocuMed.PWA/Models/Api/ApiResult.cs +++ b/DocuMed.PWA/Models/Api/ApiResult.cs @@ -1,25 +1,16 @@ namespace DocuMed.PWA.Models.Api; -public class ApiResult +public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) { - public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) - { - IsSuccess = isSuccess; - StatusCode = statusCode; - Message = message ?? statusCode.ToDisplay(); - } + public bool IsSuccess { get; set; } = isSuccess; + public ApiResultStatusCode StatusCode { get; set; } = statusCode; - public bool IsSuccess { get; set; } - public ApiResultStatusCode StatusCode { get; set; } - - public string Message { get; set; } + public string Message { get; set; } = message ?? statusCode.ToDisplay(); } -public class ApiResult : ApiResult where TData : class +public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) + : ApiResult(isSuccess, statusCode, message) + where TData : class { - public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) : base(isSuccess, statusCode, message) - { - Data = data; - } - public TData Data { get; set; } + public TData Data { get; set; } = data; } \ No newline at end of file diff --git a/DocuMed.PWA/Models/BaseViewModel.cs b/DocuMed.PWA/Models/BaseViewModel.cs index 7f8eb55..2db1676 100644 --- a/DocuMed.PWA/Models/BaseViewModel.cs +++ b/DocuMed.PWA/Models/BaseViewModel.cs @@ -17,11 +17,8 @@ public class BaseViewModel public class BaseViewModel { public bool IsProcessing { get; set; } = false; - public TPageDto PageDto { get; set; } - public BaseViewModel() - { - PageDto = Activator.CreateInstance(); - } + public TPageDto PageDto { get; set; } = Activator.CreateInstance(); + public virtual void Initialize() { diff --git a/DocuMed.PWA/Pages/HomePage.razor.cs b/DocuMed.PWA/Pages/HomePage.razor.cs index 3a96518..972e44e 100644 --- a/DocuMed.PWA/Pages/HomePage.razor.cs +++ b/DocuMed.PWA/Pages/HomePage.razor.cs @@ -3,20 +3,11 @@ using DocuMed.Domain.Enums.QueryFilters; namespace DocuMed.PWA.Pages; -public class HomePageViewModel : BaseViewModel> +public class HomePageViewModel(IUserUtility userUtility, IRestWrapper restWrapper, ISnackbar snackbar) + : BaseViewModel> { - private readonly IUserUtility _userUtility; - private readonly IRestWrapper _restWrapper; - private readonly ISnackbar _snackbar; public DayQueryFilter SelectedDayFilter { get; set; } = DayQueryFilter.Today; - public HomePageViewModel(IUserUtility userUtility,IRestWrapper restWrapper,ISnackbar snackbar) - { - _userUtility = userUtility; - _restWrapper = restWrapper; - _snackbar = snackbar; - } - public ApplicationUserSDto User { get; private set; } = new ApplicationUserSDto(); @@ -27,9 +18,9 @@ public class HomePageViewModel : BaseViewModel> try { IsProcessing = true; - User = await _userUtility.GetUserAsync(); - var token = await _userUtility.GetBearerTokenAsync(); - var list = await _restWrapper + User = await userUtility.GetUserAsync(); + var token = await userUtility.GetBearerTokenAsync(); + var list = await restWrapper .MedicalHistoryRestApi .GetAllByFilterAsync(SelectedDayFilter, 0, token); PageDto = list; @@ -38,11 +29,11 @@ public class HomePageViewModel : BaseViewModel> catch (ApiException ex) { var exe = await ex.GetContentAsAsync(); - _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); } catch (Exception e) { - _snackbar.Add(e.Message, Severity.Error); + snackbar.Add(e.Message, Severity.Error); } finally { diff --git a/DocuMed.PWA/Pages/Index.razor b/DocuMed.PWA/Pages/Index.razor index f2f0cee..6156005 100644 --- a/DocuMed.PWA/Pages/Index.razor +++ b/DocuMed.PWA/Pages/Index.razor @@ -15,24 +15,24 @@ color: white; } */ -
-
+
+
- -
+
+ background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay />
-

+

شرح حال نویسی بیمار راحت تر از همیشه

-

+

نرم افزار داکیومد با امکانات بسیار زیاد خود مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم @@ -41,17 +41,17 @@

-
+
-
+
+ background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay />
-

+

اوردر های شما همه در یک اپلیکیشن

-

+

نرم افزار داکیومد با امکانات بسیار زیاد خود مثل شرح حال نویسی همیار همیشگی پزشکان محترم @@ -60,16 +60,16 @@

-
+
-
+
+ background="transparent" speed="1" class="m-auto h-72 w-72" loop autoplay />
-

+

نرم افزار جامع داکیـــــومد

-

+

نرم افزار داکیومد با امکانات بسیار زیاد خود مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم @@ -79,14 +79,14 @@

- - + -
+
-

ورود | ثبت نام

-

+

ورود | ثبت نام

+

برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را وارد کنید

@@ -109,11 +109,11 @@
-
+
- -

ورود | ثبت نام

-

+ +

ورود | ثبت نام

+

برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را وارد کنید

@@ -125,7 +125,7 @@ Icon="@Icons.Material.TwoTone.Verified" Color="Color.Secondary" Variant="Variant.Filled"> -
+

02:00

ارسال مجدد پیامک @@ -141,19 +141,19 @@
-
- -

ثبت نام

-

+

+ +

ثبت نام

+

برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد کنید

- - - + + -
- -

منتظر بمانید

+
+ +

منتظر بمانید

@@ -180,9 +180,9 @@ -
- -

منتظر بمانید

+
+ +

منتظر بمانید

diff --git a/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs index 354fd12..617634f 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs +++ b/DocuMed.PWA/Pages/MedicalHistoryActionPage.razor.cs @@ -1,6 +1,7 @@ using DocuMed.PWA.Shared.Dialogs; using Mapster; using Microsoft.JSInterop; +using Section = DocuMed.Domain.Entities.Hospitals.Section; namespace DocuMed.PWA.Pages; diff --git a/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor.cs b/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor.cs index 003ab1f..ff3b68e 100644 --- a/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor.cs +++ b/DocuMed.PWA/Pages/MedicalHistoryTemplatesPage.razor.cs @@ -1,21 +1,14 @@ namespace DocuMed.PWA.Pages; -public class MedicalHistoryTemplatesPageViewModel : BaseViewModel> +public class MedicalHistoryTemplatesPageViewModel( + NavigationManager navigationManager, + IUserUtility userUtility, + IRestWrapper restWrapper, + ISnackbar snackbar) + : BaseViewModel> { - private readonly NavigationManager _navigationManager; - private readonly IUserUtility _userUtility; - private readonly IRestWrapper _restWrapper; - private readonly ISnackbar _snackbar; - - public MedicalHistoryTemplatesPageViewModel(NavigationManager navigationManager,IUserUtility userUtility , IRestWrapper restWrapper,ISnackbar snackbar) - { - _navigationManager = navigationManager; - _userUtility = userUtility; - _restWrapper = restWrapper; - _snackbar = snackbar; - } - public void CreateMedicalHistoryTemplateClicked() => _navigationManager.NavigateTo("MedicalHistoryTemplateActionPage"); - public void MedicalHistoryTemplateClicked(MedicalHistoryTemplateSDto template) => _navigationManager.NavigateTo($"MedicalHistoryTemplateActionPage/{template.Id.ToString()}"); + public void CreateMedicalHistoryTemplateClicked() => navigationManager.NavigateTo("MedicalHistoryTemplateActionPage"); + public void MedicalHistoryTemplateClicked(MedicalHistoryTemplateSDto template) => navigationManager.NavigateTo($"MedicalHistoryTemplateActionPage/{template.Id.ToString()}"); public override async Task InitializeAsync() { @@ -23,8 +16,8 @@ public class MedicalHistoryTemplatesPageViewModel : BaseViewModel( Address.MedicalHistoryTemplateController) .ReadAll(0, token); PageDto = list; @@ -33,11 +26,11 @@ public class MedicalHistoryTemplatesPageViewModel : BaseViewModel(); - _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); } catch (Exception e) { - _snackbar.Add(e.Message, Severity.Error); + snackbar.Add(e.Message, Severity.Error); } finally { diff --git a/DocuMed.PWA/Pages/ProfilePage.razor.cs b/DocuMed.PWA/Pages/ProfilePage.razor.cs index be7561d..d390d5b 100644 --- a/DocuMed.PWA/Pages/ProfilePage.razor.cs +++ b/DocuMed.PWA/Pages/ProfilePage.razor.cs @@ -3,12 +3,16 @@ using Mapster; namespace DocuMed.PWA.Pages; -public class ProfilePageViewModel : BaseViewModel +public class ProfilePageViewModel( + IUserUtility userUtility, + IRestWrapper restWrapper, + ISnackbar snackbar, + NavigationManager navigationManager) + : BaseViewModel { - private readonly NavigationManager _navigationManager; - public IUserUtility UserUtility { get; } - public IRestWrapper RestWrapper { get; } - public ISnackbar Snackbar { get; } + public IUserUtility UserUtility { get; } = userUtility; + public IRestWrapper RestWrapper { get; } = restWrapper; + public ISnackbar Snackbar { get; } = snackbar; public ApplicationUserSDto User { get; set; } = new(); @@ -21,14 +25,6 @@ public class ProfilePageViewModel : BaseViewModel public readonly string Version = Assembly.GetAssembly(typeof(Program))?.GetName()?.Version?.ToString() ?? string.Empty; - public ProfilePageViewModel(IUserUtility userUtility, IRestWrapper restWrapper, ISnackbar snackbar,NavigationManager navigationManager) - { - _navigationManager = navigationManager; - UserUtility = userUtility; - RestWrapper = restWrapper; - Snackbar = snackbar; - } - public override async Task InitializeAsync() { User = await UserUtility.GetUserAsync(); @@ -93,7 +89,7 @@ public class ProfilePageViewModel : BaseViewModel public async Task LogoutAsync() { await UserUtility.LogoutAsync(); - _navigationManager.NavigateTo(""); + navigationManager.NavigateTo(""); } diff --git a/DocuMed.PWA/Services/RestServices/ISectionRestApi.cs b/DocuMed.PWA/Services/RestServices/ISectionRestApi.cs index 7f47775..b88fcfd 100644 --- a/DocuMed.PWA/Services/RestServices/ISectionRestApi.cs +++ b/DocuMed.PWA/Services/RestServices/ISectionRestApi.cs @@ -1,4 +1,6 @@ -namespace DocuMed.PWA.Services.RestServices; +using Section = DocuMed.Domain.Entities.Hospitals.Section; + +namespace DocuMed.PWA.Services.RestServices; public interface ISectionRestApi : ICrudDtoApiRest { diff --git a/DocuMed.PWA/Utilities/UserUtility.cs b/DocuMed.PWA/Utilities/UserUtility.cs index 46b16ff..25d2fdb 100644 --- a/DocuMed.PWA/Utilities/UserUtility.cs +++ b/DocuMed.PWA/Utilities/UserUtility.cs @@ -2,24 +2,17 @@ namespace DocuMed.PWA.Utilities; -public class UserUtility : IUserUtility +public class UserUtility(ILocalStorageService localStorageService) : IUserUtility { - private readonly ILocalStorageService _localStorageService; + public async Task GetBearerTokenAsync() => await localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token); + public async Task SetBearerTokenAsync(string token) => await localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token, token); - public UserUtility(ILocalStorageService localStorageService) - { - _localStorageService = localStorageService; - } - - public async Task GetBearerTokenAsync() => await _localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token); - public async Task SetBearerTokenAsync(string token) => await _localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token, token); - - public async Task GetUserAsync() => await _localStorageService.GetItemAsync(LocalStorageKeys.UserInfo); - public async Task SetUserAsync(ApplicationUserSDto user) => await _localStorageService.SetItemAsync(LocalStorageKeys.UserInfo, user); + public async Task GetUserAsync() => await localStorageService.GetItemAsync(LocalStorageKeys.UserInfo); + public async Task SetUserAsync(ApplicationUserSDto user) => await localStorageService.SetItemAsync(LocalStorageKeys.UserInfo, user); public async Task LogoutAsync() { - await _localStorageService.RemoveItemAsync(LocalStorageKeys.Token); - await _localStorageService.RemoveItemAsync(LocalStorageKeys.UserInfo); + await localStorageService.RemoveItemAsync(LocalStorageKeys.Token); + await localStorageService.RemoveItemAsync(LocalStorageKeys.UserInfo); } //public AccessToken? AccessToken { get; set; } diff --git a/DocuMed.PWA/wwwroot/css/app.min.css b/DocuMed.PWA/wwwroot/css/app.min.css index ae050a9..38f5cd6 100644 --- a/DocuMed.PWA/wwwroot/css/app.min.css +++ b/DocuMed.PWA/wwwroot/css/app.min.css @@ -1,5 +1,111 @@ -/* -! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com +*, ::before, ::after { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +} + +::backdrop { + --tw-border-spacing-x: 0; + --tw-border-spacing-y: 0; + --tw-translate-x: 0; + --tw-translate-y: 0; + --tw-rotate: 0; + --tw-skew-x: 0; + --tw-skew-y: 0; + --tw-scale-x: 1; + --tw-scale-y: 1; + --tw-pan-x: ; + --tw-pan-y: ; + --tw-pinch-zoom: ; + --tw-scroll-snap-strictness: proximity; + --tw-gradient-from-position: ; + --tw-gradient-via-position: ; + --tw-gradient-to-position: ; + --tw-ordinal: ; + --tw-slashed-zero: ; + --tw-numeric-figure: ; + --tw-numeric-spacing: ; + --tw-numeric-fraction: ; + --tw-ring-inset: ; + --tw-ring-offset-width: 0px; + --tw-ring-offset-color: #fff; + --tw-ring-color: rgb(59 130 246 / 0.5); + --tw-ring-offset-shadow: 0 0 #0000; + --tw-ring-shadow: 0 0 #0000; + --tw-shadow: 0 0 #0000; + --tw-shadow-colored: 0 0 #0000; + --tw-blur: ; + --tw-brightness: ; + --tw-contrast: ; + --tw-grayscale: ; + --tw-hue-rotate: ; + --tw-invert: ; + --tw-saturate: ; + --tw-sepia: ; + --tw-drop-shadow: ; + --tw-backdrop-blur: ; + --tw-backdrop-brightness: ; + --tw-backdrop-contrast: ; + --tw-backdrop-grayscale: ; + --tw-backdrop-hue-rotate: ; + --tw-backdrop-invert: ; + --tw-backdrop-opacity: ; + --tw-backdrop-saturate: ; + --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; +}/* +! tailwindcss v3.4.13 | MIT License | https://tailwindcss.com *//* 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116) @@ -402,115 +508,7 @@ video { --color-secondary: rgba(253, 85, 35, 1); --color-medicalhistory: rgba(253, 216, 53, 1); --color-medicalhistory-template: rgba(41, 187, 189, 1); - } - -*, ::before, ::after { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; - --tw-contain-size: ; - --tw-contain-layout: ; - --tw-contain-paint: ; - --tw-contain-style: ; -} - -::backdrop { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; - --tw-contain-size: ; - --tw-contain-layout: ; - --tw-contain-paint: ; - --tw-contain-style: ; -} + } .visible { visibility: visible; } diff --git a/DocuMed.Repository/DocuMed - Backup.Repository.csproj b/DocuMed.Repository/DocuMed - Backup.Repository.csproj new file mode 100644 index 0000000..21eafa0 --- /dev/null +++ b/DocuMed.Repository/DocuMed - Backup.Repository.csproj @@ -0,0 +1,69 @@ + + + + net8.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DocuMed.Repository/DocuMed.Repository.csproj b/DocuMed.Repository/DocuMed.Repository.csproj index 364cf77..a418364 100644 --- a/DocuMed.Repository/DocuMed.Repository.csproj +++ b/DocuMed.Repository/DocuMed.Repository.csproj @@ -1,10 +1,10 @@  - - net8.0 - enable - enable - + + net8.0 + enable + enable + @@ -24,45 +24,49 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DocuMed.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs b/DocuMed.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs index 683d41a..159e3fe 100644 --- a/DocuMed.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs +++ b/DocuMed.Repository/Extensions/DbContextOptionCustomExtensionsInfo.cs @@ -1,11 +1,8 @@ namespace DocuMed.Repository.Extensions; -public class DbContextOptionCustomExtensionsInfo : DbContextOptionsExtensionInfo +public class DbContextOptionCustomExtensionsInfo(IDbContextOptionsExtension extension) + : DbContextOptionsExtensionInfo(extension) { - public DbContextOptionCustomExtensionsInfo(IDbContextOptionsExtension extension) : base(extension) - { - } - public override bool IsDatabaseProvider { get; } public override string LogFragment { get; } = string.Empty; diff --git a/DocuMed.Repository/Handlers/Hospitals/CreateHospitalCommandHandler.cs b/DocuMed.Repository/Handlers/Hospitals/CreateHospitalCommandHandler.cs new file mode 100644 index 0000000..10407b8 --- /dev/null +++ b/DocuMed.Repository/Handlers/Hospitals/CreateHospitalCommandHandler.cs @@ -0,0 +1,16 @@ +namespace DocuMed.Repository.Handlers.Hospitals; + +public class CreateHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler +{ + + public async Task Handle(CreateHospitalCommand request, CancellationToken cancellationToken) + { + var ent = Hospital.Create(request.Name, request.Detail, request.Address, request.UniversityId); + + repositoryWrapper.SetRepository().Add(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + + return ent.Id; + + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Hospitals/DeleteHospitalCommandHandler.cs b/DocuMed.Repository/Handlers/Hospitals/DeleteHospitalCommandHandler.cs new file mode 100644 index 0000000..5241ae7 --- /dev/null +++ b/DocuMed.Repository/Handlers/Hospitals/DeleteHospitalCommandHandler.cs @@ -0,0 +1,19 @@ +namespace DocuMed.Repository.Handlers.Hospitals; + +public class DeleteHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler +{ + + public async Task Handle(DeleteHospitalCommand request, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(h => h.Id == request.Id, cancellationToken); + if (ent == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found"); + + repositoryWrapper.SetRepository().Delete(ent); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + + return ent.Id; + + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Hospitals/GetHospitalQueryHandler.cs b/DocuMed.Repository/Handlers/Hospitals/GetHospitalQueryHandler.cs new file mode 100644 index 0000000..f0ba98b --- /dev/null +++ b/DocuMed.Repository/Handlers/Hospitals/GetHospitalQueryHandler.cs @@ -0,0 +1,16 @@ +namespace DocuMed.Repository.Handlers.Hospitals; + +public class GetHospitalQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler +{ + public async Task Handle(GetHospitalQuery request, CancellationToken cancellationToken) + { + var response = await repositoryWrapper.SetRepository() + .TableNoTracking + .Where(h => h.Id == request.Id) + .Select(HospitalMapper.ProjectToSDto) + .FirstOrDefaultAsync(cancellationToken); + if (response == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found"); + return response; + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Hospitals/GetHospitalsQueryHandler.cs b/DocuMed.Repository/Handlers/Hospitals/GetHospitalsQueryHandler.cs new file mode 100644 index 0000000..fab8f2f --- /dev/null +++ b/DocuMed.Repository/Handlers/Hospitals/GetHospitalsQueryHandler.cs @@ -0,0 +1,16 @@ +namespace DocuMed.Repository.Handlers.Hospitals; + +public class GetHospitalsQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler> +{ + public async Task> Handle(GetHospitalsQuery request, CancellationToken cancellationToken) + { + var response = await repositoryWrapper.SetRepository() + .TableNoTracking + .Skip(request.Page * request.Size) + .Take(request.Size) + .Select(HospitalMapper.ProjectToSDto) + .ToListAsync(cancellationToken); + + return response; + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Handlers/Hospitals/UpdateHospitalCommandHandler.cs b/DocuMed.Repository/Handlers/Hospitals/UpdateHospitalCommandHandler.cs new file mode 100644 index 0000000..2821ed0 --- /dev/null +++ b/DocuMed.Repository/Handlers/Hospitals/UpdateHospitalCommandHandler.cs @@ -0,0 +1,23 @@ +namespace DocuMed.Repository.Handlers.Hospitals; + +public class UpdateHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler +{ + + public async Task Handle(UpdateHospitalCommand request, CancellationToken cancellationToken) + { + var ent = await repositoryWrapper.SetRepository().TableNoTracking + .FirstOrDefaultAsync(h => h.Id == request.Id, cancellationToken); + if (ent == null) + throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found"); + + var newEnt = Hospital.Create(request.Name, request.Detail, request.Address, request.UniversityId); + newEnt.Id = ent.Id; + newEnt.CreatedAt = ent.CreatedAt; + newEnt.CreatedBy = ent.CreatedBy; + repositoryWrapper.SetRepository().Update(newEnt); + await repositoryWrapper.SaveChangesAsync(cancellationToken); + + return newEnt.Id; + + } +} \ No newline at end of file diff --git a/DocuMed.Repository/Migrations/20231031084330_init.Designer.cs b/DocuMed.Repository/Migrations/20231031084330_init.Designer.cs deleted file mode 100644 index b279313..0000000 --- a/DocuMed.Repository/Migrations/20231031084330_init.Designer.cs +++ /dev/null @@ -1,863 +0,0 @@ -// -using System; -using DocuMed.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 DocuMed.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20231031084330_init")] - partial class init - { - /// - 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("DocuMed.Domain.Entities.City.City", 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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Cities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Detail") - .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("UniversityId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UniversityId"); - - b.ToTable("Sections", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CityId") - .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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Universities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AddictionHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AllergyDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ChiefComplaint") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DiastolicBloodPressure") - .HasColumnType("integer"); - - b.Property("DrugHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FamilyHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FatherName") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("NationalId") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastDiseasesHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastSurgeryHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PresentIllnessDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PulseRate") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SPO2") - .HasColumnType("integer"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.Property("SystemReviewDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("SystolicBloodPressure") - .HasColumnType("integer"); - - b.Property("Temperature") - .HasColumnType("integer"); - - b.Property("VitalSignDetail") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistories", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryId"); - - b.ToTable("MedicalHistoryAnswers", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BodySystem") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("IsSign") - .HasColumnType("boolean"); - - b.Property("IsSymptom") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryTemplateId"); - - b.ToTable("MedicalHistoryQuestions", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("ChiefComplaint") - .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("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistoryTemplates", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Roles", "public"); - }); - - modelBuilder.Entity("DocuMed.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("SectionId") - .HasColumnType("uuid"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("SignUpStatus") - .HasColumnType("integer"); - - b.Property("StudentId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UniversityId") - .HasColumnType("uuid"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("SectionId"); - - b.HasIndex("UniversityId"); - - 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("DocuMed.Domain.Entities.City.Section", b => - { - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany("Sections") - .HasForeignKey("UniversityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("University"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.HasOne("DocuMed.Domain.Entities.City.City", "City") - .WithMany("Universities") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") - .WithMany("Answers") - .HasForeignKey("MedicalHistoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistory"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") - .WithMany("Questions") - .HasForeignKey("MedicalHistoryTemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistoryTemplate"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => - { - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId"); - - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany() - .HasForeignKey("UniversityId"); - - b.Navigation("Section"); - - b.Navigation("University"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => - { - b.Navigation("Universities"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Navigation("Sections"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Navigation("Answers"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Navigation("Questions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DocuMed.Repository/Migrations/20231031084330_init.cs b/DocuMed.Repository/Migrations/20231031084330_init.cs deleted file mode 100644 index 19bb292..0000000 --- a/DocuMed.Repository/Migrations/20231031084330_init.cs +++ /dev/null @@ -1,600 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DocuMed.Repository.Migrations -{ - /// - public partial class init : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "public"); - - migrationBuilder.CreateTable( - name: "Cities", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Name = table.Column(type: "text", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Cities", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Roles", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Description = table.Column(type: "text", nullable: false), - EnglishName = table.Column(type: "text", nullable: false), - PersianName = table.Column(type: "text", nullable: false), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Roles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Universities", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Name = table.Column(type: "text", nullable: false), - Address = table.Column(type: "text", nullable: false), - CityId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Universities", x => x.Id); - table.ForeignKey( - name: "FK_Universities_Cities_CityId", - column: x => x.CityId, - principalSchema: "public", - principalTable: "Cities", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "RoleClaims", - schema: "public", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "uuid", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_RoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_RoleClaims_Roles_RoleId", - column: x => x.RoleId, - principalSchema: "public", - principalTable: "Roles", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Sections", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Name = table.Column(type: "text", nullable: false), - Detail = table.Column(type: "text", nullable: false), - UniversityId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Sections", x => x.Id); - table.ForeignKey( - name: "FK_Sections_Universities_UniversityId", - column: x => x.UniversityId, - principalSchema: "public", - principalTable: "Universities", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Users", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - FirstName = table.Column(type: "text", nullable: false), - LastName = table.Column(type: "text", nullable: false), - NationalId = table.Column(type: "text", nullable: false), - StudentId = table.Column(type: "text", nullable: false), - BirthDate = table.Column(type: "timestamp without time zone", nullable: false), - Gender = table.Column(type: "integer", nullable: false), - SignUpStatus = table.Column(type: "integer", nullable: false), - UniversityId = table.Column(type: "uuid", nullable: true), - SectionId = table.Column(type: "uuid", nullable: true), - UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "boolean", nullable: false), - PasswordHash = table.Column(type: "text", nullable: true), - SecurityStamp = table.Column(type: "text", nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true), - PhoneNumber = table.Column(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column(type: "boolean", nullable: false), - LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column(type: "boolean", nullable: false), - AccessFailedCount = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - table.ForeignKey( - name: "FK_Users_Sections_SectionId", - column: x => x.SectionId, - principalSchema: "public", - principalTable: "Sections", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Users_Universities_UniversityId", - column: x => x.UniversityId, - principalSchema: "public", - principalTable: "Universities", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "Claims", - schema: "public", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "uuid", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Claims", x => x.Id); - table.ForeignKey( - name: "FK_Claims_Users_UserId", - column: x => x.UserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Logins", - schema: "public", - columns: table => new - { - LoginProvider = table.Column(type: "text", nullable: false), - ProviderKey = table.Column(type: "text", nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Logins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_Logins_Users_UserId", - column: x => x.UserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "MedicalHistories", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - ChiefComplaint = table.Column(type: "text", nullable: false), - SectionId = table.Column(type: "uuid", nullable: false), - FirstName = table.Column(type: "text", nullable: false), - LastName = table.Column(type: "text", nullable: false), - FatherName = table.Column(type: "text", nullable: false), - NationalId = table.Column(type: "text", nullable: false), - Age = table.Column(type: "integer", nullable: false), - BirthDate = table.Column(type: "timestamp without time zone", nullable: false), - PresentIllnessDetail = table.Column(type: "text", nullable: false), - PastDiseasesHistoryDetail = table.Column(type: "text", nullable: false), - PastSurgeryHistoryDetail = table.Column(type: "text", nullable: false), - FamilyHistoryDetail = table.Column(type: "text", nullable: false), - AllergyDetail = table.Column(type: "text", nullable: false), - DrugHistoryDetail = table.Column(type: "text", nullable: false), - AddictionHistoryDetail = table.Column(type: "text", nullable: false), - SystemReviewDetail = table.Column(type: "text", nullable: false), - VitalSignDetail = table.Column(type: "text", nullable: false), - SystolicBloodPressure = table.Column(type: "integer", nullable: false), - DiastolicBloodPressure = table.Column(type: "integer", nullable: false), - PulseRate = table.Column(type: "integer", nullable: false), - SPO2 = table.Column(type: "integer", nullable: false), - Temperature = table.Column(type: "integer", nullable: false), - MedicalHistoryTemplateId = table.Column(type: "uuid", nullable: false), - ApplicationUserId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MedicalHistories", x => x.Id); - table.ForeignKey( - name: "FK_MedicalHistories_Sections_SectionId", - column: x => x.SectionId, - principalSchema: "public", - principalTable: "Sections", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_MedicalHistories_Users_ApplicationUserId", - column: x => x.ApplicationUserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "MedicalHistoryTemplates", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - ChiefComplaint = table.Column(type: "text", nullable: false), - SectionId = table.Column(type: "uuid", nullable: false), - ApplicationUserId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MedicalHistoryTemplates", x => x.Id); - table.ForeignKey( - name: "FK_MedicalHistoryTemplates_Sections_SectionId", - column: x => x.SectionId, - principalSchema: "public", - principalTable: "Sections", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_MedicalHistoryTemplates_Users_ApplicationUserId", - column: x => x.ApplicationUserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Tokens", - schema: "public", - columns: table => new - { - UserId = table.Column(type: "uuid", nullable: false), - LoginProvider = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Tokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_Tokens_Users_UserId", - column: x => x.UserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "UserRoles", - schema: "public", - columns: table => new - { - UserId = table.Column(type: "uuid", nullable: false), - RoleId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_UserRoles_Roles_RoleId", - column: x => x.RoleId, - principalSchema: "public", - principalTable: "Roles", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_UserRoles_Users_UserId", - column: x => x.UserId, - principalSchema: "public", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "MedicalHistoryAnswers", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Answer = table.Column(type: "text", nullable: false), - Question = table.Column(type: "text", nullable: false), - Part = table.Column(type: "integer", nullable: false), - QuestionType = table.Column(type: "integer", nullable: false), - MedicalHistoryId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MedicalHistoryAnswers", x => x.Id); - table.ForeignKey( - name: "FK_MedicalHistoryAnswers_MedicalHistories_MedicalHistoryId", - column: x => x.MedicalHistoryId, - principalSchema: "public", - principalTable: "MedicalHistories", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "MedicalHistoryQuestions", - schema: "public", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - Question = table.Column(type: "text", nullable: false), - Part = table.Column(type: "integer", nullable: false), - QuestionType = table.Column(type: "integer", nullable: false), - BodySystem = table.Column(type: "integer", nullable: false), - IsSign = table.Column(type: "boolean", nullable: false), - IsSymptom = table.Column(type: "boolean", nullable: false), - MedicalHistoryTemplateId = table.Column(type: "uuid", nullable: false), - RemovedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedAt = table.Column(type: "timestamp without time zone", nullable: false), - CreatedBy = table.Column(type: "text", nullable: false), - IsRemoved = table.Column(type: "boolean", nullable: false), - RemovedBy = table.Column(type: "text", nullable: false), - ModifiedAt = table.Column(type: "timestamp without time zone", nullable: false), - ModifiedBy = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MedicalHistoryQuestions", x => x.Id); - table.ForeignKey( - name: "FK_MedicalHistoryQuestions_MedicalHistoryTemplates_MedicalHist~", - column: x => x.MedicalHistoryTemplateId, - principalSchema: "public", - principalTable: "MedicalHistoryTemplates", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateIndex( - name: "IX_Claims_UserId", - schema: "public", - table: "Claims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Logins_UserId", - schema: "public", - table: "Logins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistories_ApplicationUserId", - schema: "public", - table: "MedicalHistories", - column: "ApplicationUserId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistories_SectionId", - schema: "public", - table: "MedicalHistories", - column: "SectionId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistoryAnswers_MedicalHistoryId", - schema: "public", - table: "MedicalHistoryAnswers", - column: "MedicalHistoryId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistoryQuestions_MedicalHistoryTemplateId", - schema: "public", - table: "MedicalHistoryQuestions", - column: "MedicalHistoryTemplateId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistoryTemplates_ApplicationUserId", - schema: "public", - table: "MedicalHistoryTemplates", - column: "ApplicationUserId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicalHistoryTemplates_SectionId", - schema: "public", - table: "MedicalHistoryTemplates", - column: "SectionId"); - - migrationBuilder.CreateIndex( - name: "IX_RoleClaims_RoleId", - schema: "public", - table: "RoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - schema: "public", - table: "Roles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Sections_UniversityId", - schema: "public", - table: "Sections", - column: "UniversityId"); - - migrationBuilder.CreateIndex( - name: "IX_Universities_CityId", - schema: "public", - table: "Universities", - column: "CityId"); - - migrationBuilder.CreateIndex( - name: "IX_UserRoles_RoleId", - schema: "public", - table: "UserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - schema: "public", - table: "Users", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_Users_SectionId", - schema: "public", - table: "Users", - column: "SectionId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_UniversityId", - schema: "public", - table: "Users", - column: "UniversityId"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - schema: "public", - table: "Users", - column: "NormalizedUserName", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Claims", - schema: "public"); - - migrationBuilder.DropTable( - name: "Logins", - schema: "public"); - - migrationBuilder.DropTable( - name: "MedicalHistoryAnswers", - schema: "public"); - - migrationBuilder.DropTable( - name: "MedicalHistoryQuestions", - schema: "public"); - - migrationBuilder.DropTable( - name: "RoleClaims", - schema: "public"); - - migrationBuilder.DropTable( - name: "Tokens", - schema: "public"); - - migrationBuilder.DropTable( - name: "UserRoles", - schema: "public"); - - migrationBuilder.DropTable( - name: "MedicalHistories", - schema: "public"); - - migrationBuilder.DropTable( - name: "MedicalHistoryTemplates", - schema: "public"); - - migrationBuilder.DropTable( - name: "Roles", - schema: "public"); - - migrationBuilder.DropTable( - name: "Users", - schema: "public"); - - migrationBuilder.DropTable( - name: "Sections", - schema: "public"); - - migrationBuilder.DropTable( - name: "Universities", - schema: "public"); - - migrationBuilder.DropTable( - name: "Cities", - schema: "public"); - } - } -} diff --git a/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.Designer.cs b/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.Designer.cs deleted file mode 100644 index 9944ad6..0000000 --- a/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.Designer.cs +++ /dev/null @@ -1,867 +0,0 @@ -// -using System; -using DocuMed.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 DocuMed.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20231105123131_editMhAddGa")] - partial class editMhAddGa - { - /// - 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("DocuMed.Domain.Entities.City.City", 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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Cities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Detail") - .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("UniversityId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UniversityId"); - - b.ToTable("Sections", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CityId") - .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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Universities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AddictionHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AllergyDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ChiefComplaint") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DiastolicBloodPressure") - .HasColumnType("integer"); - - b.Property("DrugHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FamilyHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FatherName") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("GeneralAppearanceDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("NationalId") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastDiseasesHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastSurgeryHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PresentIllnessDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PulseRate") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SPO2") - .HasColumnType("integer"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.Property("SystemReviewDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("SystolicBloodPressure") - .HasColumnType("integer"); - - b.Property("Temperature") - .HasColumnType("integer"); - - b.Property("VitalSignDetail") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistories", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryId"); - - b.ToTable("MedicalHistoryAnswers", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BodySystem") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("IsSign") - .HasColumnType("boolean"); - - b.Property("IsSymptom") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryTemplateId"); - - b.ToTable("MedicalHistoryQuestions", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("ChiefComplaint") - .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("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistoryTemplates", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Roles", "public"); - }); - - modelBuilder.Entity("DocuMed.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("SectionId") - .HasColumnType("uuid"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("SignUpStatus") - .HasColumnType("integer"); - - b.Property("StudentId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UniversityId") - .HasColumnType("uuid"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("SectionId"); - - b.HasIndex("UniversityId"); - - 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("DocuMed.Domain.Entities.City.Section", b => - { - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany("Sections") - .HasForeignKey("UniversityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("University"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.HasOne("DocuMed.Domain.Entities.City.City", "City") - .WithMany("Universities") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") - .WithMany("Answers") - .HasForeignKey("MedicalHistoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistory"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") - .WithMany("Questions") - .HasForeignKey("MedicalHistoryTemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistoryTemplate"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => - { - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId"); - - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany() - .HasForeignKey("UniversityId"); - - b.Navigation("Section"); - - b.Navigation("University"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => - { - b.Navigation("Universities"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Navigation("Sections"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Navigation("Answers"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Navigation("Questions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.cs b/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.cs deleted file mode 100644 index 5efd6e5..0000000 --- a/DocuMed.Repository/Migrations/20231105123131_editMhAddGa.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DocuMed.Repository.Migrations -{ - /// - public partial class editMhAddGa : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "GeneralAppearanceDetail", - schema: "public", - table: "MedicalHistories", - type: "text", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "GeneralAppearanceDetail", - schema: "public", - table: "MedicalHistories"); - } - } -} diff --git a/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.Designer.cs b/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.Designer.cs deleted file mode 100644 index 6b0db50..0000000 --- a/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.Designer.cs +++ /dev/null @@ -1,867 +0,0 @@ -// -using System; -using DocuMed.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 DocuMed.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20231112120230_editMHAddDouble")] - partial class editMHAddDouble - { - /// - 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("DocuMed.Domain.Entities.City.City", 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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Cities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Detail") - .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("UniversityId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UniversityId"); - - b.ToTable("Sections", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CityId") - .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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Universities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AddictionHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AllergyDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ChiefComplaint") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DiastolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("DrugHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FamilyHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FatherName") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("GeneralAppearanceDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("NationalId") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastDiseasesHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastSurgeryHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PresentIllnessDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PulseRate") - .HasColumnType("double precision"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SPO2") - .HasColumnType("double precision"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.Property("SystemReviewDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("SystolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("Temperature") - .HasColumnType("double precision"); - - b.Property("VitalSignDetail") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistories", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryId"); - - b.ToTable("MedicalHistoryAnswers", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BodySystem") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("IsSign") - .HasColumnType("boolean"); - - b.Property("IsSymptom") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryTemplateId"); - - b.ToTable("MedicalHistoryQuestions", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("ChiefComplaint") - .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("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistoryTemplates", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Roles", "public"); - }); - - modelBuilder.Entity("DocuMed.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("SectionId") - .HasColumnType("uuid"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("SignUpStatus") - .HasColumnType("integer"); - - b.Property("StudentId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UniversityId") - .HasColumnType("uuid"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("SectionId"); - - b.HasIndex("UniversityId"); - - 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("DocuMed.Domain.Entities.City.Section", b => - { - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany("Sections") - .HasForeignKey("UniversityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("University"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.HasOne("DocuMed.Domain.Entities.City.City", "City") - .WithMany("Universities") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") - .WithMany("Answers") - .HasForeignKey("MedicalHistoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistory"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") - .WithMany("Questions") - .HasForeignKey("MedicalHistoryTemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistoryTemplate"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => - { - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId"); - - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany() - .HasForeignKey("UniversityId"); - - b.Navigation("Section"); - - b.Navigation("University"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => - { - b.Navigation("Universities"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Navigation("Sections"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Navigation("Answers"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Navigation("Questions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.cs b/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.cs deleted file mode 100644 index f890253..0000000 --- a/DocuMed.Repository/Migrations/20231112120230_editMHAddDouble.cs +++ /dev/null @@ -1,108 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DocuMed.Repository.Migrations -{ - /// - public partial class editMHAddDouble : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Temperature", - schema: "public", - table: "MedicalHistories", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "SystolicBloodPressure", - schema: "public", - table: "MedicalHistories", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "SPO2", - schema: "public", - table: "MedicalHistories", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "PulseRate", - schema: "public", - table: "MedicalHistories", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "DiastolicBloodPressure", - schema: "public", - table: "MedicalHistories", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Temperature", - schema: "public", - table: "MedicalHistories", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - - migrationBuilder.AlterColumn( - name: "SystolicBloodPressure", - schema: "public", - table: "MedicalHistories", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - - migrationBuilder.AlterColumn( - name: "SPO2", - schema: "public", - table: "MedicalHistories", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - - migrationBuilder.AlterColumn( - name: "PulseRate", - schema: "public", - table: "MedicalHistories", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - - migrationBuilder.AlterColumn( - name: "DiastolicBloodPressure", - schema: "public", - table: "MedicalHistories", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - } - } -} diff --git a/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.Designer.cs b/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.Designer.cs deleted file mode 100644 index 49697e1..0000000 --- a/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.Designer.cs +++ /dev/null @@ -1,871 +0,0 @@ -// -using System; -using DocuMed.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 DocuMed.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20231128085153_editMHAddCode")] - partial class editMHAddCode - { - /// - 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("DocuMed.Domain.Entities.City.City", 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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Cities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Detail") - .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("UniversityId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UniversityId"); - - b.ToTable("Sections", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CityId") - .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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Universities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AddictionHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AllergyDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ChiefComplaint") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DiastolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("DrugHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FamilyHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FatherName") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("GeneralAppearanceDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("NationalId") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastDiseasesHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastSurgeryHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PresentIllnessDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PulseRate") - .HasColumnType("double precision"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SPO2") - .HasColumnType("double precision"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.Property("SystemReviewDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("SystolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("Temperature") - .HasColumnType("double precision"); - - b.Property("VitalSignDetail") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistories", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryId"); - - b.ToTable("MedicalHistoryAnswers", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BodySystem") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("IsSign") - .HasColumnType("boolean"); - - b.Property("IsSymptom") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryTemplateId"); - - b.ToTable("MedicalHistoryQuestions", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("ChiefComplaint") - .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("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistoryTemplates", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Roles", "public"); - }); - - modelBuilder.Entity("DocuMed.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("SectionId") - .HasColumnType("uuid"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("SignUpStatus") - .HasColumnType("integer"); - - b.Property("StudentId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UniversityId") - .HasColumnType("uuid"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("SectionId"); - - b.HasIndex("UniversityId"); - - 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("DocuMed.Domain.Entities.City.Section", b => - { - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany("Sections") - .HasForeignKey("UniversityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("University"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.HasOne("DocuMed.Domain.Entities.City.City", "City") - .WithMany("Universities") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") - .WithMany("Answers") - .HasForeignKey("MedicalHistoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistory"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") - .WithMany("Questions") - .HasForeignKey("MedicalHistoryTemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistoryTemplate"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => - { - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId"); - - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany() - .HasForeignKey("UniversityId"); - - b.Navigation("Section"); - - b.Navigation("University"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => - { - b.Navigation("Universities"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Navigation("Sections"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Navigation("Answers"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Navigation("Questions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.cs b/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.cs deleted file mode 100644 index 3805260..0000000 --- a/DocuMed.Repository/Migrations/20231128085153_editMHAddCode.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DocuMed.Repository.Migrations -{ - /// - public partial class editMHAddCode : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Code", - schema: "public", - table: "MedicalHistories", - type: "text", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Code", - schema: "public", - table: "MedicalHistories"); - } - } -} diff --git a/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs b/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs deleted file mode 100644 index 92e2677..0000000 --- a/DocuMed.Repository/Migrations/ApplicationContextModelSnapshot.cs +++ /dev/null @@ -1,868 +0,0 @@ -// -using System; -using DocuMed.Repository.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DocuMed.Repository.Migrations -{ - [DbContext(typeof(ApplicationContext))] - partial class ApplicationContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("public") - .HasAnnotation("ProductVersion", "7.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", 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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Cities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Detail") - .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("UniversityId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("UniversityId"); - - b.ToTable("Sections", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Address") - .IsRequired() - .HasColumnType("text"); - - b.Property("CityId") - .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("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("CityId"); - - b.ToTable("Universities", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("AddictionHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("Age") - .HasColumnType("integer"); - - b.Property("AllergyDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("BirthDate") - .HasColumnType("timestamp without time zone"); - - b.Property("ChiefComplaint") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("DiastolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("DrugHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FamilyHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("FatherName") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("GeneralAppearanceDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("NationalId") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastDiseasesHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PastSurgeryHistoryDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PresentIllnessDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("PulseRate") - .HasColumnType("double precision"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SPO2") - .HasColumnType("double precision"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.Property("SystemReviewDetail") - .IsRequired() - .HasColumnType("text"); - - b.Property("SystolicBloodPressure") - .HasColumnType("double precision"); - - b.Property("Temperature") - .HasColumnType("double precision"); - - b.Property("VitalSignDetail") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistories", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryId"); - - b.ToTable("MedicalHistoryAnswers", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("BodySystem") - .HasColumnType("integer"); - - b.Property("CreatedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("CreatedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsRemoved") - .HasColumnType("boolean"); - - b.Property("IsSign") - .HasColumnType("boolean"); - - b.Property("IsSymptom") - .HasColumnType("boolean"); - - b.Property("MedicalHistoryTemplateId") - .HasColumnType("uuid"); - - b.Property("ModifiedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("ModifiedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("Part") - .HasColumnType("integer"); - - b.Property("Question") - .IsRequired() - .HasColumnType("text"); - - b.Property("QuestionType") - .HasColumnType("integer"); - - b.Property("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("MedicalHistoryTemplateId"); - - b.ToTable("MedicalHistoryQuestions", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("ApplicationUserId") - .HasColumnType("uuid"); - - b.Property("ChiefComplaint") - .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("RemovedAt") - .HasColumnType("timestamp without time zone"); - - b.Property("RemovedBy") - .IsRequired() - .HasColumnType("text"); - - b.Property("SectionId") - .HasColumnType("uuid"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("SectionId"); - - b.ToTable("MedicalHistoryTemplates", "public"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Roles", "public"); - }); - - modelBuilder.Entity("DocuMed.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("SectionId") - .HasColumnType("uuid"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("SignUpStatus") - .HasColumnType("integer"); - - b.Property("StudentId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UniversityId") - .HasColumnType("uuid"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.HasIndex("SectionId"); - - b.HasIndex("UniversityId"); - - 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("DocuMed.Domain.Entities.City.Section", b => - { - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany("Sections") - .HasForeignKey("UniversityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("University"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.HasOne("DocuMed.Domain.Entities.City.City", "City") - .WithMany("Universities") - .HasForeignKey("CityId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("City"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistoryAnswer", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", "MedicalHistory") - .WithMany("Answers") - .HasForeignKey("MedicalHistoryId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistory"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b => - { - b.HasOne("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", "MedicalHistoryTemplate") - .WithMany("Questions") - .HasForeignKey("MedicalHistoryTemplateId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("MedicalHistoryTemplate"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Section"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.User.ApplicationUser", b => - { - b.HasOne("DocuMed.Domain.Entities.City.Section", "Section") - .WithMany() - .HasForeignKey("SectionId"); - - b.HasOne("DocuMed.Domain.Entities.City.University", "University") - .WithMany() - .HasForeignKey("UniversityId"); - - b.Navigation("Section"); - - b.Navigation("University"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.City", b => - { - b.Navigation("Universities"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b => - { - b.Navigation("Sections"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b => - { - b.Navigation("Answers"); - }); - - modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b => - { - b.Navigation("Questions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/DocuMed.Repository/Models/ApplicationContext.cs b/DocuMed.Repository/Models/ApplicationContext.cs index 065bf31..8894788 100644 --- a/DocuMed.Repository/Models/ApplicationContext.cs +++ b/DocuMed.Repository/Models/ApplicationContext.cs @@ -1,15 +1,9 @@ namespace DocuMed.Repository.Models; -public class ApplicationContext : IdentityDbContext +public class ApplicationContext(DbContextOptions options, ILogger logger) + : IdentityDbContext(options) { - private readonly ILogger _logger; - private readonly Assembly _projectAssembly; - - public ApplicationContext( DbContextOptions options, ILogger logger): base(options) - { - _logger = logger; - _projectAssembly = options.GetExtension().ProjectAssembly; - } + private readonly Assembly _projectAssembly = options.GetExtension().ProjectAssembly; protected override void OnModelCreating(ModelBuilder builder) @@ -18,9 +12,9 @@ public class ApplicationContext : IdentityDbContext(_logger, entitiesAssembly); + builder.RegisterAllEntities(logger, entitiesAssembly); stopwatch.Stop(); - _logger.LogInformation($"!!!!!!! RegisterAllEntities : {stopwatch.ElapsedMilliseconds}ms !!!!!!!"); + logger.LogInformation($"!!!!!!! RegisterAllEntities : {stopwatch.ElapsedMilliseconds}ms !!!!!!!"); RenameIdentityTables(builder); diff --git a/DocuMed.Repository/Repositories/Base/BaseRepository.cs b/DocuMed.Repository/Repositories/Base/BaseRepository.cs index d3f8bd7..2d0c71b 100644 --- a/DocuMed.Repository/Repositories/Base/BaseRepository.cs +++ b/DocuMed.Repository/Repositories/Base/BaseRepository.cs @@ -2,14 +2,11 @@ namespace DocuMed.Repository.Repositories.Base { - public class BaseRepository : Repository, IBaseRepository where T : class, IApiEntity + public class BaseRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) + : Repository(dbContext), IBaseRepository + where T : class, IApiEntity { - protected readonly ICurrentUserService CurrentUserService; - - public BaseRepository(ApplicationContext dbContext,ICurrentUserService currentUserService) : base(dbContext) - { - CurrentUserService = currentUserService; - } + protected readonly ICurrentUserService CurrentUserService = currentUserService; public virtual async ValueTask GetByIdAsync(CancellationToken cancellationToken, params object[] ids) { diff --git a/DocuMed.Repository/Repositories/Base/ReadRepository.cs b/DocuMed.Repository/Repositories/Base/ReadRepository.cs index 9cec778..3a26f45 100644 --- a/DocuMed.Repository/Repositories/Base/ReadRepository.cs +++ b/DocuMed.Repository/Repositories/Base/ReadRepository.cs @@ -1,12 +1,9 @@ namespace DocuMed.Repository.Repositories.Base { - public class ReadRepository : Repository, IDisposable, IReadRepository where T : class, IApiEntity + public class ReadRepository(ApplicationContext dbContext) + : Repository(dbContext), IDisposable, IReadRepository + where T : class, IApiEntity { - public ReadRepository( - ApplicationContext dbContext) : base(dbContext) - { - } - public void Dispose() { DbContext?.Dispose(); diff --git a/DocuMed.Repository/Repositories/Base/RepositoryWrapper.cs b/DocuMed.Repository/Repositories/Base/RepositoryWrapper.cs index dfcbbe4..38511e7 100644 --- a/DocuMed.Repository/Repositories/Base/RepositoryWrapper.cs +++ b/DocuMed.Repository/Repositories/Base/RepositoryWrapper.cs @@ -1,16 +1,10 @@ namespace DocuMed.Repository.Repositories.Base; -public class RepositoryWrapper : IRepositoryWrapper +public class RepositoryWrapper(ApplicationContext context, ICurrentUserService currentUserService) + : IRepositoryWrapper { - private readonly ApplicationContext _context; - private readonly ICurrentUserService _currentUserService; private IDbContextTransaction? _currentTransaction; - public RepositoryWrapper(ApplicationContext context,ICurrentUserService currentUserService) - { - _context = context; - _currentUserService = currentUserService; - } - public IBaseRepository SetRepository() where T : ApiEntity => new BaseRepository(_context, _currentUserService); + public IBaseRepository SetRepository() where T : ApiEntity => new BaseRepository(context, currentUserService); public async Task RollBackAsync(CancellationToken cancellationToken) @@ -27,26 +21,26 @@ public class RepositoryWrapper : IRepositoryWrapper } public async Task BeginTransaction(CancellationToken cancellationToken) { - _currentTransaction = await _context.Database.BeginTransactionAsync(cancellationToken); + _currentTransaction = await context.Database.BeginTransactionAsync(cancellationToken); } public async Task SaveChangesAsync(CancellationToken cancellationToken = default) { SetAuditables(); - await _context.SaveChangesAsync(cancellationToken); + await context.SaveChangesAsync(cancellationToken); } private void SetAuditables() { - IEnumerable> entries = _context.ChangeTracker.Entries(); + IEnumerable> entries = context.ChangeTracker.Entries(); foreach (EntityEntry entity in entries) { if (entity.State == EntityState.Added) { entity.Property(e => e.CreatedAt) .CurrentValue = DateTime.Now; - if (_currentUserService.UserName != null) + if (currentUserService.UserName != null) entity.Property(e => e.CreatedBy) - .CurrentValue = _currentUserService.UserName; + .CurrentValue = currentUserService.UserName; } if (entity.State == EntityState.Modified) @@ -55,9 +49,9 @@ public class RepositoryWrapper : IRepositoryWrapper { entity.Property(e => e.ModifiedAt) .CurrentValue = DateTime.Now; - if (_currentUserService.UserName != null) + if (currentUserService.UserName != null) entity.Property(e => e.ModifiedBy) - .CurrentValue = _currentUserService.UserName; + .CurrentValue = currentUserService.UserName; } } } @@ -65,6 +59,6 @@ public class RepositoryWrapper : IRepositoryWrapper public void Dispose() { _currentTransaction?.Dispose(); - _context?.Dispose(); + context?.Dispose(); } } diff --git a/DocuMed.Repository/Repositories/Base/WriteRepository.cs b/DocuMed.Repository/Repositories/Base/WriteRepository.cs index 534dcd7..a5e4f48 100644 --- a/DocuMed.Repository/Repositories/Base/WriteRepository.cs +++ b/DocuMed.Repository/Repositories/Base/WriteRepository.cs @@ -1,11 +1,9 @@ namespace DocuMed.Repository.Repositories.Base { - public class WriteRepository : Repository, IDisposable, IWriteRepository where T : class, IApiEntity + public class WriteRepository(ApplicationContext dbContext) + : Repository(dbContext), IDisposable, IWriteRepository + where T : class, IApiEntity { - public WriteRepository(ApplicationContext dbContext) : base(dbContext) - { - } - public void Dispose() { DbContext?.Dispose(); diff --git a/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs index de616c5..7b4a282 100644 --- a/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs +++ b/DocuMed.Repository/Repositories/Entities/MedicalHistoryRepository.cs @@ -1,11 +1,8 @@ namespace DocuMed.Repository.Repositories.Entities; -public class MedicalHistoryRepository : BaseRepository,IMedicalHistoryRepository +public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) + : BaseRepository(dbContext, currentUserService), IMedicalHistoryRepository { - public MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService) - { - } - public async Task> GetMedicalHistoriesAsync(int page = 0, CancellationToken cancellationToken = default) { if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) diff --git a/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs b/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs index 722c2b2..48487bd 100644 --- a/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs +++ b/DocuMed.Repository/Repositories/Entities/MedicalHistoryTemplateRepository.cs @@ -1,11 +1,8 @@ namespace DocuMed.Repository.Repositories.Entities; -public class MedicalHistoryTemplateRepository : BaseRepository, IMedicalHistoryTemplateRepository +public class MedicalHistoryTemplateRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) + : BaseRepository(dbContext, currentUserService), IMedicalHistoryTemplateRepository { - public MedicalHistoryTemplateRepository(ApplicationContext dbContext,ICurrentUserService currentUserService) : base(dbContext,currentUserService) - { - } - public async Task> GetMedicalHistoryTemplatesAsync(int page = 0, CancellationToken cancellationToken = default) { if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) diff --git a/DocuMed.Repository/Repositories/UnitOfWork/UnitOfWork.cs b/DocuMed.Repository/Repositories/UnitOfWork/UnitOfWork.cs index 26d4451..c28e4b8 100644 --- a/DocuMed.Repository/Repositories/UnitOfWork/UnitOfWork.cs +++ b/DocuMed.Repository/Repositories/UnitOfWork/UnitOfWork.cs @@ -1,13 +1,8 @@ namespace DocuMed.Repository.Repositories.UnitOfWork; -public class UnitOfWork : IUnitOfWork +public class UnitOfWork(ApplicationContext applicationContext) : IUnitOfWork { - private readonly ApplicationContext _applicationContext; private IDbContextTransaction? _currentTransaction ; - public UnitOfWork(ApplicationContext applicationContext) - { - _applicationContext = applicationContext; - } public async Task RollBackAsync() { @@ -23,17 +18,17 @@ public class UnitOfWork : IUnitOfWork } public async Task BeginTransaction() { - _currentTransaction = await _applicationContext.Database.BeginTransactionAsync(); + _currentTransaction = await applicationContext.Database.BeginTransactionAsync(); } public async Task SaveChangesAsync(CancellationToken cancellationToken = default) { SetAuditables(); - await _applicationContext.SaveChangesAsync(cancellationToken); + await applicationContext.SaveChangesAsync(cancellationToken); } private void SetAuditables() { - IEnumerable> entries = _applicationContext.ChangeTracker.Entries(); + IEnumerable> entries = applicationContext.ChangeTracker.Entries(); foreach (EntityEntry entity in entries) { if (entity.State == EntityState.Added) diff --git a/DocuMed.Repository/Services/DbInitializerService.cs b/DocuMed.Repository/Services/DbInitializerService.cs index 3c6cff0..469b46e 100644 --- a/DocuMed.Repository/Services/DbInitializerService.cs +++ b/DocuMed.Repository/Services/DbInitializerService.cs @@ -1,37 +1,23 @@ namespace DocuMed.Repository.Services; -public class DbInitializerService : IDbInitializerService +public class DbInitializerService( + ApplicationContext context, + RoleManager roleManager, + UserManager userManager, + IOptionsSnapshot adminUserSeedOptions, + ILogger logger) + : IDbInitializerService { - private readonly IOptionsSnapshot _adminUserSeedOptions; - private readonly ApplicationContext _context; - private readonly ILogger _logger; - private readonly RoleManager _roleManager; - private readonly UserManager _userManager; - - public DbInitializerService( - ApplicationContext context, - RoleManager roleManager, - UserManager userManager, - IOptionsSnapshot adminUserSeedOptions, - ILogger logger) - { - _context = context; - _roleManager = roleManager; - _userManager = userManager; - _adminUserSeedOptions = adminUserSeedOptions; - _logger = logger; - } - public void Initialize() { try { - _context.Database.Migrate(); - _logger.LogInformation("Migration SUCCESS !!!!"); + context.Database.Migrate(); + logger.LogInformation("Migration SUCCESS !!!!"); } catch (Exception e) { - _logger.LogError(e, e.Message); + logger.LogError(e, e.Message); } } @@ -41,8 +27,8 @@ public class DbInitializerService : IDbInitializerService { await SeedRoles(); - var seedAdmin = _adminUserSeedOptions.Value.UserSetting; - var user = await _userManager.FindByNameAsync(seedAdmin.Username); + var seedAdmin = adminUserSeedOptions.Value.UserSetting; + var user = await userManager.FindByNameAsync(seedAdmin.Username); if (user == null) { var adminUser = new ApplicationUser @@ -58,8 +44,8 @@ public class DbInitializerService : IDbInitializerService PhoneNumber = seedAdmin.Phone, BirthDate = DateTime.Now.AddYears(-23) }; - var adminUserResult = await _userManager.CreateAsync(adminUser, seedAdmin.Password); - if (adminUserResult.Succeeded) await _userManager.AddToRoleAsync(adminUser, seedAdmin.RoleName); + var adminUserResult = await userManager.CreateAsync(adminUser, seedAdmin.Password); + if (adminUserResult.Succeeded) await userManager.AddToRoleAsync(adminUser, seedAdmin.RoleName); } } catch (Exception e) @@ -71,8 +57,8 @@ public class DbInitializerService : IDbInitializerService public async Task SeedRoles() { - var seedAdmin = _adminUserSeedOptions.Value.UserSetting; - var managerRole = await _roleManager.FindByNameAsync(seedAdmin.RoleName); + var seedAdmin = adminUserSeedOptions.Value.UserSetting; + var managerRole = await roleManager.FindByNameAsync(seedAdmin.RoleName); if (managerRole == null) { @@ -82,9 +68,9 @@ public class DbInitializerService : IDbInitializerService EnglishName = seedAdmin.RoleName, Description = "root admin role" }; - var adminRoleResult = await _roleManager.CreateAsync(managerRole); + var adminRoleResult = await roleManager.CreateAsync(managerRole); foreach (var claim in ApplicationClaims.AllClaims) - await _roleManager.AddClaimAsync(managerRole, claim); + await roleManager.AddClaimAsync(managerRole, claim); } } } \ No newline at end of file