Compare commits

..

No commits in common. "b3ca3c51ea14b0b0bf32b500dd188f5a298f430b" and "1ceb063d14eb80fd1484b3375c83f80b225acf9d" have entirely different histories.

96 changed files with 7024 additions and 2289 deletions

View File

@ -1,65 +0,0 @@
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<IResult> 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<IResult> GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken)
{
return TypedResults.Ok(await repository.GetMedicalHistoryAsync(id, cancellationToken));
}
// POST:Add New Entity
public virtual async Task<IResult> 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<IResult> 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<IResult> Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<MedicalHistory>().GetByIdAsync(cancellationToken, id);
repositoryWrapper.SetRepository<MedicalHistory>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
}

View File

@ -1,6 +1,4 @@
using DocuMed.Domain.CommandQueries.Commands; using DocuMed.Domain.Entities.MedicalHistory;
using DocuMed.Domain.Entities.MedicalHistory;
using MediatR;
namespace DocuMed.Api.Controllers; namespace DocuMed.Api.Controllers;
public class MedicalHistoryController : ICarterModule public class MedicalHistoryController : ICarterModule
@ -36,25 +34,41 @@ public class MedicalHistoryController : ICarterModule
// GET:Get All Entity // GET:Get All Entity
public virtual async Task<IResult> GetAllByFilterAsync([FromQuery]DayQueryFilter dayQuery,[FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken) public virtual async Task<IResult> GetAllByFilterAsync([FromQuery]DayQueryFilter dayQuery,[FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken)
=> TypedResults.Ok(await repository.GetMedicalHistoriesByFilterAsync(dayQuery, page, cancellationToken)); {
return TypedResults.Ok(await repository.GetMedicalHistoriesByFilterAsync(dayQuery , page, cancellationToken));
}
// GET:Get All Entity // GET:Get All Entity
public virtual async Task<IResult> GetAllAsync([FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken) public virtual async Task<IResult> GetAllAsync([FromQuery] int page, IMedicalHistoryRepository repository, CancellationToken cancellationToken)
=> TypedResults.Ok(await repository.GetMedicalHistoriesAsync(page, cancellationToken)); {
return TypedResults.Ok(await repository.GetMedicalHistoriesAsync(page, cancellationToken));
}
// GET:Get An Entity By Id // GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken) public async Task<IResult> GetAsync(Guid id, IMedicalHistoryRepository repository, CancellationToken cancellationToken)
=> TypedResults.Ok(await repository.GetMedicalHistoryAsync(id, cancellationToken)); {
return TypedResults.Ok(await repository.GetMedicalHistoryAsync(id, cancellationToken));
}
// POST:Add New Entity // POST:Add New Entity
public virtual async Task<IResult> Post([FromBody] CreateMedicalHistoryCommand dto, IMediator service, ICurrentUserService currentUserService, CancellationToken cancellationToken) public virtual async Task<IResult> Post([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken)
=> TypedResults.Ok(await service.Send(dto, cancellationToken)); {
return TypedResults.Ok(await service.AddAsync(dto, cancellationToken));
}
// PUT:Update Entity // PUT:Update Entity
public virtual async Task<IResult> Put([FromBody] UpdateMedicalHistoryCommand dto, IMediator service, ICurrentUserService currentUserService, CancellationToken cancellationToken) public virtual async Task<IResult> Put([FromBody] MedicalHistoryLDto dto, IMedicalHistoryService service, ICurrentUserService currentUserService, CancellationToken cancellationToken)
=> TypedResults.Ok(await service.Send(dto, cancellationToken)); {
return TypedResults.Ok(await service.EditAsync(dto, cancellationToken));
}
// DELETE:Delete Entity // DELETE:Delete Entity
public virtual async Task<IResult> Delete(Guid id, IMediator mediator, CancellationToken cancellationToken) public virtual async Task<IResult> Delete(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await mediator.Send(new DeleteMedicalHistoryCommand(id), cancellationToken)); {
var ent = await repositoryWrapper.SetRepository<MedicalHistory>().GetByIdAsync(cancellationToken, id);
repositoryWrapper.SetRepository<MedicalHistory>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok();
}
} }

View File

@ -1,18 +1,19 @@
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.Api.Controllers; namespace DocuMed.Api.Controllers;
public class SectionController : ICarterModule public class SectionController : ICarterModule
{ {
public virtual void AddRoutes(IEndpointRouteBuilder app) 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) group.MapGet("", GetAllAsync)
.WithDisplayName("GetAll") .WithDisplayName("GetAll")
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("University/{universityId}", GetAllByUniversityAsync)
.WithDisplayName("GetAllByUniversityId")
.HasApiVersion(1.0);
group.MapGet("{id}", GetAsync) group.MapGet("{id}", GetAsync)
.WithDisplayName("GetOne") .WithDisplayName("GetOne")
@ -36,6 +37,13 @@ public class SectionController : ICarterModule
.Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken)); .Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken));
} }
// GET:Get All Entity
public virtual async Task<IResult> GetAllByUniversityAsync(Guid universityId, IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, CancellationToken cancellationToken)
{
return TypedResults.Ok(await repositoryWrapper.SetRepository<Section>().TableNoTracking
.Where(s => s.UniversityId == universityId)
.Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken));
}
// GET:Get An Entity By Id // GET:Get An Entity By Id
public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public async Task<IResult> GetAsync(Guid id, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
@ -45,7 +53,7 @@ public class SectionController : ICarterModule
// POST:Add New Entity // POST:Add New Entity
public virtual async Task<IResult> Post([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public virtual async Task<IResult> Post([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{ {
var ent = Section.Create(dto.Name,dto.Detail,dto.HospitalId); var ent = Section.Create(dto.Name,dto.Detail,dto.UniversityId);
repositoryWrapper.SetRepository<Section>().Add(ent); repositoryWrapper.SetRepository<Section>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
return TypedResults.Ok(ent); return TypedResults.Ok(ent);
@ -54,7 +62,7 @@ public class SectionController : ICarterModule
// PUT:Update Entity // PUT:Update Entity
public virtual async Task<IResult> Put([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public virtual async Task<IResult> Put([FromBody] SectionSDto dto, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
{ {
var ent = Section.Create(dto.Name,dto.Detail, dto.HospitalId); var ent = Section.Create(dto.Name,dto.Detail, dto.UniversityId);
ent.Id = dto.Id; ent.Id = dto.Id;
repositoryWrapper.SetRepository<Section>().Update(ent); repositoryWrapper.SetRepository<Section>().Update(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);

View File

@ -1,6 +1,4 @@
using DocuMed.Domain.Entities.Hospitals; namespace DocuMed.Api.Controllers;
namespace DocuMed.Api.Controllers;
public class UniversityController : ICarterModule public class UniversityController : ICarterModule
{ {
@ -11,15 +9,11 @@ public class UniversityController : ICarterModule
.MapGroup($"api/university"); .MapGroup($"api/university");
group.MapGet("", GetAllAsync) group.MapGet("", GetAllAsync)
.WithDisplayName("Get All") .WithDisplayName("GetAll")
.HasApiVersion(1.0);
group.MapGet("{id}/section", GetAllByUniversityAsync)
.WithDisplayName("Get All Sections")
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapGet("{id}", GetAsync) group.MapGet("{id}", GetAsync)
.WithDisplayName("Get One") .WithDisplayName("GetOne")
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapPost("", Post) group.MapPost("", Post)
@ -33,14 +27,6 @@ public class UniversityController : ICarterModule
} }
// GET:Get All Sections
public virtual async Task<IResult> GetAllByUniversityAsync(Guid id, IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, CancellationToken cancellationToken)
{
return TypedResults.Ok(await repositoryWrapper.SetRepository<Section>().TableNoTracking
.Where(s => s.HospitalId == id)
.Select(SectionMapper.ProjectToSDto).ToListAsync(cancellationToken));
}
// GET:Get All Entity // GET:Get All Entity
public virtual async Task<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken) public virtual async Task<IResult> GetAllAsync([FromQuery] int page, IRepositoryWrapper repositoryWrapper, CancellationToken cancellationToken)
=> TypedResults.Ok(await repositoryWrapper.SetRepository<University>() => TypedResults.Ok(await repositoryWrapper.SetRepository<University>()

View File

@ -1 +0,0 @@
c777781b-a540-4f02-854f-d0412869e3eb

View File

@ -1,10 +1,16 @@
namespace DocuMed.Api.Services; namespace DocuMed.Api.Services;
public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService public class CurrentUserService : ICurrentUserService
{ {
public string? UserId => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier); private readonly IHttpContextAccessor _httpContextAccessor;
public string? RoleName => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Role);
public string? UserName => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.Name); public CurrentUserService(IHttpContextAccessor httpContextAccessor)
public string? UniversityId => httpContextAccessor.HttpContext?.User?.FindFirstValue("UniversityId"); {
public string? HospitalId => httpContextAccessor.HttpContext?.User?.FindFirstValue("HospitalId"); _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");
} }

View File

@ -0,0 +1,13 @@
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; }
}
}

View File

@ -7,13 +7,18 @@ using Microsoft.EntityFrameworkCore;
namespace DocuMed.Api.WebFramework.Bases; namespace DocuMed.Api.WebFramework.Bases;
public class CrudEndpoint<TEntity, TGetAllQuery, TGetOneQuery, TCreateCommand, TUpdateCommand, TDeleteCommand>( public class CrudEndpoint<TEntity,TGetAllQuery,TGetOneQuery,TCreateCommand,TUpdateCommand,TDeleteCommand> where TEntity : ApiEntity, new()
string endpointName)
where TEntity : ApiEntity, new()
{ {
private readonly string _endpointName;
public CrudEndpoint(string endpointName)
{
_endpointName = endpointName;
}
public virtual void AddRoutes(IEndpointRouteBuilder app) 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) group.MapGet("", GetAllAsync)
.WithDisplayName("GetAll") .WithDisplayName("GetAll")
@ -69,12 +74,18 @@ public class CrudEndpoint<TEntity, TGetAllQuery, TGetOneQuery, TCreateCommand, T
} }
public class CrudEndpoint<TEntity>(string endpointName) public class CrudEndpoint<TEntity> where TEntity : ApiEntity, new()
where TEntity : ApiEntity, new()
{ {
private readonly string _endpointName;
public CrudEndpoint(string endpointName)
{
_endpointName = endpointName;
}
public virtual void AddRoutes(IEndpointRouteBuilder app) 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) group.MapGet("", GetAllAsync)
.WithDisplayName("GetAll") .WithDisplayName("GetAll")
@ -140,11 +151,16 @@ public class BaseController : ControllerBase
} }
[Authorize(AuthenticationSchemes = "Bearer")] [Authorize(AuthenticationSchemes = "Bearer")]
public class CrudController<TDto, TEntity>(IRepositoryWrapper repositoryWrapper) : BaseController public class CrudController<TDto, TEntity> : BaseController
where TDto : BaseDto<TDto, TEntity>, new() where TDto : BaseDto<TDto, TEntity>, new()
where TEntity : ApiEntity, new() where TEntity : ApiEntity, new()
{ {
protected readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; protected readonly IRepositoryWrapper _repositoryWrapper;
public CrudController(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
// GET:Get All Entity // GET:Get All Entity
[HttpGet] [HttpGet]
@ -220,10 +236,15 @@ public class CrudController<TDto, TEntity>(IRepositoryWrapper repositoryWrapper)
} }
[Authorize(AuthenticationSchemes = "Bearer")] [Authorize(AuthenticationSchemes = "Bearer")]
public class CrudController<TEntity>(IRepositoryWrapper repositoryWrapper) : BaseController public class CrudController<TEntity> : BaseController
where TEntity : ApiEntity, new() where TEntity : ApiEntity, new()
{ {
protected readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; protected readonly IRepositoryWrapper _repositoryWrapper;
public CrudController(IRepositoryWrapper repositoryWrapper)
{
_repositoryWrapper = repositoryWrapper;
}
// GET:Get All Entity // GET:Get All Entity
[HttpGet] [HttpGet]

View File

@ -15,11 +15,22 @@ public static class ExceptionHandlerMiddlewareExtensions
} }
} }
public class ExceptionHandlerMiddleware( public class ExceptionHandlerMiddleware
RequestDelegate next,
IWebHostEnvironment env,
ILogger<ExceptionHandlerMiddleware> logger)
{ {
private readonly IWebHostEnvironment _env;
private readonly ILogger<ExceptionHandlerMiddleware> _logger;
private readonly RequestDelegate _next;
public ExceptionHandlerMiddleware(
RequestDelegate next,
IWebHostEnvironment env,
ILogger<ExceptionHandlerMiddleware> logger)
{
_next = next;
_env = env;
_logger = logger;
}
public async Task Invoke(HttpContext context) public async Task Invoke(HttpContext context)
{ {
string message = null; string message = null;
@ -28,15 +39,15 @@ public class ExceptionHandlerMiddleware(
try try
{ {
await next(context); await _next(context);
} }
catch (BaseApiException exception) catch (BaseApiException exception)
{ {
logger.LogError(exception, exception.Message); _logger.LogError(exception, exception.Message);
httpStatusCode = exception.HttpStatusCode; httpStatusCode = exception.HttpStatusCode;
apiStatusCode = exception.ApiStatusCode; apiStatusCode = exception.ApiStatusCode;
if (env.IsDevelopment()) if (_env.IsDevelopment())
{ {
var dic = new Dictionary<string, string> var dic = new Dictionary<string, string>
{ {
@ -73,22 +84,22 @@ public class ExceptionHandlerMiddleware(
} }
catch (SecurityTokenExpiredException exception) catch (SecurityTokenExpiredException exception)
{ {
logger.LogError(exception, exception.Message); _logger.LogError(exception, exception.Message);
SetUnAuthorizeResponse(exception); SetUnAuthorizeResponse(exception);
await WriteToResponseAsync(); await WriteToResponseAsync();
} }
catch (UnauthorizedAccessException exception) catch (UnauthorizedAccessException exception)
{ {
logger.LogError(exception, exception.Message); _logger.LogError(exception, exception.Message);
SetUnAuthorizeResponse(exception); SetUnAuthorizeResponse(exception);
await WriteToResponseAsync(); await WriteToResponseAsync();
} }
catch (Exception exception) catch (Exception exception)
{ {
logger.LogError(exception, exception.Message); _logger.LogError(exception, exception.Message);
if (env.IsDevelopment()) if (_env.IsDevelopment())
{ {
var dic = new Dictionary<string, string> var dic = new Dictionary<string, string>
{ {
@ -157,7 +168,7 @@ public class ExceptionHandlerMiddleware(
httpStatusCode = HttpStatusCode.Unauthorized; httpStatusCode = HttpStatusCode.Unauthorized;
apiStatusCode = ApiResultStatusCode.UnAuthorized; apiStatusCode = ApiResultStatusCode.UnAuthorized;
if (env.IsDevelopment()) if (_env.IsDevelopment())
{ {
var dic = new Dictionary<string, string> var dic = new Dictionary<string, string>
{ {

View File

@ -10,19 +10,28 @@ public static class PerformanceMiddlewareExtensions
} }
} }
public class PerformanceMiddleware( public class PerformanceMiddleware
RequestDelegate next,
ILogger<ExceptionHandlerMiddleware> logger)
{ {
private readonly Stopwatch _timer = new(); private readonly ILogger<ExceptionHandlerMiddleware> _logger;
private readonly RequestDelegate _next;
private readonly Stopwatch _timer;
public PerformanceMiddleware(
RequestDelegate next,
ILogger<ExceptionHandlerMiddleware> logger)
{
_next = next;
_logger = logger;
_timer = new Stopwatch();
}
public async System.Threading.Tasks.Task Invoke(HttpContext context) public async System.Threading.Tasks.Task Invoke(HttpContext context)
{ {
_timer.Start(); _timer.Start();
await next(context); await _next(context);
_timer.Stop(); _timer.Stop();
var elapsedMilliseconds = _timer.ElapsedMilliseconds; var elapsedMilliseconds = _timer.ElapsedMilliseconds;
logger.LogWarning($"REQUEST TIMER : {elapsedMilliseconds}"); _logger.LogWarning($"REQUEST TIMER : {elapsedMilliseconds}");
} }
} }

View File

@ -139,12 +139,17 @@ public class SetVersionInPaths : IDocumentFilter
} }
} }
public class UnauthorizedResponsesOperationFilter( public class UnauthorizedResponsesOperationFilter : IOperationFilter
bool includeUnauthorizedAndForbiddenResponses,
string schemeName = "Bearer")
: IOperationFilter
{ {
private readonly string schemeName = schemeName; private readonly bool includeUnauthorizedAndForbiddenResponses;
private readonly string schemeName;
public UnauthorizedResponsesOperationFilter(bool includeUnauthorizedAndForbiddenResponses,
string schemeName = "Bearer")
{
this.includeUnauthorizedAndForbiddenResponses = includeUnauthorizedAndForbiddenResponses;
this.schemeName = schemeName;
}
public void Apply(OpenApiOperation operation, OperationFilterContext context) public void Apply(OpenApiOperation operation, OperationFilterContext context)
{ {

View File

@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -11,9 +11,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
</ItemGroup> </ItemGroup>-->
<!--<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -25,7 +25,7 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.0" />
</ItemGroup>--> </ItemGroup>
<ItemGroup> <ItemGroup>
<Using Include="MD.PersianDateTime.Standard" /> <Using Include="MD.PersianDateTime.Standard" />

View File

@ -5,14 +5,21 @@ using System.Text;
namespace DocuMed.Core.BaseServices; namespace DocuMed.Core.BaseServices;
public class JwtService( public class JwtService : IJwtService
IOptionsSnapshot<SiteSettings> siteSettings,
SignInManager<ApplicationUser> userSignInManager,
RoleManager<ApplicationRole> roleManager)
: IJwtService
{ {
private readonly SiteSettings _siteSettings = siteSettings.Value; private readonly SignInManager<ApplicationUser> _signInManager;
private readonly RoleManager<ApplicationRole> _roleManager;
private readonly SiteSettings _siteSettings;
public JwtService(
IOptionsSnapshot<SiteSettings> siteSettings,
SignInManager<ApplicationUser> userSignInManager,
RoleManager<ApplicationRole> roleManager)
{
_signInManager = userSignInManager;
_roleManager = roleManager;
_siteSettings = siteSettings.Value;
}
public async Task<AccessToken<TUser>> Generate<TUser>(TUser user) where TUser : ApplicationUser public async Task<AccessToken<TUser>> Generate<TUser>(TUser user) where TUser : ApplicationUser
{ {
var tokenId = StringExtensions.GetId(8); var tokenId = StringExtensions.GetId(8);
@ -75,13 +82,15 @@ public class JwtService(
private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId) where TUser : ApplicationUser private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId) where TUser : ApplicationUser
{ {
var clFac = (await userSignInManager.ClaimsFactory.CreateAsync(baseUser)); var clFac = (await _signInManager.ClaimsFactory.CreateAsync(baseUser));
var claims = new List<Claim>(); var claims = new List<Claim>();
claims.Add(new Claim("JwtID", jwtId)); claims.Add(new Claim("JwtID", jwtId));
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName)); claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString())); claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
if (baseUser.Email != null) if (baseUser.Email != null)
claims.Add(new Claim(ClaimTypes.Email, baseUser.Email)); claims.Add(new Claim(ClaimTypes.Email, baseUser.Email));
if(baseUser.UniversityId != null)
claims.Add(new Claim("UniversityId",baseUser.UniversityId.ToString() ?? string.Empty ));
claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail")); claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail"));
return claims; return claims;
@ -89,14 +98,16 @@ public class JwtService(
private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId, string roleId) where TUser : ApplicationUser private async Task<List<Claim>> GetClaims<TUser>(TUser baseUser, string jwtId, string roleId) where TUser : ApplicationUser
{ {
var applicationRole = await roleManager.FindByIdAsync(roleId); var applicationRole = await _roleManager.FindByIdAsync(roleId);
var roleClaims = await roleManager.GetClaimsAsync(applicationRole); var roleClaims = await _roleManager.GetClaimsAsync(applicationRole);
var claims = new List<Claim>(); var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName)); claims.Add(new Claim(ClaimTypes.Name, baseUser.UserName));
claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString())); claims.Add(new Claim(ClaimTypes.NameIdentifier, baseUser.Id.ToString()));
claims.Add(new Claim(ClaimTypes.Role, applicationRole.EnglishName)); claims.Add(new Claim(ClaimTypes.Role, applicationRole.EnglishName));
if (baseUser.Email != null) if (baseUser.Email != null)
claims.Add(new Claim(ClaimTypes.Email, baseUser.Email)); claims.Add(new Claim(ClaimTypes.Email, baseUser.Email));
if (baseUser.UniversityId != null)
claims.Add(new Claim("UniversityId", baseUser.UniversityId.ToString() ?? string.Empty));
claims.AddRange(roleClaims); claims.AddRange(roleClaims);
claims.Add(new Claim("JwtID", jwtId)); claims.Add(new Claim("JwtID", jwtId));
claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail")); claims.Add(new Claim(ClaimTypes.Gender, baseUser.Gender == 0 ? "Female" : "Mail"));

View File

@ -1,33 +1,55 @@
using DocuMed.Domain.Entities.Staffs; using DocuMed.Domain.Entities.City;
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.Core.CoreServices; namespace DocuMed.Core.CoreServices;
public class AccountService(
UserManager<ApplicationUser> userManager, public class AccountService : IAccountService
SignInManager<ApplicationUser> userSignInManager,
IJwtService jwtService,
ICurrentUserService currentUserService,
IUserService userService,
ISmsService smsService,
IRepositoryWrapper repositoryWrapper) : IAccountService
{ {
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _userSignInManager;
private readonly IJwtService _jwtService;
private readonly ICurrentUserService _currentUserService;
private readonly IUserService _userService;
private readonly ISmsService _smsService;
private readonly IRepositoryWrapper _repositoryWrapper;
public AccountService(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> 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<bool> ForgetPasswordAsync(string phoneNumber) public async Task<bool> ForgetPasswordAsync(string phoneNumber)
{ {
var user = await userManager.FindByNameAsync(phoneNumber); var user = await _userManager.FindByNameAsync(phoneNumber);
if (user != null) if (user != null)
{ {
var rand = new Random(DateTime.Now.Millisecond); var rand = new Random(DateTime.Now.Millisecond);
var newPass = rand.Next(1000000, 9000000).ToString(); var newPass = rand.Next(1000000, 9000000).ToString();
if (!user.PhoneNumberConfirmed) if (!user.PhoneNumberConfirmed)
throw new AppException("شماره تلفن شما تایید نشده است و قابلیت استفاده از فراموشی رمز عبور را ندارید"); throw new AppException("شماره تلفن شما تایید نشده است و قابلیت استفاده از فراموشی رمز عبور را ندارید");
var rp = await userManager.RemovePasswordAsync(user); var rp = await _userManager.RemovePasswordAsync(user);
if (!rp.Succeeded) if (!rp.Succeeded)
throw new AppException(string.Join('-', rp.Errors.Select(e => e.Description))); 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) if (!ap.Succeeded)
throw new AppException(string.Join('-', ap.Errors.Select(e => e.Description))); 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; return true;
} }
@ -36,7 +58,7 @@ public class AccountService(
public async Task<bool> CheckMemberShipAsync(string phoneNumber) public async Task<bool> CheckMemberShipAsync(string phoneNumber)
{ {
var user = await userManager.FindByNameAsync(phoneNumber); var user = await _userManager.FindByNameAsync(phoneNumber);
if (user == null) if (user == null)
return false; return false;
return true; return true;
@ -47,23 +69,23 @@ public class AccountService(
var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber); var newPhoneNumber = StringExtensions.CheckPhoneNumber(phoneNumber);
if (!PhoneNumberExtensions.CheckPhoneNumber(newPhoneNumber)) if (!PhoneNumberExtensions.CheckPhoneNumber(newPhoneNumber))
throw new AppException("شماره تلفن ارسالی اشتباه است"); throw new AppException("شماره تلفن ارسالی اشتباه است");
var user = await userManager.FindByNameAsync(newPhoneNumber); var user = await _userManager.FindByNameAsync(newPhoneNumber);
if (user == null) if (user == null)
user = await userService.CreateUserAsync(phoneNumber); user = await _userService.CreateUserAsync(phoneNumber);
var token = await userManager.GenerateTwoFactorTokenAsync(user, "Phone"); var token = await _userManager.GenerateTwoFactorTokenAsync(user, "Phone");
await smsService.SendVerifyCodeAsync(newPhoneNumber, token); await _smsService.SendVerifyCodeAsync(newPhoneNumber, token);
return user.SignUpStatus; return user.SignUpStatus;
} }
public async Task<AccessToken<ApplicationUserSDto>> LoginWithPasswordAsync(string userName, string password, CancellationToken cancellationToken) public async Task<AccessToken<ApplicationUserSDto>> 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) if (!result.Succeeded)
throw new AppException("رمز عبور یا نام کاربری اشتباه است"); throw new AppException("رمز عبور یا نام کاربری اشتباه است");
var admin = await userManager.FindByNameAsync(userName); var admin = await _userManager.FindByNameAsync(userName);
if (admin == null) if (admin == null)
throw new AppException("نام کاربری یا رمز عبور اشتباه است"); throw new AppException("نام کاربری یا رمز عبور اشتباه است");
return await CompleteLogin(admin, cancellationToken); return await CompleteLogin(admin, cancellationToken);
@ -71,11 +93,11 @@ public class AccountService(
public async Task<AccessToken<ApplicationUserSDto>> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken) public async Task<AccessToken<ApplicationUserSDto>> LoginWithVerifyCodeAsync(string userName, string verifyCode, CancellationToken cancellationToken)
{ {
var user = await userManager.FindByNameAsync(userName); var user = await _userManager.FindByNameAsync(userName);
if (user == null) if (user == null)
throw new AppException("نام کاربری یا کد ارسالی اشتباه است", ApiResultStatusCode.NotFound); throw new AppException("نام کاربری یا کد ارسالی اشتباه است", ApiResultStatusCode.NotFound);
var verifyResult = await userManager.VerifyTwoFactorTokenAsync(user, "Phone", verifyCode); var verifyResult = await _userManager.VerifyTwoFactorTokenAsync(user, "Phone", verifyCode);
if (verifyCode == "859585") if (verifyCode == "859585")
verifyResult = true; verifyResult = true;
if (!verifyResult) if (!verifyResult)
@ -84,7 +106,7 @@ public class AccountService(
{ {
user.PhoneNumberConfirmed = true; user.PhoneNumberConfirmed = true;
user.SignUpStatus = SignUpStatus.PhoneNumberVerified; user.SignUpStatus = SignUpStatus.PhoneNumberVerified;
var result = await userManager.UpdateAsync(user); var result = await _userManager.UpdateAsync(user);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); throw new AppException(string.Join('|', result.Errors));
} }
@ -93,9 +115,9 @@ public class AccountService(
public async Task<AccessToken<ApplicationUserSDto>> CompleteSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken) public async Task<AccessToken<ApplicationUserSDto>> CompleteSignUpAsync(SignUpRequestDto requestDto, CancellationToken cancellationToken)
{ {
if (currentUserService.UserId == null) if (_currentUserService.UserId == null)
throw new AppException("User Id is 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) if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound); throw new AppException("User not found", ApiResultStatusCode.NotFound);
@ -108,18 +130,8 @@ public class AccountService(
user.FirstName = requestDto.FirstName; user.FirstName = requestDto.FirstName;
user.LastName = requestDto.LastName; user.LastName = requestDto.LastName;
user.SignUpStatus = SignUpStatus.SignUpCompleted; user.SignUpStatus = SignUpStatus.SignUpCompleted;
user.UniversityId = requestDto.UniversityId;
var student = await repositoryWrapper.SetRepository<Student>() var result = await _userManager.UpdateAsync(user);
.TableNoTracking
.FirstOrDefaultAsync(f => f.UserId == user.Id, cancellationToken);
if (student == null)
{
student = Student.Create(requestDto.UniversityId,requestDto.SectionId,user.Id);
repositoryWrapper.SetRepository<Student>().Add(student);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
}
var result = await userManager.UpdateAsync(user);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); throw new AppException(string.Join('|', result.Errors));
@ -129,14 +141,12 @@ public class AccountService(
private async Task<AccessToken<ApplicationUserSDto>> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken) private async Task<AccessToken<ApplicationUserSDto>> CompleteLogin(ApplicationUser user, CancellationToken cancellationToken)
{ {
var token = await jwtService.Generate<ApplicationUserSDto, ApplicationUser>(user); var token = await _jwtService.Generate<ApplicationUserSDto, ApplicationUser>(user);
var student = await repositoryWrapper.SetRepository<Student>().TableNoTracking
.FirstOrDefaultAsync(s => s.UserId == user.Id, cancellationToken);
if (student != null) if (token.User.SectionId != Guid.Empty)
{ {
var section = await repositoryWrapper.SetRepository<Section>().TableNoTracking var section = await _repositoryWrapper.SetRepository<Section>().TableNoTracking
.FirstOrDefaultAsync(s => s.Id == student.SectionId, cancellationToken); .FirstOrDefaultAsync(s => s.Id == user.SectionId, cancellationToken);
if (section != null) if (section != null)
{ {
token.User.SectionName = section.Name; token.User.SectionName = section.Name;

View File

@ -0,0 +1,8 @@
namespace DocuMed.Core.EntityServices.Abstracts;
public interface IMedicalHistoryService : IScopedDependency
{
public Task<bool> EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken);
public Task<bool> AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken);
}

View File

@ -0,0 +1,77 @@
namespace DocuMed.Core.EntityServices;
public class MedicalHistoryService : 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<bool> EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken)
{
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 = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, template.FirstName,
template.LastName, template.FatherName, template.NationalId, template.Age, template.BirthDate,
template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail,
template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail,
template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail,
template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2,
template.Temperature, template.ApplicationUserId, template.MedicalHistoryTemplateId);
ent.Id = template.Id;
ent.CreatedAt = template.CreatedAt;
foreach (var answer in template.Answers.Where(a=>a.Id == Guid.Empty))
ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType);
foreach (var answer in template.Answers.Where(a => a.Id != Guid.Empty))
{
var dbAnswer = await _repositoryWrapper.SetRepository<MedicalHistoryAnswer>().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<MedicalHistoryAnswer>().Update(dbAnswer);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
}
}
_medicalHistoryRepository.Update(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
public async Task<bool> AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken)
{
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,
template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail,
template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail,
template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail,
template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2,
template.Temperature, userId,template.MedicalHistoryTemplateId);
foreach (var answer in template.Answers)
ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType);
_medicalHistoryRepository.Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true;
}
}

View File

@ -5,22 +5,28 @@ using System.Threading;
namespace DocuMed.Core.EntityServices; namespace DocuMed.Core.EntityServices;
public class MedicalHistoryTemplateService( public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService
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<bool> EditAsync(MedicalHistoryTemplateLDto template, CancellationToken cancellationToken) public async Task<bool> 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); throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized);
if (template.Id==Guid.Empty) if (template.Id==Guid.Empty)
throw new AppException("پیش نویس پیدا نشد", ApiResultStatusCode.NotFound); throw new AppException("پیش نویس پیدا نشد", ApiResultStatusCode.NotFound);
var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId); var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId);
ent.Id = template.Id; ent.Id = template.Id;
var questions = await repositoryWrapper.SetRepository<MedicalHistoryQuestion>() var questions = await _repositoryWrapper.SetRepository<MedicalHistoryQuestion>()
.TableNoTracking .TableNoTracking
.Where(q => q.MedicalHistoryTemplateId == ent.Id) .Where(q => q.MedicalHistoryTemplateId == ent.Id)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -28,28 +34,28 @@ public class MedicalHistoryTemplateService(
{ {
if (template.Questions.FirstOrDefault(q => q.Id == question.Id) == null) if (template.Questions.FirstOrDefault(q => q.Id == question.Id) == null)
{ {
repositoryWrapper.SetRepository<MedicalHistoryQuestion>() _repositoryWrapper.SetRepository<MedicalHistoryQuestion>()
.Delete(question); .Delete(question);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
} }
} }
foreach (var question in template.Questions.Where(q=>q.Id==Guid.Empty)) 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); ent.AddQuestion(question.Question, question.Part, question.QuestionType,question.BodySystem,question.IsSign,question.IsSymptom);
medicalHistoryTemplateRepository.Update(ent); _medicalHistoryTemplateRepository.Update(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
public async Task<bool> AddAsync(MedicalHistoryTemplateLDto template,CancellationToken cancellationToken) public async Task<bool> 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); throw new AppException("توکن غیرمجاز", ApiResultStatusCode.UnAuthorized);
var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId); var ent = MedicalHistoryTemplate.Create(template.ChiefComplaint, template.SectionId, userId);
foreach (var question in template.Questions) foreach (var question in template.Questions)
ent.AddQuestion(question.Question, question.Part, question.QuestionType, question.BodySystem, question.IsSign, question.IsSymptom); ent.AddQuestion(question.Question, question.Part, question.QuestionType, question.BodySystem, question.IsSign, question.IsSymptom);
medicalHistoryTemplateRepository.Add(ent); _medicalHistoryTemplateRepository.Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken); await _repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
} }

View File

@ -1,24 +1,33 @@
namespace DocuMed.Core.EntityServices; namespace DocuMed.Core.EntityServices;
public class UserService( public class UserService : IUserService
ICurrentUserService currentUserService,
UserManager<ApplicationUser> userManager,
RoleManager<ApplicationRole> roleManager,
IRepositoryWrapper repositoryWrapper)
: IUserService
{ {
private readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper; private readonly ICurrentUserService _currentUserService;
private readonly UserManager<ApplicationUser> _userManager;
private readonly RoleManager<ApplicationRole> _roleManager;
private readonly IRepositoryWrapper _repositoryWrapper;
public UserService(ICurrentUserService currentUserService,
UserManager<ApplicationUser> userManager,
RoleManager<ApplicationRole> roleManager,
IRepositoryWrapper repositoryWrapper)
{
_currentUserService = currentUserService;
_userManager = userManager;
_roleManager = roleManager;
_repositoryWrapper = repositoryWrapper;
}
public async Task<List<ApplicationUserSDto>> GetUsersAsync(int page = 0, CancellationToken cancellationToken = default) public async Task<List<ApplicationUserSDto>> 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; return users;
} }
public async Task<ApplicationUserSDto> GetUserAsync(Guid userId) public async Task<ApplicationUserSDto> GetUserAsync(Guid userId)
=> (await userManager.FindByIdAsync(userId.ToString())).AdaptToSDto(); => (await _userManager.FindByIdAsync(userId.ToString())).AdaptToSDto();
public async Task<ApplicationUser> CreateUserAsync(string phoneNumber) public async Task<ApplicationUser> CreateUserAsync(string phoneNumber)
{ {
@ -28,7 +37,7 @@ public class UserService(
PhoneNumber = phoneNumber, PhoneNumber = phoneNumber,
SignUpStatus = SignUpStatus.StartSignUp SignUpStatus = SignUpStatus.StartSignUp
}; };
var result = await userManager.CreateAsync(user); var result = await _userManager.CreateAsync(user);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); throw new AppException(string.Join('|', result.Errors));
return user; return user;
@ -45,22 +54,23 @@ public class UserService(
NationalId = request.NationalId, NationalId = request.NationalId,
BirthDate = request.BirthDate, BirthDate = request.BirthDate,
Gender = request.Gender, Gender = request.Gender,
SignUpStatus = SignUpStatus.PhoneNumberVerified, SignUpStatus = SignUpStatus.SignUpCompleted,
UniversityId = request.UniversityId
}; };
if (!request.Password.IsNullOrEmpty()) if (!request.Password.IsNullOrEmpty())
{ {
var result = await userManager.CreateAsync(user, request.Password); var result = await _userManager.CreateAsync(user, request.Password);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); throw new AppException(string.Join('|', result.Errors));
} }
else else
{ {
var result = await userManager.CreateAsync(user); var result = await _userManager.CreateAsync(user);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); 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) if (!roleResult.Succeeded)
throw new AppException(string.Join('|', roleResult.Errors)); throw new AppException(string.Join('|', roleResult.Errors));
@ -69,31 +79,36 @@ public class UserService(
public async Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken) public async Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken)
{ {
if (currentUserService.UserId == null) if (_currentUserService.UserId == null)
throw new AppException("Wrong authorize token , UserId needed"); 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) if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound); throw new AppException("User not found", ApiResultStatusCode.NotFound);
user.LastName = request.LastName; user.LastName = request.LastName;
user.FirstName = request.FirstName; user.FirstName = request.FirstName;
user.UserName = request.PhoneNumber; user.UserName = request.PhoneNumber;
user.PhoneNumber = request.PhoneNumber; user.PhoneNumber = request.PhoneNumber;
user.StudentId = request.StudentId;
user.FirstName = request.FirstName; user.FirstName = request.FirstName;
user.LastName = request.LastName; user.LastName = request.LastName;
user.NationalId = request.NationalId; user.NationalId = request.NationalId;
user.BirthDate = request.BirthDate; user.BirthDate = request.BirthDate;
user.Gender = request.Gender; user.Gender = request.Gender;
if (request.UniversityId != Guid.Empty)
user.UniversityId = request.UniversityId;
if (request.SectionId != Guid.Empty)
user.SectionId = request.SectionId;
var result = await userManager.UpdateAsync(user); var result = await _userManager.UpdateAsync(user);
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors)); throw new AppException(string.Join('|', result.Errors));
if (!request.Password.IsNullOrEmpty()) if (!request.Password.IsNullOrEmpty())
{ {
if (await userManager.HasPasswordAsync(user)) if (await _userManager.HasPasswordAsync(user))
await userManager.RemovePasswordAsync(user); await _userManager.RemovePasswordAsync(user);
var addPassResult = await userManager.AddPasswordAsync(user, request.Password); var addPassResult = await _userManager.AddPasswordAsync(user, request.Password);
if (!addPassResult.Succeeded) if (!addPassResult.Succeeded)
throw new AppException(string.Join('|', addPassResult.Errors)); throw new AppException(string.Join('|', addPassResult.Errors));
} }
@ -102,10 +117,10 @@ public class UserService(
public async Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken) public async Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken)
{ {
var user = await userManager.FindByIdAsync(userId.ToString()); var user = await _userManager.FindByIdAsync(userId.ToString());
if (user == null) if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound); throw new AppException("User not found", ApiResultStatusCode.NotFound);
var removeResult = await userManager.DeleteAsync(user); var removeResult = await _userManager.DeleteAsync(user);
if (!removeResult.Succeeded) if (!removeResult.Succeeded)
throw new AppException(string.Join('|', removeResult.Errors)); throw new AppException(string.Join('|', removeResult.Errors));
return true; return true;
@ -116,7 +131,7 @@ public class UserService(
public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default) public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default)
{ {
var roles = await roleManager.Roles var roles = await _roleManager.Roles
.Skip(page * 15) .Skip(page * 15)
.Take(15) .Take(15)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -125,12 +140,12 @@ public class UserService(
public async Task<RoleActionRequestDto> GetRoleAsync(Guid roleId) public async Task<RoleActionRequestDto> GetRoleAsync(Guid roleId)
{ {
var role = (await roleManager.FindByIdAsync(roleId.ToString())); var role = (await _roleManager.FindByIdAsync(roleId.ToString()));
if (role == null) if (role == null)
throw new AppException("نقش پیدا نشد", ApiResultStatusCode.NotFound); throw new AppException("نقش پیدا نشد", ApiResultStatusCode.NotFound);
var roleDto = role.Adapt<RoleActionRequestDto>(); var roleDto = role.Adapt<RoleActionRequestDto>();
roleDto.Permissions = (await roleManager.GetClaimsAsync(role)) roleDto.Permissions = (await _roleManager.GetClaimsAsync(role))
.Where(c => c.Type == CustomClaimType.Permission) .Where(c => c.Type == CustomClaimType.Permission)
.Select(c => c.Value) .Select(c => c.Value)
.ToList(); .ToList();
@ -149,12 +164,12 @@ public class UserService(
Description = request.Description, Description = request.Description,
Name = $"{request.EnglishName}" Name = $"{request.EnglishName}"
}; };
var createRoleResult = await roleManager.CreateAsync(applicationRole); var createRoleResult = await _roleManager.CreateAsync(applicationRole);
if (!createRoleResult.Succeeded) if (!createRoleResult.Succeeded)
throw new AppException(string.Join('|', createRoleResult.Errors)); throw new AppException(string.Join('|', createRoleResult.Errors));
foreach (var claim in request.Permissions) 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; return applicationRole;
} }
@ -162,7 +177,7 @@ public class UserService(
{ {
if (request.EnglishName.IsNullOrEmpty()) if (request.EnglishName.IsNullOrEmpty())
throw new AppException("لطفا نام انگلیسی را وارد کنید"); throw new AppException("لطفا نام انگلیسی را وارد کنید");
var applicationRole = await roleManager.FindByIdAsync(request.RoleId.ToString()); var applicationRole = await _roleManager.FindByIdAsync(request.RoleId.ToString());
if (applicationRole == null) if (applicationRole == null)
throw new AppException("نقش پیدا نشد"); throw new AppException("نقش پیدا نشد");
@ -171,10 +186,10 @@ public class UserService(
applicationRole.Description = request.Description; applicationRole.Description = request.Description;
applicationRole.Name = $"{request.EnglishName}"; applicationRole.Name = $"{request.EnglishName}";
var createRoleResult = await roleManager.UpdateAsync(applicationRole); var createRoleResult = await _roleManager.UpdateAsync(applicationRole);
if (!createRoleResult.Succeeded) if (!createRoleResult.Succeeded)
throw new AppException(string.Join('|', createRoleResult.Errors)); 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()) foreach (var roleClaim in roleClaims.ToList())
{ {
if (request.Permissions.Contains(roleClaim.Value)) if (request.Permissions.Contains(roleClaim.Value))
@ -185,20 +200,20 @@ public class UserService(
} }
foreach (var claim in request.Permissions) 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) foreach (var claim in roleClaims)
await roleManager.RemoveClaimAsync(applicationRole, claim); await _roleManager.RemoveClaimAsync(applicationRole, claim);
return true; return true;
} }
public async Task<bool> RemoveRoleAsync(Guid roleId) public async Task<bool> RemoveRoleAsync(Guid roleId)
{ {
var applicationRole = await roleManager.FindByIdAsync(roleId.ToString()); var applicationRole = await _roleManager.FindByIdAsync(roleId.ToString());
if (applicationRole == null) if (applicationRole == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound); throw new AppException("User not found", ApiResultStatusCode.NotFound);
var removeResult = await roleManager.DeleteAsync(applicationRole); var removeResult = await _roleManager.DeleteAsync(applicationRole);
if (!removeResult.Succeeded) if (!removeResult.Succeeded)
throw new AppException(string.Join('|', removeResult.Errors)); throw new AppException(string.Join('|', removeResult.Errors));
return true; return true;

View File

@ -1,12 +1,19 @@
namespace DocuMed.Core.Models.Api; namespace DocuMed.Core.Models.Api;
public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) public class ApiResult
{ {
public bool IsSuccess { get; set; } = isSuccess; public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null)
public ApiResultStatusCode StatusCode { get; set; } = statusCode; {
IsSuccess = isSuccess;
StatusCode = statusCode;
Message = message ?? statusCode.ToDisplay();
}
public bool IsSuccess { get; set; }
public ApiResultStatusCode StatusCode { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string Message { get; set; } = message ?? statusCode.ToDisplay(); public string Message { get; set; }
#region Implicit Operators #region Implicit Operators
@ -55,12 +62,17 @@ public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string me
#endregion #endregion
} }
public class ApiResult<TData>(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) public class ApiResult<TData> : ApiResult
: ApiResult(isSuccess, statusCode, message)
where TData : class where TData : class
{ {
public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null)
: base(isSuccess, statusCode, message)
{
Data = data;
}
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public TData Data { get; set; } = data; public TData Data { get; set; }
#region Implicit Operators #region Implicit Operators

View File

@ -1,5 +0,0 @@
namespace DocuMed.Domain.CommandQueries.Commands;
public sealed record CreateHospitalCommand(string Name, string Detail, string Address, Guid UniversityId) : IRequest<Guid>;
public sealed record UpdateHospitalCommand(Guid Id,string Name, string Detail, string Address, Guid UniversityId) : IRequest<Guid>;
public sealed record DeleteHospitalCommand(Guid Id) : IRequest<Guid>;

View File

@ -1,58 +0,0 @@
namespace DocuMed.Domain.CommandQueries.Commands;
public sealed record CreateMedicalHistoryCommand(
string ChiefComplaint,
Guid SectionId,
string FirstName,
string LastName,
string FatherName,
string NationalId,
DateTime BirthDate,
string PresentIllnessDetail,
string PastDiseasesHistoryDetail,
string PastSurgeryHistoryDetail,
string FamilyHistoryDetail,
string AllergyDetail,
string DrugHistoryDetail,
string AddictionHistoryDetail,
string SystemReviewDetail,
string VitalSignDetail,
string GeneralAppearanceDetail,
double SystolicBloodPressure,
double DiastolicBloodPressure,
double PulseRate,
double SPO2,
double Temperature,
Guid ApplicationUserId,
Guid MedicalHistoryTemplateId,
List<MedicalHistoryAnswerSDto> Answers) : IRequest<Guid>;
public sealed record UpdateMedicalHistoryCommand(
Guid Id,
string ChiefComplaint,
Guid SectionId,
string FirstName,
string LastName,
string FatherName,
string NationalId,
DateTime BirthDate,
string PresentIllnessDetail,
string PastDiseasesHistoryDetail,
string PastSurgeryHistoryDetail,
string FamilyHistoryDetail,
string AllergyDetail,
string DrugHistoryDetail,
string AddictionHistoryDetail,
string SystemReviewDetail,
string VitalSignDetail,
string GeneralAppearanceDetail,
double SystolicBloodPressure,
double DiastolicBloodPressure,
double PulseRate,
double SPO2,
double Temperature,
Guid ApplicationUserId,
Guid MedicalHistoryTemplateId,
List<MedicalHistoryAnswerSDto> Answers) : IRequest<Guid>;
public sealed record DeleteMedicalHistoryCommand(Guid Id) : IRequest<Guid>;

View File

@ -1,4 +0,0 @@
namespace DocuMed.Domain.CommandQueries.Queries;
public sealed record GetHospitalsQuery(int Page = 0 , int Size = Refers.SizeM) : IRequest<List<HospitalSDto>>;
public sealed record GetHospitalQuery(Guid Id) : IRequest<HospitalSDto>;

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -11,10 +11,10 @@
<PackageReference Include="MediatR" Version="12.4.1" /> <PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.8" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.8" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" /> <PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup>--> </ItemGroup>
<PropertyGroup> <!--<PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -27,7 +27,7 @@
<PackageReference Include="MediatR" Version="12.1.1" /> <PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" /> <PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
</ItemGroup> </ItemGroup>-->
<Target Name="Mapster"> <Target Name="Mapster">
@ -42,10 +42,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Dtos\LargDtos\" />
<Folder Include="Dtos\ResponseDtos\" /> <Folder Include="Dtos\ResponseDtos\" />
<Folder Include="Dtos\RequestDtos\" /> <Folder Include="Dtos\RequestDtos\" />
<Folder Include="Entities\City\" /> <Folder Include="Entities\City\" />
<Folder Include="Entities\Patients\" /> <Folder Include="Entities\Patient\" />
<Folder Include="Entities\User\" /> <Folder Include="Entities\User\" />
</ItemGroup> </ItemGroup>
@ -55,15 +56,11 @@
<Using Include="DocuMed.Common.Models.Mapper" /> <Using Include="DocuMed.Common.Models.Mapper" />
<Using Include="DocuMed.Domain.Dtos.SmallDtos" /> <Using Include="DocuMed.Domain.Dtos.SmallDtos" />
<Using Include="DocuMed.Domain.Entities.City" /> <Using Include="DocuMed.Domain.Entities.City" />
<Using Include="DocuMed.Domain.Entities.Hospitals" />
<Using Include="DocuMed.Domain.Entities.MedicalHistory" /> <Using Include="DocuMed.Domain.Entities.MedicalHistory" />
<Using Include="DocuMed.Domain.Entities.Staffs" />
<Using Include="DocuMed.Domain.Entities.User" /> <Using Include="DocuMed.Domain.Entities.User" />
<Using Include="DocuMed.Domain.Enums" /> <Using Include="DocuMed.Domain.Enums" />
<Using Include="DocuMed.Domain.Models" />
<Using Include="Mapster" /> <Using Include="Mapster" />
<Using Include="MD.PersianDateTime.Standard" /> <Using Include="MD.PersianDateTime.Standard" />
<Using Include="MediatR" />
<Using Include="Microsoft.AspNetCore.Identity" /> <Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Newtonsoft.Json" /> <Using Include="Newtonsoft.Json" />
<Using Include="System.ComponentModel.DataAnnotations" /> <Using Include="System.ComponentModel.DataAnnotations" />

View File

@ -5,6 +5,5 @@ public class SignUpRequestDto
public string FirstName { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty;
public Guid UniversityId { get; set; } public Guid UniversityId { get; set; }
public Guid SectionId { get; set; }
public Guid CityId { get; set; } public Guid CityId { get; set; }
} }

View File

@ -1,9 +0,0 @@
namespace DocuMed.Domain.Dtos.SmallDtos;
public class HospitalSDto : BaseDto<HospitalSDto,Hospital>
{
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;
}

View File

@ -4,5 +4,5 @@ public class SectionSDto : BaseDto<SectionSDto,Section>
{ {
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Detail { get; set; } = string.Empty; public string Detail { get; set; } = string.Empty;
public Guid HospitalId { get; set; } public Guid UniversityId { get; set; }
} }

View File

@ -1,18 +0,0 @@
namespace DocuMed.Domain.Dtos.SmallDtos;
public class StudentSDto : BaseDto<StudentSDto,Student>
{
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;
}

View File

@ -23,3 +23,11 @@ public partial class University
return new University(name, address, cityId); 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);
}
}

View File

@ -1,10 +1,8 @@
namespace DocuMed.Domain.Entities.City; 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]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] [GenerateMapper]
public partial class City : ApiEntity public partial class City : ApiEntity
{ {
public City() public City()

View File

@ -1,4 +1,4 @@
namespace DocuMed.Domain.Entities.Hospitals; namespace DocuMed.Domain.Entities.City;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper] [GenerateMapper]
@ -10,16 +10,16 @@ public partial class Section : ApiEntity
} }
public Section(string name, string detail, Guid hospitalId) public Section(string name, string detail, Guid universityId)
{ {
Name = name; Name = name;
Detail = detail; Detail = detail;
HospitalId = hospitalId; UniversityId = universityId;
} }
public string Name { get; internal set; } = string.Empty; public string Name { get; internal set; } = string.Empty;
public string Detail { get; internal set; } = string.Empty; public string Detail { get; internal set; } = string.Empty;
public Guid HospitalId { get; internal set; } public Guid UniversityId { get; internal set; }
public Hospital? Hospital { get; internal set; } public University? University { get; internal set; }
} }

View File

@ -22,5 +22,5 @@ public partial class University : ApiEntity
public Guid CityId { get; internal set; } public Guid CityId { get; internal set; }
public City? City { get; internal set; } public City? City { get; internal set; }
public List<Hospitals.Section> Sections { get; internal set; } = new(); public List<Section> Sections { get; internal set; } = new();
} }

View File

@ -1,15 +0,0 @@
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);
}
}

View File

@ -1,26 +0,0 @@
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<Section> Sections { get; internal set; } = new ();
}

View File

@ -26,6 +26,12 @@ public partial class MedicalHistory
public static MedicalHistory Create( public static MedicalHistory Create(
string chiefComplaint, string chiefComplaint,
Guid sectionId, Guid sectionId,
string firstName,
string lastName,
string fatherName,
string nationalId,
int age,
DateTime birthDate,
string presentIllnessDetail, string presentIllnessDetail,
string pastDiseasesHistoryDetail, string pastDiseasesHistoryDetail,
string pastSurgeryHistoryDetail, string pastSurgeryHistoryDetail,
@ -57,6 +63,12 @@ public partial class MedicalHistory
generalAppearanceDetail, generalAppearanceDetail,
chiefComplaint, chiefComplaint,
sectionId, sectionId,
firstName,
lastName,
fatherName,
nationalId,
age,
birthDate,
systolicBloodPressure, systolicBloodPressure,
diastolicBloodPressure, diastolicBloodPressure,
pulseRate, pulseRate,

View File

@ -1,11 +1,9 @@
namespace DocuMed.Domain.Entities.MedicalHistory; 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]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] [GenerateMapper]
public partial class MedicalHistory : ApiEntity public partial class MedicalHistory : ApiEntity
{ {
public MedicalHistory() public MedicalHistory()
@ -25,6 +23,12 @@ public partial class MedicalHistory : ApiEntity
string generalAppearanceDetail, string generalAppearanceDetail,
string chiefComplaint, string chiefComplaint,
Guid sectionId, Guid sectionId,
string firstName,
string lastName,
string fatherName,
string nationalId,
int age,
DateTime birthDate,
double systolicBloodPressure, double systolicBloodPressure,
double diastolicBloodPressure, double diastolicBloodPressure,
double pulseRate, double pulseRate,
@ -46,6 +50,12 @@ public partial class MedicalHistory : ApiEntity
GeneralAppearanceDetail = generalAppearanceDetail; GeneralAppearanceDetail = generalAppearanceDetail;
ChiefComplaint = chiefComplaint; ChiefComplaint = chiefComplaint;
SectionId = sectionId; SectionId = sectionId;
FirstName = firstName;
LastName = lastName;
FatherName = fatherName;
NationalId = nationalId;
Age = age;
BirthDate = birthDate;
SystolicBloodPressure = systolicBloodPressure; SystolicBloodPressure = systolicBloodPressure;
DiastolicBloodPressure = diastolicBloodPressure; DiastolicBloodPressure = diastolicBloodPressure;
PulseRate = pulseRate; PulseRate = pulseRate;
@ -59,6 +69,13 @@ public partial class MedicalHistory : ApiEntity
public Guid SectionId { get; internal set; } public Guid SectionId { get; internal set; }
public Section? Section { get; internal set; } public Section? Section { get; internal set; }
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; }
public string PresentIllnessDetail { get; internal set; } = string.Empty; public string PresentIllnessDetail { get; internal set; } = string.Empty;
public string PastDiseasesHistoryDetail { get; internal set; } = string.Empty; public string PastDiseasesHistoryDetail { get; internal set; } = string.Empty;
public string PastSurgeryHistoryDetail { get; internal set; } = string.Empty; public string PastSurgeryHistoryDetail { get; internal set; } = string.Empty;

View File

@ -1,10 +1,7 @@
namespace DocuMed.Domain.Entities.MedicalHistoryTemplate; namespace DocuMed.Domain.Entities.MedicalHistoryTemplate;
[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 | 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] [GenerateMapper]
public partial class MedicalHistoryQuestion : ApiEntity public partial class MedicalHistoryQuestion : ApiEntity
{ {
public MedicalHistoryQuestion() public MedicalHistoryQuestion()

View File

@ -1,9 +1,11 @@
namespace DocuMed.Domain.Entities.MedicalHistoryTemplate; 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]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] [GenerateMapper]
public partial class MedicalHistoryTemplate : ApiEntity public partial class MedicalHistoryTemplate : ApiEntity
{ {
public MedicalHistoryTemplate() public MedicalHistoryTemplate()

View File

@ -0,0 +1,12 @@
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; }
}

View File

@ -1,7 +0,0 @@
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);
}

View File

@ -1,33 +0,0 @@
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; }
}

View File

@ -1,7 +0,0 @@
namespace DocuMed.Domain.Entities.Staffs;
public partial class Student
{
public static Student Create(Guid universityId, Guid sectionId, Guid userId)
=> new Student(universityId, sectionId, userId);
}

View File

@ -1,31 +0,0 @@
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; }
}

View File

@ -1,6 +1,4 @@
using DocuMed.Domain.Entities.Patients; namespace DocuMed.Domain.Entities.User;
namespace DocuMed.Domain.Entities.User;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper] [GenerateMapper]
@ -9,10 +7,14 @@ public class ApplicationUser : IdentityUser<Guid>
public string FirstName { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty;
public string NationalId { get; set; } = string.Empty; public string NationalId { get; set; } = string.Empty;
public string StudentId { get; set; } = string.Empty;
public DateTime BirthDate { get; set; } public DateTime BirthDate { get; set; }
public Gender Gender { get; set; } public Gender Gender { get; set; }
public SignUpStatus SignUpStatus { get; set; } public SignUpStatus SignUpStatus { get; set; }
public Student? Student { get; set; } public Guid? UniversityId { get; set; }
public Patient? Patient { get; set; } public University? University { get; set; }
public Guid? SectionId { get; set; }
public Section? Section { get; set; }
} }

View File

@ -1,7 +1,9 @@
using System; using System;
using System.Linq.Expressions; using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos; using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.City;
using DocuMed.Domain.Entities.User; using DocuMed.Domain.Entities.User;
using Mapster.Models;
namespace DocuMed.Domain.Mappers namespace DocuMed.Domain.Mappers
{ {
@ -14,9 +16,18 @@ namespace DocuMed.Domain.Mappers
FirstName = p1.FirstName, FirstName = p1.FirstName,
LastName = p1.LastName, LastName = p1.LastName,
NationalId = p1.NationalId, NationalId = p1.NationalId,
StudentId = p1.StudentId,
BirthDate = p1.BirthDate, BirthDate = p1.BirthDate,
Gender = p1.Gender, Gender = p1.Gender,
SignUpStatus = p1.SignUpStatus, 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, Id = p1.Id,
UserName = p1.UserName, UserName = p1.UserName,
Email = p1.Email, Email = p1.Email,
@ -35,9 +46,14 @@ namespace DocuMed.Domain.Mappers
result.FirstName = p2.FirstName; result.FirstName = p2.FirstName;
result.LastName = p2.LastName; result.LastName = p2.LastName;
result.NationalId = p2.NationalId; result.NationalId = p2.NationalId;
result.StudentId = p2.StudentId;
result.BirthDate = p2.BirthDate; result.BirthDate = p2.BirthDate;
result.Gender = p2.Gender; result.Gender = p2.Gender;
result.SignUpStatus = p2.SignUpStatus; 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.Id = p2.Id;
result.UserName = p2.UserName; result.UserName = p2.UserName;
result.Email = p2.Email; result.Email = p2.Email;
@ -46,85 +62,112 @@ namespace DocuMed.Domain.Mappers
return result; return result;
} }
public static Expression<Func<ApplicationUserSDto, ApplicationUser>> ProjectToApplicationUser => p4 => new ApplicationUser() public static Expression<Func<ApplicationUserSDto, ApplicationUser>> ProjectToApplicationUser => p8 => new ApplicationUser()
{ {
FirstName = p4.FirstName, FirstName = p8.FirstName,
LastName = p4.LastName, LastName = p8.LastName,
NationalId = p4.NationalId, NationalId = p8.NationalId,
BirthDate = p4.BirthDate, StudentId = p8.StudentId,
Gender = p4.Gender, BirthDate = p8.BirthDate,
SignUpStatus = p4.SignUpStatus, Gender = p8.Gender,
Id = p4.Id, SignUpStatus = p8.SignUpStatus,
UserName = p4.UserName, UniversityId = (Guid?)p8.UniversityId,
Email = p4.Email, University = new University() {Id = p8.UniversityId},
PhoneNumber = p4.PhoneNumber, SectionId = (Guid?)p8.SectionId,
PhoneNumberConfirmed = p4.PhoneNumberConfirmed Section = new Section()
};
public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p5)
{
return p5 == null ? null : new ApplicationUserSDto()
{ {
FirstName = p5.FirstName, Name = p8.SectionName,
LastName = p5.LastName, Id = p8.SectionId
UserName = p5.UserName, },
Email = p5.Email, Id = p8.Id,
PhoneNumber = p5.PhoneNumber, UserName = p8.UserName,
PhoneNumberConfirmed = p5.PhoneNumberConfirmed, Email = p8.Email,
NationalId = p5.NationalId, PhoneNumber = p8.PhoneNumber,
StudentId = funcMain1(p5.Student == null ? null : (Guid?)p5.Student.Id), PhoneNumberConfirmed = p8.PhoneNumberConfirmed
BirthDate = p5.BirthDate, };
Gender = p5.Gender, public static ApplicationUserSDto AdaptToSDto(this ApplicationUser p9)
SignUpStatus = p5.SignUpStatus, {
Id = p5.Id return p9 == 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
}; };
} }
public static ApplicationUserSDto AdaptTo(this ApplicationUser p7, ApplicationUserSDto p8) public static ApplicationUserSDto AdaptTo(this ApplicationUser p10, ApplicationUserSDto p11)
{ {
if (p7 == null) if (p10 == null)
{ {
return null; return null;
} }
ApplicationUserSDto result = p8 ?? new ApplicationUserSDto(); ApplicationUserSDto result = p11 ?? new ApplicationUserSDto();
result.FirstName = p7.FirstName; result.FirstName = p10.FirstName;
result.LastName = p7.LastName; result.LastName = p10.LastName;
result.UserName = p7.UserName; result.UserName = p10.UserName;
result.Email = p7.Email; result.Email = p10.Email;
result.PhoneNumber = p7.PhoneNumber; result.PhoneNumber = p10.PhoneNumber;
result.PhoneNumberConfirmed = p7.PhoneNumberConfirmed; result.PhoneNumberConfirmed = p10.PhoneNumberConfirmed;
result.NationalId = p7.NationalId; result.NationalId = p10.NationalId;
result.StudentId = funcMain2(p7.Student == null ? null : (Guid?)p7.Student.Id, result.StudentId); result.StudentId = p10.StudentId;
result.BirthDate = p7.BirthDate; result.BirthDate = p10.BirthDate;
result.Gender = p7.Gender; result.Gender = p10.Gender;
result.SignUpStatus = p7.SignUpStatus; result.SignUpStatus = p10.SignUpStatus;
result.Id = p7.Id; 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;
return result; return result;
} }
public static Expression<Func<ApplicationUser, ApplicationUserSDto>> ProjectToSDto => p11 => new ApplicationUserSDto() public static Expression<Func<ApplicationUser, ApplicationUserSDto>> ProjectToSDto => p12 => new ApplicationUserSDto()
{ {
FirstName = p11.FirstName, FirstName = p12.FirstName,
LastName = p11.LastName, LastName = p12.LastName,
UserName = p11.UserName, UserName = p12.UserName,
Email = p11.Email, Email = p12.Email,
PhoneNumber = p11.PhoneNumber, PhoneNumber = p12.PhoneNumber,
PhoneNumberConfirmed = p11.PhoneNumberConfirmed, PhoneNumberConfirmed = p12.PhoneNumberConfirmed,
NationalId = p11.NationalId, NationalId = p12.NationalId,
StudentId = p11.Student.Id.ToString(), StudentId = p12.StudentId,
BirthDate = p11.BirthDate, BirthDate = p12.BirthDate,
Gender = p11.Gender, Gender = p12.Gender,
SignUpStatus = p11.SignUpStatus, SignUpStatus = p12.SignUpStatus,
Id = p11.Id 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
}; };
private static string funcMain1(Guid? p6) private static University funcMain1(Never p4, University p5, ApplicationUserSDto p2)
{ {
return p6 == null ? null : ((Guid)p6).ToString(); University result = p5 ?? new University();
result.Id = p2.UniversityId;
return result;
} }
private static string funcMain2(Guid? p9, string p10) private static Section funcMain2(Never p6, Section p7, ApplicationUserSDto p2)
{ {
return p9 == null ? null : ((Guid)p9).ToString(); Section result = p7 ?? new Section();
result.Name = p2.SectionName;
result.Id = p2.SectionId;
return result;
} }
} }
} }

View File

@ -10,192 +10,197 @@ namespace DocuMed.Domain.Mappers
{ {
public static partial class CityMapper public static partial class CityMapper
{ {
public static City AdaptToCity(this CityLDto p1) public static City AdaptToCity(this CitySDto p1)
{ {
return p1 == null ? null : new City() return p1 == null ? null : new City()
{ {
Name = p1.Name, Name = p1.Name,
Universities = funcMain1(p1.Universities),
Id = p1.Id Id = p1.Id
}; };
} }
public static City AdaptTo(this CityLDto p3, City p4) public static City AdaptTo(this CitySDto p2, City p3)
{
if (p3 == null)
{
return null;
}
City result = p4 ?? new City();
result.Name = p3.Name;
result.Universities = funcMain2(p3.Universities, result.Universities);
result.Id = p3.Id;
return result;
}
public static Expression<Func<CityLDto, City>> ProjectToCity => p7 => new City()
{
Name = p7.Name,
Universities = p7.Universities.Select<UniversitySDto, University>(p8 => new University()
{
Name = p8.Name,
Address = p8.Address,
CityId = p8.CityId,
Id = p8.Id
}).ToList<University>(),
Id = p7.Id
};
public static CityLDto AdaptToLDto(this City p9)
{
return p9 == null ? null : new CityLDto()
{
Name = p9.Name,
Universities = funcMain3(p9.Universities),
Id = p9.Id
};
}
public static CityLDto AdaptTo(this City p11, CityLDto p12)
{
if (p11 == null)
{
return null;
}
CityLDto result = p12 ?? new CityLDto();
result.Name = p11.Name;
result.Universities = funcMain4(p11.Universities, result.Universities);
result.Id = p11.Id;
return result;
}
public static Expression<Func<City, CityLDto>> ProjectToLDto => p15 => new CityLDto()
{
Name = p15.Name,
Universities = p15.Universities.Select<University, UniversitySDto>(p16 => new UniversitySDto()
{
Name = p16.Name,
Address = p16.Address,
CityId = p16.CityId,
Id = p16.Id
}).ToList<UniversitySDto>(),
Id = p15.Id
};
public static City AdaptToCity(this CitySDto p17)
{
return p17 == null ? null : new City()
{
Name = p17.Name,
Id = p17.Id
};
}
public static City AdaptTo(this CitySDto p18, City p19)
{
if (p18 == null)
{
return null;
}
City result = p19 ?? new City();
result.Name = p18.Name;
result.Id = p18.Id;
return result;
}
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<Func<City, CitySDto>> ProjectToSDto => p23 => new CitySDto()
{
Name = p23.Name,
Id = p23.Id
};
private static List<University> funcMain1(List<UniversitySDto> p2)
{ {
if (p2 == null) if (p2 == null)
{ {
return null; return null;
} }
List<University> result = new List<University>(p2.Count); City result = p3 ?? new City();
int i = 0; result.Name = p2.Name;
int len = p2.Count; result.Id = p2.Id;
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; return result;
} }
public static Expression<Func<CitySDto, City>> ProjectToCity => p4 => new City()
private static List<University> funcMain2(List<UniversitySDto> p5, List<University> p6)
{ {
if (p5 == null) Name = p4.Name,
Id = p4.Id
};
public static CitySDto AdaptToSDto(this City p5)
{
return p5 == null ? null : new CitySDto()
{
Name = p5.Name,
Id = p5.Id
};
}
public static CitySDto AdaptTo(this City p6, CitySDto p7)
{
if (p6 == null)
{ {
return null; return null;
} }
List<University> result = new List<University>(p5.Count); CitySDto result = p7 ?? new CitySDto();
int i = 0; result.Name = p6.Name;
int len = p5.Count; result.Id = p6.Id;
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; return result;
} }
public static Expression<Func<City, CitySDto>> ProjectToSDto => p8 => new CitySDto()
{
Name = p8.Name,
Id = p8.Id
};
public static City AdaptToCity(this CityLDto p9)
{
return p9 == null ? null : new City()
{
Name = p9.Name,
Universities = funcMain1(p9.Universities),
Id = p9.Id
};
}
public static City AdaptTo(this CityLDto p11, City p12)
{
if (p11 == null)
{
return null;
}
City result = p12 ?? new City();
private static List<UniversitySDto> funcMain3(List<University> p10) result.Name = p11.Name;
result.Universities = funcMain2(p11.Universities, result.Universities);
result.Id = p11.Id;
return result;
}
public static Expression<Func<CityLDto, City>> ProjectLDtoToCity => p15 => new City()
{
Name = p15.Name,
Universities = p15.Universities.Select<UniversitySDto, University>(p16 => new University()
{
Name = p16.Name,
Address = p16.Address,
CityId = p16.CityId,
Id = p16.Id
}).ToList<University>(),
Id = p15.Id
};
public static CityLDto AdaptToLDto(this City p17)
{
return p17 == null ? null : new CityLDto()
{
Name = p17.Name,
Universities = funcMain3(p17.Universities),
Id = p17.Id
};
}
public static CityLDto AdaptTo(this City p19, CityLDto p20)
{
if (p19 == null)
{
return null;
}
CityLDto result = p20 ?? new CityLDto();
result.Name = p19.Name;
result.Universities = funcMain4(p19.Universities, result.Universities);
result.Id = p19.Id;
return result;
}
public static Expression<Func<City, CityLDto>> ProjectToLDto => p23 => new CityLDto()
{
Name = p23.Name,
Universities = p23.Universities.Select<University, UniversitySDto>(p24 => new UniversitySDto()
{
Name = p24.Name,
Address = p24.Address,
CityId = p24.CityId,
Id = p24.Id
}).ToList<UniversitySDto>(),
Id = p23.Id
};
private static List<University> funcMain1(List<UniversitySDto> p10)
{ {
if (p10 == null) if (p10 == null)
{ {
return null; return null;
} }
List<UniversitySDto> result = new List<UniversitySDto>(p10.Count); List<University> result = new List<University>(p10.Count);
int i = 0; int i = 0;
int len = p10.Count; int len = p10.Count;
while (i < len) while (i < len)
{ {
University item = p10[i]; 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<University> funcMain2(List<UniversitySDto> p13, List<University> p14)
{
if (p13 == null)
{
return null;
}
List<University> result = new List<University>(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<UniversitySDto> funcMain3(List<University> p18)
{
if (p18 == null)
{
return null;
}
List<UniversitySDto> result = new List<UniversitySDto>(p18.Count);
int i = 0;
int len = p18.Count;
while (i < len)
{
University item = p18[i];
result.Add(item == null ? null : new UniversitySDto() result.Add(item == null ? null : new UniversitySDto()
{ {
Name = item.Name, Name = item.Name,
@ -209,20 +214,20 @@ namespace DocuMed.Domain.Mappers
} }
private static List<UniversitySDto> funcMain4(List<University> p13, List<UniversitySDto> p14) private static List<UniversitySDto> funcMain4(List<University> p21, List<UniversitySDto> p22)
{ {
if (p13 == null) if (p21 == null)
{ {
return null; return null;
} }
List<UniversitySDto> result = new List<UniversitySDto>(p13.Count); List<UniversitySDto> result = new List<UniversitySDto>(p21.Count);
int i = 0; int i = 0;
int len = p13.Count; int len = p21.Count;
while (i < len) while (i < len)
{ {
University item = p13[i]; University item = p21[i];
result.Add(item == null ? null : new UniversitySDto() result.Add(item == null ? null : new UniversitySDto()
{ {
Name = item.Name, Name = item.Name,

View File

@ -1,78 +0,0 @@
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<Func<HospitalSDto, Hospital>> 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<Func<Hospital, HospitalSDto>> ProjectToSDto => p8 => new HospitalSDto()
{
Name = p8.Name,
Detail = p8.Detail,
Address = p8.Address,
UniversityName = p8.University.Name,
Id = p8.Id
};
}
}

File diff suppressed because it is too large Load Diff

View File

@ -40,49 +40,60 @@ namespace DocuMed.Domain.Mappers
return result; return result;
} }
public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p4) public static Expression<Func<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>> ProjectToMedicalHistoryQuestion => p4 => new MedicalHistoryQuestion()
{ {
return p4 == null ? null : new MedicalHistoryQuestionSDto() 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()
{ {
Question = p4.Question, Question = p5.Question,
Part = p4.Part, Part = p5.Part,
QuestionType = p4.QuestionType, QuestionType = p5.QuestionType,
MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId, MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId,
BodySystem = p4.BodySystem, BodySystem = p5.BodySystem,
IsSign = p4.IsSign, IsSign = p5.IsSign,
IsSymptom = p4.IsSymptom, IsSymptom = p5.IsSymptom,
Id = p4.Id Id = p5.Id
}; };
} }
public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p5, MedicalHistoryQuestionSDto p6) public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p6, MedicalHistoryQuestionSDto p7)
{ {
if (p5 == null) if (p6 == null)
{ {
return null; return null;
} }
MedicalHistoryQuestionSDto result = p6 ?? new MedicalHistoryQuestionSDto(); MedicalHistoryQuestionSDto result = p7 ?? new MedicalHistoryQuestionSDto();
result.Question = p5.Question; result.Question = p6.Question;
result.Part = p5.Part; result.Part = p6.Part;
result.QuestionType = p5.QuestionType; result.QuestionType = p6.QuestionType;
result.MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId; result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId;
result.BodySystem = p5.BodySystem; result.BodySystem = p6.BodySystem;
result.IsSign = p5.IsSign; result.IsSign = p6.IsSign;
result.IsSymptom = p5.IsSymptom; result.IsSymptom = p6.IsSymptom;
result.Id = p5.Id; result.Id = p6.Id;
return result; return result;
} }
public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p7 => new MedicalHistoryQuestionSDto() public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p8 => new MedicalHistoryQuestionSDto()
{ {
Question = p7.Question, Question = p8.Question,
Part = p7.Part, Part = p8.Part,
QuestionType = p7.QuestionType, QuestionType = p8.QuestionType,
MedicalHistoryTemplateId = p7.MedicalHistoryTemplateId, MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId,
BodySystem = p7.BodySystem, BodySystem = p8.BodySystem,
IsSign = p7.IsSign, IsSign = p8.IsSign,
IsSymptom = p7.IsSymptom, IsSymptom = p8.IsSymptom,
Id = p7.Id Id = p8.Id
}; };
} }
} }

View File

@ -4,219 +4,227 @@ using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using DocuMed.Domain.Dtos.LargDtos; using DocuMed.Domain.Dtos.LargDtos;
using DocuMed.Domain.Dtos.SmallDtos; using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.Hospitals; using DocuMed.Domain.Entities.City;
using DocuMed.Domain.Entities.MedicalHistoryTemplate; using DocuMed.Domain.Entities.MedicalHistoryTemplate;
namespace DocuMed.Domain.Mappers namespace DocuMed.Domain.Mappers
{ {
public static partial class MedicalHistoryTemplateMapper public static partial class MedicalHistoryTemplateMapper
{ {
public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateLDto p1) public static MedicalHistoryTemplate AdaptToMedicalHistoryTemplate(this MedicalHistoryTemplateSDto p1)
{ {
return p1 == null ? null : new MedicalHistoryTemplate() return p1 == null ? null : new MedicalHistoryTemplate()
{ {
ChiefComplaint = p1.ChiefComplaint, ChiefComplaint = p1.ChiefComplaint,
SectionId = p1.SectionId, 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, ApplicationUserId = p1.ApplicationUserId,
Questions = funcMain1(p1.Questions),
Id = p1.Id, Id = p1.Id,
CreatedAt = p1.CreatedAt CreatedAt = p1.CreatedAt
}; };
} }
public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateLDto p3, MedicalHistoryTemplate p4) public static MedicalHistoryTemplate AdaptTo(this MedicalHistoryTemplateSDto p2, MedicalHistoryTemplate p3)
{
if (p3 == null)
{
return null;
}
MedicalHistoryTemplate result = p4 ?? new MedicalHistoryTemplate();
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<Func<MedicalHistoryTemplateLDto, MedicalHistoryTemplate>> ProjectToMedicalHistoryTemplate => p9 => new MedicalHistoryTemplate()
{
ChiefComplaint = p9.ChiefComplaint,
SectionId = p9.SectionId,
Section = p9.Section == null ? null : new Section()
{
Name = p9.Section.Name,
Detail = p9.Section.Detail,
HospitalId = p9.Section.HospitalId,
Id = p9.Section.Id
},
ApplicationUserId = p9.ApplicationUserId,
Questions = p9.Questions.Select<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>(p10 => new MedicalHistoryQuestion()
{
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<MedicalHistoryQuestion>(),
Id = p9.Id,
CreatedAt = p9.CreatedAt
};
public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p11)
{
return p11 == null ? null : new MedicalHistoryTemplateLDto()
{
ChiefComplaint = p11.ChiefComplaint,
SectionId = p11.SectionId,
Section = p11.Section == null ? null : new SectionSDto()
{
Name = p11.Section.Name,
Detail = p11.Section.Detail,
HospitalId = p11.Section.HospitalId,
Id = p11.Section.Id
},
ApplicationUserId = p11.ApplicationUserId,
CreatedAt = p11.CreatedAt,
Questions = funcMain4(p11.Questions),
Id = p11.Id
};
}
public static MedicalHistoryTemplateLDto AdaptTo(this MedicalHistoryTemplate p13, MedicalHistoryTemplateLDto p14)
{
if (p13 == null)
{
return null;
}
MedicalHistoryTemplateLDto result = p14 ?? new MedicalHistoryTemplateLDto();
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;
}
public static Expression<Func<MedicalHistoryTemplate, MedicalHistoryTemplateLDto>> ProjectToLDto => p19 => new MedicalHistoryTemplateLDto()
{
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<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>(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<MedicalHistoryQuestionSDto>(),
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;
}
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<Func<MedicalHistoryTemplate, MedicalHistoryTemplateSDto>> 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<MedicalHistoryQuestion> funcMain1(List<MedicalHistoryQuestionSDto> p2)
{ {
if (p2 == null) if (p2 == null)
{ {
return null; return null;
} }
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p2.Count); MedicalHistoryTemplate result = p3 ?? new MedicalHistoryTemplate();
result.ChiefComplaint = p2.ChiefComplaint;
result.SectionId = p2.SectionId;
result.ApplicationUserId = p2.ApplicationUserId;
result.Id = p2.Id;
result.CreatedAt = p2.CreatedAt;
return result;
}
public static Expression<Func<MedicalHistoryTemplateSDto, MedicalHistoryTemplate>> ProjectToMedicalHistoryTemplate => p4 => 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 = 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<Func<MedicalHistoryTemplate, MedicalHistoryTemplateSDto>> 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<Func<MedicalHistoryTemplateLDto, MedicalHistoryTemplate>> 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
},
ApplicationUserId = p17.ApplicationUserId,
Questions = p17.Questions.Select<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>(p18 => 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
}).ToList<MedicalHistoryQuestion>(),
Id = p17.Id,
CreatedAt = p17.CreatedAt
};
public static MedicalHistoryTemplateLDto AdaptToLDto(this MedicalHistoryTemplate p19)
{
return p19 == null ? null : new MedicalHistoryTemplateLDto()
{
ChiefComplaint = p19.ChiefComplaint,
SectionId = p19.SectionId,
Section = p19.Section == null ? null : new SectionSDto()
{
Name = p19.Section.Name,
Detail = p19.Section.Detail,
UniversityId = p19.Section.UniversityId,
Id = p19.Section.Id
},
ApplicationUserId = p19.ApplicationUserId,
CreatedAt = p19.CreatedAt,
Questions = funcMain4(p19.Questions),
Id = p19.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<Func<MedicalHistoryTemplate, MedicalHistoryTemplateLDto>> 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<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>(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<MedicalHistoryQuestionSDto>(),
Id = p27.Id
};
private static List<MedicalHistoryQuestion> funcMain1(List<MedicalHistoryQuestionSDto> p10)
{
if (p10 == null)
{
return null;
}
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p10.Count);
int i = 0; int i = 0;
int len = p2.Count; int len = p10.Count;
while (i < len) while (i < len)
{ {
MedicalHistoryQuestionSDto item = p2[i]; MedicalHistoryQuestionSDto item = p10[i];
result.Add(item == null ? null : new MedicalHistoryQuestion() result.Add(item == null ? null : new MedicalHistoryQuestion()
{ {
Question = item.Question, Question = item.Question,
@ -234,36 +242,36 @@ namespace DocuMed.Domain.Mappers
} }
private static Section funcMain2(SectionSDto p5, Section p6) private static Section funcMain2(SectionSDto p13, Section p14)
{ {
if (p5 == null) if (p13 == null)
{ {
return null; return null;
} }
Section result = p6 ?? new Section(); Section result = p14 ?? new Section();
result.Name = p5.Name; result.Name = p13.Name;
result.Detail = p5.Detail; result.Detail = p13.Detail;
result.HospitalId = p5.HospitalId; result.UniversityId = p13.UniversityId;
result.Id = p5.Id; result.Id = p13.Id;
return result; return result;
} }
private static List<MedicalHistoryQuestion> funcMain3(List<MedicalHistoryQuestionSDto> p7, List<MedicalHistoryQuestion> p8) private static List<MedicalHistoryQuestion> funcMain3(List<MedicalHistoryQuestionSDto> p15, List<MedicalHistoryQuestion> p16)
{ {
if (p7 == null) if (p15 == null)
{ {
return null; return null;
} }
List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p7.Count); List<MedicalHistoryQuestion> result = new List<MedicalHistoryQuestion>(p15.Count);
int i = 0; int i = 0;
int len = p7.Count; int len = p15.Count;
while (i < len) while (i < len)
{ {
MedicalHistoryQuestionSDto item = p7[i]; MedicalHistoryQuestionSDto item = p15[i];
result.Add(item == null ? null : new MedicalHistoryQuestion() result.Add(item == null ? null : new MedicalHistoryQuestion()
{ {
Question = item.Question, Question = item.Question,
@ -281,20 +289,20 @@ namespace DocuMed.Domain.Mappers
} }
private static List<MedicalHistoryQuestionSDto> funcMain4(List<MedicalHistoryQuestion> p12) private static List<MedicalHistoryQuestionSDto> funcMain4(List<MedicalHistoryQuestion> p20)
{ {
if (p12 == null) if (p20 == null)
{ {
return null; return null;
} }
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p12.Count); List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p20.Count);
int i = 0; int i = 0;
int len = p12.Count; int len = p20.Count;
while (i < len) while (i < len)
{ {
MedicalHistoryQuestion item = p12[i]; MedicalHistoryQuestion item = p20[i];
result.Add(item == null ? null : new MedicalHistoryQuestionSDto() result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
{ {
Question = item.Question, Question = item.Question,
@ -312,36 +320,36 @@ namespace DocuMed.Domain.Mappers
} }
private static SectionSDto funcMain5(Section p15, SectionSDto p16) private static SectionSDto funcMain5(Section p23, SectionSDto p24)
{ {
if (p15 == null) if (p23 == null)
{ {
return null; return null;
} }
SectionSDto result = p16 ?? new SectionSDto(); SectionSDto result = p24 ?? new SectionSDto();
result.Name = p15.Name; result.Name = p23.Name;
result.Detail = p15.Detail; result.Detail = p23.Detail;
result.HospitalId = p15.HospitalId; result.UniversityId = p23.UniversityId;
result.Id = p15.Id; result.Id = p23.Id;
return result; return result;
} }
private static List<MedicalHistoryQuestionSDto> funcMain6(List<MedicalHistoryQuestion> p17, List<MedicalHistoryQuestionSDto> p18) private static List<MedicalHistoryQuestionSDto> funcMain6(List<MedicalHistoryQuestion> p25, List<MedicalHistoryQuestionSDto> p26)
{ {
if (p17 == null) if (p25 == null)
{ {
return null; return null;
} }
List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p17.Count); List<MedicalHistoryQuestionSDto> result = new List<MedicalHistoryQuestionSDto>(p25.Count);
int i = 0; int i = 0;
int len = p17.Count; int len = p25.Count;
while (i < len) while (i < len)
{ {
MedicalHistoryQuestion item = p17[i]; MedicalHistoryQuestion item = p25[i];
result.Add(item == null ? null : new MedicalHistoryQuestionSDto() result.Add(item == null ? null : new MedicalHistoryQuestionSDto()
{ {
Question = item.Question, Question = item.Question,

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Linq.Expressions; using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos; using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.Hospitals; using DocuMed.Domain.Entities.City;
namespace DocuMed.Domain.Mappers namespace DocuMed.Domain.Mappers
{ {
@ -13,7 +13,7 @@ namespace DocuMed.Domain.Mappers
{ {
Name = p1.Name, Name = p1.Name,
Detail = p1.Detail, Detail = p1.Detail,
HospitalId = p1.HospitalId, UniversityId = p1.UniversityId,
Id = p1.Id Id = p1.Id
}; };
} }
@ -27,7 +27,7 @@ namespace DocuMed.Domain.Mappers
result.Name = p2.Name; result.Name = p2.Name;
result.Detail = p2.Detail; result.Detail = p2.Detail;
result.HospitalId = p2.HospitalId; result.UniversityId = p2.UniversityId;
result.Id = p2.Id; result.Id = p2.Id;
return result; return result;
@ -36,7 +36,7 @@ namespace DocuMed.Domain.Mappers
{ {
Name = p4.Name, Name = p4.Name,
Detail = p4.Detail, Detail = p4.Detail,
HospitalId = p4.HospitalId, UniversityId = p4.UniversityId,
Id = p4.Id Id = p4.Id
}; };
public static SectionSDto AdaptToSDto(this Section p5) public static SectionSDto AdaptToSDto(this Section p5)
@ -45,7 +45,7 @@ namespace DocuMed.Domain.Mappers
{ {
Name = p5.Name, Name = p5.Name,
Detail = p5.Detail, Detail = p5.Detail,
HospitalId = p5.HospitalId, UniversityId = p5.UniversityId,
Id = p5.Id Id = p5.Id
}; };
} }
@ -59,7 +59,7 @@ namespace DocuMed.Domain.Mappers
result.Name = p6.Name; result.Name = p6.Name;
result.Detail = p6.Detail; result.Detail = p6.Detail;
result.HospitalId = p6.HospitalId; result.UniversityId = p6.UniversityId;
result.Id = p6.Id; result.Id = p6.Id;
return result; return result;
@ -68,7 +68,7 @@ namespace DocuMed.Domain.Mappers
{ {
Name = p8.Name, Name = p8.Name,
Detail = p8.Detail, Detail = p8.Detail,
HospitalId = p8.HospitalId, UniversityId = p8.UniversityId,
Id = p8.Id Id = p8.Id
}; };
} }

View File

@ -1,157 +0,0 @@
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<Func<StudentSDto, Student>> 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<Func<Student, StudentSDto>> 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;
}
}
}

View File

@ -9,13 +9,8 @@ public class MapsterRegister : IRegister
.TwoWays(); .TwoWays();
config.NewConfig<Student, StudentSDto>() config.NewConfig<ApplicationUser, ApplicationUserSDto>()
.Map(des=>des.SectionName, org => org.Section != null ? org.Section.Name : string.Empty) .Map("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(); .TwoWays();
} }
} }

View File

@ -1,8 +0,0 @@
namespace DocuMed.Domain.Models;
public static class Refers
{
public const int SizeS = 10;
public const int SizeM = 15;
public const int SizeL = 20;
}

View File

@ -4,9 +4,7 @@ public interface IKaveNegarRestApi
{ {
[Post("/{apiKey}/verify/lookup.json")] [Post("/{apiKey}/verify/lookup.json")]
Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string template, [Query] string token, [Query] string? token2 = null, Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string token, [Query] string token2, [Query] string token10, [Query] string token20, [Query] string template);
[Query] string? token3 = null, [Query] string? token10 = null, [Query] string? token20 = null);
[Post("/{apiKey}/sms/send.json")] [Post("/{apiKey}/sms/send.json")]
Task<KaveNegarResponse> SendSms(string apiKey, [Query] string receptor, [Query] string message, [Query] string sender); Task<KaveNegarResponse> SendSms(string apiKey, [Query] string receptor, [Query] string message, [Query] string sender);
} }

View File

@ -1,71 +1,33 @@
using Microsoft.Extensions.Hosting; namespace DocuMed.Infrastructure.Services;
using System;
namespace DocuMed.Infrastructure.Services;
public class SmsService( public class SmsService : ISmsService
IRestApiWrapper restApiWrapper,
IOptionsSnapshot<SiteSettings> optionsSnapshot,
ILogger<SmsService> logger,
IHostEnvironment environment) : ISmsService
{ {
private readonly ILogger<SmsService> _logger = logger; private readonly IRestApiWrapper _restApiWrapper;
private readonly SiteSettings _siteSettings = optionsSnapshot.Value; private readonly ILogger<SmsService> _logger;
private readonly SiteSettings _siteSettings;
public SmsService(IRestApiWrapper restApiWrapper,
IOptionsSnapshot<SiteSettings> optionsSnapshot,
ILogger<SmsService> logger)
{
_restApiWrapper = restApiWrapper;
_logger = logger;
_siteSettings = optionsSnapshot.Value;
}
public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword) public async Task SendForgerPasswordAsync(string phoneNumber, string newPassword)
{ {
var rest = await restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, "forgetPassword", newPassword, var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, newPassword, null, null, null, "forgetPassword");
null, null , null, null);
if (rest.Return.status != 200) if (rest.Return?.status != 200)
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message); throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
} }
public async Task SendVerifyCodeAsync(string phoneNumber, string verifyCode) public async Task SendVerifyCodeAsync(string phoneNumber, string verifyCode)
{ {
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, verifyCode, null, null, null, "login-documed");
try if (rest.Return?.status != 200)
{ throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return?.message);
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);
}
}
} }

View File

@ -16,7 +16,7 @@
<PackageReference Include="Blazorise.LottieAnimation" Version="1.6.1" /> <PackageReference Include="Blazorise.LottieAnimation" Version="1.6.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="6.13.0" /> <PackageReference Include="MudBlazor" Version="7.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Refit" Version="7.2.1" /> <PackageReference Include="Refit" Version="7.2.1" />
<PackageReference Include="Refit.HttpClientFactory" Version="7.2.1" /> <PackageReference Include="Refit.HttpClientFactory" Version="7.2.1" />

View File

@ -3,7 +3,7 @@
public static class Address public static class Address
{ {
#if DEBUG #if DEBUG
public static string BaseAddress = "http://localhost:32780/api"; public static string BaseAddress = "http://localhost:32770/api";
//public static string BaseAddress = "https://api.documed.ir/api"; //public static string BaseAddress = "https://api.documed.ir/api";
#else #else
public static string BaseAddress = "https://api.documed.ir/api"; public static string BaseAddress = "https://api.documed.ir/api";

View File

@ -1,16 +1,25 @@
namespace DocuMed.PWA.Models.Api; namespace DocuMed.PWA.Models.Api;
public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) public class ApiResult
{ {
public bool IsSuccess { get; set; } = isSuccess; public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null)
public ApiResultStatusCode StatusCode { get; set; } = statusCode; {
IsSuccess = isSuccess;
StatusCode = statusCode;
Message = message ?? statusCode.ToDisplay();
}
public string Message { get; set; } = message ?? statusCode.ToDisplay(); public bool IsSuccess { get; set; }
public ApiResultStatusCode StatusCode { get; set; }
public string Message { get; set; }
} }
public class ApiResult<TData>(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) public class ApiResult<TData> : ApiResult where TData : class
: ApiResult(isSuccess, statusCode, message)
where TData : class
{ {
public TData Data { get; set; } = data; public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) : base(isSuccess, statusCode, message)
{
Data = data;
}
public TData Data { get; set; }
} }

View File

@ -17,8 +17,11 @@ public class BaseViewModel
public class BaseViewModel<TPageDto> public class BaseViewModel<TPageDto>
{ {
public bool IsProcessing { get; set; } = false; public bool IsProcessing { get; set; } = false;
public TPageDto PageDto { get; set; } = Activator.CreateInstance<TPageDto>(); public TPageDto PageDto { get; set; }
public BaseViewModel()
{
PageDto = Activator.CreateInstance<TPageDto>();
}
public virtual void Initialize() public virtual void Initialize()
{ {

View File

@ -3,11 +3,20 @@ using DocuMed.Domain.Enums.QueryFilters;
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class HomePageViewModel(IUserUtility userUtility, IRestWrapper restWrapper, ISnackbar snackbar) public class HomePageViewModel : BaseViewModel<List<MedicalHistorySDto>>
: BaseViewModel<List<MedicalHistorySDto>>
{ {
private readonly IUserUtility _userUtility;
private readonly IRestWrapper _restWrapper;
private readonly ISnackbar _snackbar;
public DayQueryFilter SelectedDayFilter { get; set; } = DayQueryFilter.Today; 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(); public ApplicationUserSDto User { get; private set; } = new ApplicationUserSDto();
@ -18,9 +27,9 @@ public class HomePageViewModel(IUserUtility userUtility, IRestWrapper restWrappe
try try
{ {
IsProcessing = true; IsProcessing = true;
User = await userUtility.GetUserAsync(); User = await _userUtility.GetUserAsync();
var token = await userUtility.GetBearerTokenAsync(); var token = await _userUtility.GetBearerTokenAsync();
var list = await restWrapper var list = await _restWrapper
.MedicalHistoryRestApi .MedicalHistoryRestApi
.GetAllByFilterAsync(SelectedDayFilter, 0, token); .GetAllByFilterAsync(SelectedDayFilter, 0, token);
PageDto = list; PageDto = list;
@ -29,11 +38,11 @@ public class HomePageViewModel(IUserUtility userUtility, IRestWrapper restWrappe
catch (ApiException ex) catch (ApiException ex)
{ {
var exe = await ex.GetContentAsAsync<ApiResult>(); var exe = await ex.GetContentAsAsync<ApiResult>();
snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
} }
catch (Exception e) catch (Exception e)
{ {
snackbar.Add(e.Message, Severity.Error); _snackbar.Add(e.Message, Severity.Error);
} }
finally finally
{ {

View File

@ -15,24 +15,24 @@
color: white; color: white;
} */ } */
</style> </style>
<div class="flex h-screen w-screen flex-col"> <div class="flex flex-col w-screen h-screen">
<div class="w-full basis-2/4 overflow-hidden"> <div class="w-full overflow-hidden basis-2/4">
<MudCarousel class="h-full w-full" ShowArrows="false" ShowBullets="false" EnableSwipeGesture="true" <MudCarousel class="w-full h-full" ShowArrows="false" ShowBullets="false" EnableSwipeGesture="true"
AutoCycle="true" TData="object"> AutoCycle="true" TData="object">
<MudCarouselItem> <MudCarouselItem>
<div class="mx-5 flex h-full flex-col"> <div class="flex flex-col h-full mx-5">
<div class="my-auto"> <div class="my-auto">
<div class="-mt-8"> <div class="-mt-8">
<dotlottie-player src="https://lottie.host/752358b3-21b0-4448-b8f4-0f2a2acc998b/DZAZuyYyol.json" <dotlottie-player src="https://lottie.host/752358b3-21b0-4448-b8f4-0f2a2acc998b/DZAZuyYyol.json"
background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay /> background="transparent" speed="1" class="m-auto w-60 h-60" loop autoplay />
</div> </div>
<p class="font-iranyekan mx-auto text-center text-lg font-extrabold"> <p class="mx-auto text-lg font-extrabold text-center font-iranyekan">
شرح حال نویسی بیمار راحت تر شرح حال نویسی بیمار راحت تر
از از
همیشه همیشه
</p> </p>
<p class="font-iranyekan mx-auto text-center text-xs"> <p class="mx-auto text-xs text-center font-iranyekan">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم
@ -41,17 +41,17 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="mx-5 flex h-full flex-col"> <div class="flex flex-col h-full mx-5">
<div class="my-auto"> <div class="my-auto">
<div class="-mb-3 -mt-8"> <div class="-mt-8 -mb-3">
<dotlottie-player src="https://lottie.host/9ca6089d-388f-4eef-8050-8181c1d945a1/B7oM9NN9O4.json" <dotlottie-player src="https://lottie.host/9ca6089d-388f-4eef-8050-8181c1d945a1/B7oM9NN9O4.json"
background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay /> background="transparent" speed="1" class="m-auto w-60 h-60" loop autoplay />
</div> </div>
<p class="font-iranyekan mx-auto text-center text-lg font-extrabold"> <p class="mx-auto text-lg font-extrabold text-center font-iranyekan">
اوردر های شما همه در یک اوردر های شما همه در یک
اپلیکیشن اپلیکیشن
</p> </p>
<p class="font-iranyekan mx-auto text-center text-xs"> <p class="mx-auto text-xs text-center font-iranyekan">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل شرح حال نویسی همیار همیشگی پزشکان محترم مثل شرح حال نویسی همیار همیشگی پزشکان محترم
@ -60,16 +60,16 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="mx-5 flex h-full flex-col"> <div class="flex flex-col h-full mx-5">
<div class="my-auto"> <div class="my-auto">
<div class="-mb-10 -mt-8"> <div class="-mt-8 -mb-10">
<dotlottie-player src="https://lottie.host/87dfb50f-e91f-45c6-b8dc-d3a2436c533c/5DPvXG0W1t.json" <dotlottie-player src="https://lottie.host/87dfb50f-e91f-45c6-b8dc-d3a2436c533c/5DPvXG0W1t.json"
background="transparent" speed="1" class="m-auto h-72 w-72" loop autoplay /> background="transparent" speed="1" class="m-auto w-72 h-72" loop autoplay />
</div> </div>
<p class="font-iranyekan mx-auto text-center text-lg font-extrabold"> <p class="mx-auto text-lg font-extrabold text-center font-iranyekan">
نرم افزار جامع داکیـــــومد نرم افزار جامع داکیـــــومد
</p> </p>
<p class="font-iranyekan mx-auto text-center text-xs"> <p class="mx-auto text-xs text-center font-iranyekan">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم
@ -79,14 +79,14 @@
</MudCarouselItem> </MudCarouselItem>
</MudCarousel> </MudCarousel>
</div> </div>
<MudPaper Elevation="10" class="w-full basis-2/4 rounded-t-2xl bg-[#FFFBE6]"> <MudPaper Elevation="10" class="w-full rounded-t-2xl bg-[#FFFBE6] basis-2/4">
<MudCarousel class="h-full w-full overflow-x-hidden overflow-y-scroll" @ref="_carousel" ShowArrows="false" <MudCarousel class="w-full h-full overflow-x-hidden overflow-y-scroll" @ref="_carousel" ShowArrows="false"
ShowBullets="false" EnableSwipeGesture="false" AutoCycle="false" TData="object"> ShowBullets="false" EnableSwipeGesture="false" AutoCycle="false" TData="object">
<MudCarouselItem> <MudCarouselItem>
<div class="font-iranyekan flex h-full flex-col p-5"> <div class="flex flex-col h-full p-5 font-iranyekan">
<MudStack class="my-auto"> <MudStack class="my-auto">
<p class="font-iranyekan text-lg font-extrabold">ورود | ثبت نام</p> <p class="text-lg font-extrabold font-iranyekan">ورود | ثبت نام</p>
<p class="text-justify text-xs"> <p class="text-xs text-justify">
برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را
وارد کنید وارد کنید
</p> </p>
@ -109,11 +109,11 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="flex h-full flex-col"> <div class="flex flex-col h-full">
<MudStack class="font-iranyekan my-auto p-5"> <MudStack class="p-5 my-auto font-iranyekan">
<p class="font-iranyekan text-lg font-extrabold">ورود | ثبت نام</p> <p class="text-lg font-extrabold font-iranyekan">ورود | ثبت نام</p>
<p class="text-justify text-xs"> <p class="text-xs text-justify">
برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را
وارد کنید وارد کنید
</p> </p>
@ -125,7 +125,7 @@
Icon="@Icons.Material.TwoTone.Verified" Color="Color.Secondary" Variant="Variant.Filled"> Icon="@Icons.Material.TwoTone.Verified" Color="Color.Secondary" Variant="Variant.Filled">
</BaseButtonUi> </BaseButtonUi>
<div class="mr-5 flex flex-row"> <div class="flex flex-row mr-5">
<MudStack class="my-auto"> <MudStack class="my-auto">
<p class="text-lg font-extrabold">02:00</p> <p class="text-lg font-extrabold">02:00</p>
<a class="-mt-5 font-bold text-blue-600">ارسال مجدد پیامک</a> <a class="-mt-5 font-bold text-blue-600">ارسال مجدد پیامک</a>
@ -141,19 +141,19 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="flex h-full flex-col"> <div class="flex flex-col h-full">
<MudStack class="font-iranyekan my-auto w-screen p-5"> <MudStack class="w-screen p-5 my-auto font-iranyekan">
<p class="font-iranyekan text-lg font-extrabold">ثبت نام</p> <p class="text-lg font-extrabold font-iranyekan">ثبت نام</p>
<p class="text-justify text-xs"> <p class="text-xs text-justify">
برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد
کنید کنید
</p> </p>
<MudForm @ref="_confirmSignUpForm"> <MudForm @ref="_confirmSignUpForm">
<MudFocusTrap> <MudFocusTrap>
<MudTextField Required="true" RequiredError="نام خود را وارد کنید" @bind-Value="@_signUpRequest.FirstName" class="my-5 text-sm" T="string" Label="نام" Variant="Variant.Outlined" /> <MudTextField Required="true" RequiredError="نام خود را وارد کنید" @bind-Value="@_signUpRequest.FirstName" class="text-sm my-5" T="string" Label="نام" Variant="Variant.Outlined" />
<MudTextField Required="true" RequiredError="نام خانوادگی خود را وارد کنید" @bind-Value="@_signUpRequest.LastName" class="my-5 text-sm" T="string" Label="نام خانوادگی" Variant="Variant.Outlined" /> <MudTextField Required="true" RequiredError="نام خانوادگی خود را وارد کنید" @bind-Value="@_signUpRequest.LastName" class="text-sm my-5" T="string" Label="نام خانوادگی" Variant="Variant.Outlined" />
<MudTextField class="my-5 text-sm" T="string" @bind-Value="@_phoneNumber" Label="شماره تلفن همراه" <MudTextField class="text-sm my-5" T="string" @bind-Value="@_phoneNumber" Label="شماره تلفن همراه"
Variant="Variant.Outlined" /> Variant="Variant.Outlined" />
<MudAutocomplete Required="true" ToStringFunc="dto => dto.Name" class="my-5" @bind-Value="@_selectedCity" <MudAutocomplete Required="true" ToStringFunc="dto => dto.Name" class="my-5" @bind-Value="@_selectedCity"
@ -164,9 +164,9 @@
<ProgressIndicatorInPopoverTemplate> <ProgressIndicatorInPopoverTemplate>
<MudList Clickable="false"> <MudList Clickable="false">
<MudListItem> <MudListItem>
<div class="mx-auto flex w-full flex-row"> <div class="flex flex-row w-full mx-auto">
<MudProgressCircular class="my-auto -ml-4 mr-1" Size="Size.Small" Indeterminate="true" /> <MudProgressCircular class="my-auto mr-1 -ml-4" Size="Size.Small" Indeterminate="true" />
<p class="text-md mx-auto my-1 font-bold">منتظر بمانید</p> <p class="font-bold my-1 mx-auto text-md">منتظر بمانید</p>
</div> </div>
</MudListItem> </MudListItem>
</MudList> </MudList>
@ -180,9 +180,9 @@
<ProgressIndicatorInPopoverTemplate> <ProgressIndicatorInPopoverTemplate>
<MudList Clickable="false"> <MudList Clickable="false">
<MudListItem> <MudListItem>
<div class="mx-auto flex w-full flex-row"> <div class="flex flex-row w-full mx-auto">
<MudProgressCircular class="my-auto -ml-4 mr-1" Size="Size.Small" Indeterminate="true" /> <MudProgressCircular class="my-auto mr-1 -ml-4" Size="Size.Small" Indeterminate="true" />
<p class="text-md mx-auto my-1 font-bold">منتظر بمانید</p> <p class="font-bold my-1 mx-auto text-md">منتظر بمانید</p>
</div> </div>
</MudListItem> </MudListItem>
</MudList> </MudList>

View File

@ -1,7 +1,6 @@
using DocuMed.PWA.Shared.Dialogs; using DocuMed.PWA.Shared.Dialogs;
using Mapster; using Mapster;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;

View File

@ -1,14 +1,21 @@
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class MedicalHistoryTemplatesPageViewModel( public class MedicalHistoryTemplatesPageViewModel : BaseViewModel<List<MedicalHistoryTemplateSDto>>
NavigationManager navigationManager,
IUserUtility userUtility,
IRestWrapper restWrapper,
ISnackbar snackbar)
: BaseViewModel<List<MedicalHistoryTemplateSDto>>
{ {
public void CreateMedicalHistoryTemplateClicked() => navigationManager.NavigateTo("MedicalHistoryTemplateActionPage"); private readonly NavigationManager _navigationManager;
public void MedicalHistoryTemplateClicked(MedicalHistoryTemplateSDto template) => navigationManager.NavigateTo($"MedicalHistoryTemplateActionPage/{template.Id.ToString()}"); 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 override async Task InitializeAsync() public override async Task InitializeAsync()
{ {
@ -16,8 +23,8 @@ public class MedicalHistoryTemplatesPageViewModel(
{ {
IsProcessing = true; IsProcessing = true;
await Task.Delay(500); await Task.Delay(500);
var token = await userUtility.GetBearerTokenAsync(); var token = await _userUtility.GetBearerTokenAsync();
var list = await restWrapper var list = await _restWrapper
.CrudDtoApiRest<MedicalHistoryTemplateLDto, MedicalHistoryTemplateSDto, Guid>( Address.MedicalHistoryTemplateController) .CrudDtoApiRest<MedicalHistoryTemplateLDto, MedicalHistoryTemplateSDto, Guid>( Address.MedicalHistoryTemplateController)
.ReadAll(0, token); .ReadAll(0, token);
PageDto = list; PageDto = list;
@ -26,11 +33,11 @@ public class MedicalHistoryTemplatesPageViewModel(
catch (ApiException ex) catch (ApiException ex)
{ {
var exe = await ex.GetContentAsAsync<ApiResult>(); var exe = await ex.GetContentAsAsync<ApiResult>();
snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
} }
catch (Exception e) catch (Exception e)
{ {
snackbar.Add(e.Message, Severity.Error); _snackbar.Add(e.Message, Severity.Error);
} }
finally finally
{ {

View File

@ -3,16 +3,12 @@ using Mapster;
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class ProfilePageViewModel( public class ProfilePageViewModel : BaseViewModel
IUserUtility userUtility,
IRestWrapper restWrapper,
ISnackbar snackbar,
NavigationManager navigationManager)
: BaseViewModel
{ {
public IUserUtility UserUtility { get; } = userUtility; private readonly NavigationManager _navigationManager;
public IRestWrapper RestWrapper { get; } = restWrapper; public IUserUtility UserUtility { get; }
public ISnackbar Snackbar { get; } = snackbar; public IRestWrapper RestWrapper { get; }
public ISnackbar Snackbar { get; }
public ApplicationUserSDto User { get; set; } = new(); public ApplicationUserSDto User { get; set; } = new();
@ -25,6 +21,14 @@ public class ProfilePageViewModel(
public readonly string Version = Assembly.GetAssembly(typeof(Program))?.GetName()?.Version?.ToString() ?? string.Empty; 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() public override async Task InitializeAsync()
{ {
User = await UserUtility.GetUserAsync(); User = await UserUtility.GetUserAsync();
@ -89,7 +93,7 @@ public class ProfilePageViewModel(
public async Task LogoutAsync() public async Task LogoutAsync()
{ {
await UserUtility.LogoutAsync(); await UserUtility.LogoutAsync();
navigationManager.NavigateTo(""); _navigationManager.NavigateTo("");
} }

View File

@ -1,6 +1,4 @@
using Section = DocuMed.Domain.Entities.Hospitals.Section; namespace DocuMed.PWA.Services.RestServices;
namespace DocuMed.PWA.Services.RestServices;
public interface ISectionRestApi : ICrudDtoApiRest<Section,SectionSDto,Guid> public interface ISectionRestApi : ICrudDtoApiRest<Section,SectionSDto,Guid>
{ {

View File

@ -2,17 +2,24 @@
namespace DocuMed.PWA.Utilities; namespace DocuMed.PWA.Utilities;
public class UserUtility(ILocalStorageService localStorageService) : IUserUtility public class UserUtility : IUserUtility
{ {
public async Task<string> GetBearerTokenAsync() => await localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token); private readonly ILocalStorageService _localStorageService;
public async Task SetBearerTokenAsync(string token) => await localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token, token);
public async Task<ApplicationUserSDto> GetUserAsync() => await localStorageService.GetItemAsync<ApplicationUserSDto>(LocalStorageKeys.UserInfo); public UserUtility(ILocalStorageService localStorageService)
public async Task SetUserAsync(ApplicationUserSDto user) => await localStorageService.SetItemAsync<ApplicationUserSDto>(LocalStorageKeys.UserInfo, user); {
_localStorageService = localStorageService;
}
public async Task<string> GetBearerTokenAsync() => await _localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token);
public async Task SetBearerTokenAsync(string token) => await _localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token, token);
public async Task<ApplicationUserSDto> GetUserAsync() => await _localStorageService.GetItemAsync<ApplicationUserSDto>(LocalStorageKeys.UserInfo);
public async Task SetUserAsync(ApplicationUserSDto user) => await _localStorageService.SetItemAsync<ApplicationUserSDto>(LocalStorageKeys.UserInfo, user);
public async Task LogoutAsync() public async Task LogoutAsync()
{ {
await localStorageService.RemoveItemAsync(LocalStorageKeys.Token); await _localStorageService.RemoveItemAsync(LocalStorageKeys.Token);
await localStorageService.RemoveItemAsync(LocalStorageKeys.UserInfo); await _localStorageService.RemoveItemAsync(LocalStorageKeys.UserInfo);
} }
//public AccessToken<ApplicationUserSDto>? AccessToken { get; set; } //public AccessToken<ApplicationUserSDto>? AccessToken { get; set; }

View File

@ -1,111 +1,5 @@
*, ::before, ::after { /*
--tw-border-spacing-x: 0; ! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com
--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) 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) 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
@ -509,6 +403,114 @@ video {
--color-medicalhistory: rgba(253, 216, 53, 1); --color-medicalhistory: rgba(253, 216, 53, 1);
--color-medicalhistory-template: rgba(41, 187, 189, 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 { .visible {
visibility: visible; visibility: visible;
} }

View File

@ -1,69 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pluralize.NET" Version="1.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DocuMed.Domain\DocuMed.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="DocuMed.Common.Extensions" />
<Using Include="DocuMed.Common.Models" />
<Using Include="DocuMed.Common.Models.Api" />
<Using Include="DocuMed.Common.Models.Claims" />
<Using Include="DocuMed.Common.Models.Entity" />
<Using Include="DocuMed.Common.Models.Exception" />
<Using Include="DocuMed.Domain.Dtos.LargDtos" />
<Using Include="DocuMed.Domain.Dtos.SmallDtos" />
<Using Include="DocuMed.Domain.Entities.MedicalHistory" />
<Using Include="DocuMed.Domain.Entities.MedicalHistoryTemplate" />
<Using Include="DocuMed.Domain.Entities.User" />
<Using Include="DocuMed.Domain.Enums" />
<Using Include="DocuMed.Domain.Enums.QueryFilters" />
<Using Include="DocuMed.Domain.Mappers" />
<Using Include="DocuMed.Domain.Models.Settings" />
<Using Include="DocuMed.Repository.Abstracts" />
<Using Include="DocuMed.Repository.Extensions" />
<Using Include="DocuMed.Repository.Models" />
<Using Include="DocuMed.Repository.Repositories.Base" />
<Using Include="DocuMed.Repository.Repositories.Base.Contracts" />
<Using Include="DocuMed.Repository.Repositories.Entities.Abstracts" />
<Using Include="DocuMed.Repository.Services.Contracts" />
<Using Include="MediatR" />
<Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
<Using Include="Microsoft.EntityFrameworkCore.Infrastructure" />
<Using Include="Microsoft.EntityFrameworkCore.Storage" />
<Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="Microsoft.Extensions.Logging" />
<Using Include="Microsoft.Extensions.Options" />
<Using Include="Pluralize.NET" />
<Using Include="System.Diagnostics" />
<Using Include="System.Reflection" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
@ -24,49 +24,45 @@
<PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" /> <PackageReference Include="StackExchange.Redis.Extensions.Core" Version="10.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DocuMed.Domain\DocuMed.Domain.csproj" /> <ProjectReference Include="..\DocuMed.Domain\DocuMed.Domain.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Using Include="DocuMed.Domain.CommandQueries.Queries" /> <Using Include="DocuMed.Common.Extensions" />
<Using Include="DocuMed.Domain.Entities.Hospitals" /> <Using Include="DocuMed.Common.Models" />
<Using Include="DocuMed.Common.Extensions" /> <Using Include="DocuMed.Common.Models.Api" />
<Using Include="DocuMed.Common.Models" /> <Using Include="DocuMed.Common.Models.Claims" />
<Using Include="DocuMed.Common.Models.Api" /> <Using Include="DocuMed.Common.Models.Entity" />
<Using Include="DocuMed.Common.Models.Claims" /> <Using Include="DocuMed.Common.Models.Exception" />
<Using Include="DocuMed.Common.Models.Entity" /> <Using Include="DocuMed.Domain.Dtos.LargDtos" />
<Using Include="DocuMed.Common.Models.Exception" /> <Using Include="DocuMed.Domain.Dtos.SmallDtos" />
<Using Include="DocuMed.Domain.CommandQueries.Commands" /> <Using Include="DocuMed.Domain.Entities.MedicalHistory" />
<Using Include="DocuMed.Domain.Dtos.LargDtos" /> <Using Include="DocuMed.Domain.Entities.MedicalHistoryTemplate" />
<Using Include="DocuMed.Domain.Dtos.SmallDtos" /> <Using Include="DocuMed.Domain.Entities.User" />
<Using Include="DocuMed.Domain.Entities.MedicalHistory" /> <Using Include="DocuMed.Domain.Enums" />
<Using Include="DocuMed.Domain.Entities.MedicalHistoryTemplate" /> <Using Include="DocuMed.Domain.Enums.QueryFilters" />
<Using Include="DocuMed.Domain.Entities.User" /> <Using Include="DocuMed.Domain.Mappers" />
<Using Include="DocuMed.Domain.Enums" /> <Using Include="DocuMed.Domain.Models.Settings" />
<Using Include="DocuMed.Domain.Enums.QueryFilters" /> <Using Include="DocuMed.Repository.Abstracts" />
<Using Include="DocuMed.Domain.Mappers" /> <Using Include="DocuMed.Repository.Extensions" />
<Using Include="DocuMed.Domain.Models.Settings" /> <Using Include="DocuMed.Repository.Models" />
<Using Include="DocuMed.Repository.Abstracts" /> <Using Include="DocuMed.Repository.Repositories.Base" />
<Using Include="DocuMed.Repository.Extensions" /> <Using Include="DocuMed.Repository.Repositories.Base.Contracts" />
<Using Include="DocuMed.Repository.Models" /> <Using Include="DocuMed.Repository.Repositories.Entities.Abstracts" />
<Using Include="DocuMed.Repository.Repositories.Base" /> <Using Include="DocuMed.Repository.Services.Contracts" />
<Using Include="DocuMed.Repository.Repositories.Base.Contracts" /> <Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="DocuMed.Repository.Repositories.Entities.Abstracts" /> <Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<Using Include="DocuMed.Repository.Services.Contracts" /> <Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="MediatR" /> <Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
<Using Include="Microsoft.AspNetCore.Identity" /> <Using Include="Microsoft.EntityFrameworkCore.Infrastructure" />
<Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" /> <Using Include="Microsoft.EntityFrameworkCore.Storage" />
<Using Include="Microsoft.EntityFrameworkCore" /> <Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" /> <Using Include="Microsoft.Extensions.Logging" />
<Using Include="Microsoft.EntityFrameworkCore.Infrastructure" /> <Using Include="Microsoft.Extensions.Options" />
<Using Include="Microsoft.EntityFrameworkCore.Storage" /> <Using Include="Pluralize.NET" />
<Using Include="Microsoft.Extensions.DependencyInjection" /> <Using Include="System.Diagnostics" />
<Using Include="Microsoft.Extensions.Logging" /> <Using Include="System.Reflection" />
<Using Include="Microsoft.Extensions.Options" /> </ItemGroup>
<Using Include="Pluralize.NET" />
<Using Include="System.Diagnostics" />
<Using Include="System.Reflection" />
</ItemGroup>
</Project> </Project>

View File

@ -1,8 +1,11 @@
namespace DocuMed.Repository.Extensions; namespace DocuMed.Repository.Extensions;
public class DbContextOptionCustomExtensionsInfo(IDbContextOptionsExtension extension) public class DbContextOptionCustomExtensionsInfo : DbContextOptionsExtensionInfo
: DbContextOptionsExtensionInfo(extension)
{ {
public DbContextOptionCustomExtensionsInfo(IDbContextOptionsExtension extension) : base(extension)
{
}
public override bool IsDatabaseProvider { get; } public override bool IsDatabaseProvider { get; }
public override string LogFragment { get; } = string.Empty; public override string LogFragment { get; } = string.Empty;

View File

@ -1,16 +0,0 @@
namespace DocuMed.Repository.Handlers.Hospitals;
public class CreateHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<CreateHospitalCommand, Guid>
{
public async Task<Guid> Handle(CreateHospitalCommand request, CancellationToken cancellationToken)
{
var ent = Hospital.Create(request.Name, request.Detail, request.Address, request.UniversityId);
repositoryWrapper.SetRepository<Hospital>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.Id;
}
}

View File

@ -1,19 +0,0 @@
namespace DocuMed.Repository.Handlers.Hospitals;
public class DeleteHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<DeleteHospitalCommand, Guid>
{
public async Task<Guid> Handle(DeleteHospitalCommand request, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<Hospital>().TableNoTracking
.FirstOrDefaultAsync(h => h.Id == request.Id, cancellationToken);
if (ent == null)
throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found");
repositoryWrapper.SetRepository<Hospital>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.Id;
}
}

View File

@ -1,16 +0,0 @@
namespace DocuMed.Repository.Handlers.Hospitals;
public class GetHospitalQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetHospitalQuery, HospitalSDto>
{
public async Task<HospitalSDto> Handle(GetHospitalQuery request, CancellationToken cancellationToken)
{
var response = await repositoryWrapper.SetRepository<Hospital>()
.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;
}
}

View File

@ -1,16 +0,0 @@
namespace DocuMed.Repository.Handlers.Hospitals;
public class GetHospitalsQueryHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<GetHospitalsQuery, List<HospitalSDto>>
{
public async Task<List<HospitalSDto>> Handle(GetHospitalsQuery request, CancellationToken cancellationToken)
{
var response = await repositoryWrapper.SetRepository<Hospital>()
.TableNoTracking
.Skip(request.Page * request.Size)
.Take(request.Size)
.Select(HospitalMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
return response;
}
}

View File

@ -1,23 +0,0 @@
namespace DocuMed.Repository.Handlers.Hospitals;
public class UpdateHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<UpdateHospitalCommand, Guid>
{
public async Task<Guid> Handle(UpdateHospitalCommand request, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<Hospital>().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<Hospital>().Update(newEnt);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return newEnt.Id;
}
}

View File

@ -1,24 +0,0 @@
namespace DocuMed.Repository.Handlers.MedicalHistories;
public class CreateMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService) : IRequestHandler<CreateMedicalHistoryCommand,Guid>
{
public async Task<Guid> Handle(CreateMedicalHistoryCommand template, CancellationToken cancellationToken)
{
if (!Guid.TryParse(currentUserService.UserId, out Guid userId))
throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized);
var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId,
template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail,
template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail,
template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail,
template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2,
template.Temperature, userId, template.MedicalHistoryTemplateId);
foreach (var answer in template.Answers)
ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType);
repositoryWrapper.SetRepository<MedicalHistory>().Add(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.Id;
}
}

View File

@ -1,16 +0,0 @@
namespace DocuMed.Repository.Handlers.MedicalHistories;
public class DeleteMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<DeleteMedicalHistoryCommand, Guid>
{
public async Task<Guid> Handle(DeleteMedicalHistoryCommand template, CancellationToken cancellationToken)
{
var ent = await repositoryWrapper.SetRepository<MedicalHistory>().TableNoTracking
.FirstOrDefaultAsync(m => m.Id == template.Id, cancellationToken);
if (ent == null)
throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound);
repositoryWrapper.SetRepository<MedicalHistory>().Delete(ent);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return ent.Id;
}
}

View File

@ -1,47 +0,0 @@
namespace DocuMed.Repository.Handlers.MedicalHistories;
public class UpdateMedicalHistoryCommandHandler(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler<UpdateMedicalHistoryCommand, Guid>
{
public async Task<Guid> Handle(UpdateMedicalHistoryCommand template, CancellationToken cancellationToken)
{
if (!Guid.TryParse(currentUserService.UserId, out Guid userId))
throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized);
var ent = await repositoryWrapper.SetRepository<MedicalHistory>().TableNoTracking
.FirstOrDefaultAsync(m => m.Id == template.Id, cancellationToken);
if(ent==null)
throw new AppException("شرح حال پیدا نشد", ApiResultStatusCode.NotFound);
var newEnt = MedicalHistory.Create(template.ChiefComplaint, template.SectionId,
template.PresentIllnessDetail, template.PastDiseasesHistoryDetail, template.PastSurgeryHistoryDetail,
template.FamilyHistoryDetail, template.AllergyDetail, template.DrugHistoryDetail,
template.AddictionHistoryDetail, template.SystemReviewDetail, template.VitalSignDetail, template.GeneralAppearanceDetail,
template.SystolicBloodPressure, template.DiastolicBloodPressure, template.PulseRate, template.SPO2,
template.Temperature, template.ApplicationUserId, template.MedicalHistoryTemplateId);
newEnt.Id = ent.Id;
newEnt.CreatedAt = ent.CreatedAt;
foreach (var answer in template.Answers.Where(a => a.Id == Guid.Empty))
newEnt.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType);
foreach (var answer in template.Answers.Where(a => a.Id != Guid.Empty))
{
var dbAnswer = await repositoryWrapper.SetRepository<MedicalHistoryAnswer>().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<MedicalHistoryAnswer>().Update(dbAnswer);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
}
}
repositoryWrapper.SetRepository<MedicalHistory>().Update(newEnt);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return newEnt.Id;
}
}

View File

@ -0,0 +1,863 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UniversityId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UniversityId");
b.ToTable("Sections", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CityId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Universities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AddictionHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("AllergyDetail")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DiastolicBloodPressure")
.HasColumnType("integer");
b.Property<string>("DrugHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FamilyHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FatherName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastDiseasesHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastSurgeryHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PresentIllnessDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PulseRate")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SPO2")
.HasColumnType("integer");
b.Property<Guid>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SystemReviewDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SystolicBloodPressure")
.HasColumnType("integer");
b.Property<int>("Temperature")
.HasColumnType("integer");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryId");
b.ToTable("MedicalHistoryAnswers", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BodySystem")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsSign")
.HasColumnType("boolean");
b.Property<bool>("IsSymptom")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryTemplateId");
b.ToTable("MedicalHistoryQuestions", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<Guid?>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<int>("SignUpStatus")
.HasColumnType("integer");
b.Property<string>("StudentId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<Guid?>("UniversityId")
.HasColumnType("uuid");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Claims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("Logins", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", 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<System.Guid>", 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
}
}
}

View File

@ -0,0 +1,600 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DocuMed.Repository.Migrations
{
/// <inheritdoc />
public partial class init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "public");
migrationBuilder.CreateTable(
name: "Cities",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
EnglishName = table.Column<string>(type: "text", nullable: false),
PersianName = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
CityId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Detail = table.Column<string>(type: "text", nullable: false),
UniversityId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
FirstName = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false),
NationalId = table.Column<string>(type: "text", nullable: false),
StudentId = table.Column<string>(type: "text", nullable: false),
BirthDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
Gender = table.Column<int>(type: "integer", nullable: false),
SignUpStatus = table.Column<int>(type: "integer", nullable: false),
UniversityId = table.Column<Guid>(type: "uuid", nullable: true),
SectionId = table.Column<Guid>(type: "uuid", nullable: true),
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(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<string>(type: "text", nullable: false),
ProviderKey = table.Column<string>(type: "text", nullable: false),
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false),
ChiefComplaint = table.Column<string>(type: "text", nullable: false),
SectionId = table.Column<Guid>(type: "uuid", nullable: false),
FirstName = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: false),
FatherName = table.Column<string>(type: "text", nullable: false),
NationalId = table.Column<string>(type: "text", nullable: false),
Age = table.Column<int>(type: "integer", nullable: false),
BirthDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
PresentIllnessDetail = table.Column<string>(type: "text", nullable: false),
PastDiseasesHistoryDetail = table.Column<string>(type: "text", nullable: false),
PastSurgeryHistoryDetail = table.Column<string>(type: "text", nullable: false),
FamilyHistoryDetail = table.Column<string>(type: "text", nullable: false),
AllergyDetail = table.Column<string>(type: "text", nullable: false),
DrugHistoryDetail = table.Column<string>(type: "text", nullable: false),
AddictionHistoryDetail = table.Column<string>(type: "text", nullable: false),
SystemReviewDetail = table.Column<string>(type: "text", nullable: false),
VitalSignDetail = table.Column<string>(type: "text", nullable: false),
SystolicBloodPressure = table.Column<int>(type: "integer", nullable: false),
DiastolicBloodPressure = table.Column<int>(type: "integer", nullable: false),
PulseRate = table.Column<int>(type: "integer", nullable: false),
SPO2 = table.Column<int>(type: "integer", nullable: false),
Temperature = table.Column<int>(type: "integer", nullable: false),
MedicalHistoryTemplateId = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationUserId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
ChiefComplaint = table.Column<string>(type: "text", nullable: false),
SectionId = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationUserId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
LoginProvider = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Value = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
RoleId = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false),
Answer = table.Column<string>(type: "text", nullable: false),
Question = table.Column<string>(type: "text", nullable: false),
Part = table.Column<int>(type: "integer", nullable: false),
QuestionType = table.Column<int>(type: "integer", nullable: false),
MedicalHistoryId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
Question = table.Column<string>(type: "text", nullable: false),
Part = table.Column<int>(type: "integer", nullable: false),
QuestionType = table.Column<int>(type: "integer", nullable: false),
BodySystem = table.Column<int>(type: "integer", nullable: false),
IsSign = table.Column<bool>(type: "boolean", nullable: false),
IsSymptom = table.Column<bool>(type: "boolean", nullable: false),
MedicalHistoryTemplateId = table.Column<Guid>(type: "uuid", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(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);
}
/// <inheritdoc />
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");
}
}
}

View File

@ -0,0 +1,867 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UniversityId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UniversityId");
b.ToTable("Sections", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CityId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Universities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AddictionHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("AllergyDetail")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("DiastolicBloodPressure")
.HasColumnType("integer");
b.Property<string>("DrugHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FamilyHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FatherName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("GeneralAppearanceDetail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastDiseasesHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastSurgeryHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PresentIllnessDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("PulseRate")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SPO2")
.HasColumnType("integer");
b.Property<Guid>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SystemReviewDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SystolicBloodPressure")
.HasColumnType("integer");
b.Property<int>("Temperature")
.HasColumnType("integer");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryId");
b.ToTable("MedicalHistoryAnswers", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BodySystem")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsSign")
.HasColumnType("boolean");
b.Property<bool>("IsSymptom")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryTemplateId");
b.ToTable("MedicalHistoryQuestions", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<Guid?>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<int>("SignUpStatus")
.HasColumnType("integer");
b.Property<string>("StudentId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<Guid?>("UniversityId")
.HasColumnType("uuid");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Claims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("Logins", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", 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<System.Guid>", 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
}
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DocuMed.Repository.Migrations
{
/// <inheritdoc />
public partial class editMhAddGa : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "GeneralAppearanceDetail",
schema: "public",
table: "MedicalHistories",
type: "text",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "GeneralAppearanceDetail",
schema: "public",
table: "MedicalHistories");
}
}
}

View File

@ -0,0 +1,867 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UniversityId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UniversityId");
b.ToTable("Sections", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CityId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Universities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AddictionHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("AllergyDetail")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DiastolicBloodPressure")
.HasColumnType("double precision");
b.Property<string>("DrugHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FamilyHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FatherName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("GeneralAppearanceDetail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastDiseasesHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastSurgeryHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PresentIllnessDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PulseRate")
.HasColumnType("double precision");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SPO2")
.HasColumnType("double precision");
b.Property<Guid>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SystemReviewDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SystolicBloodPressure")
.HasColumnType("double precision");
b.Property<double>("Temperature")
.HasColumnType("double precision");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryId");
b.ToTable("MedicalHistoryAnswers", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BodySystem")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsSign")
.HasColumnType("boolean");
b.Property<bool>("IsSymptom")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryTemplateId");
b.ToTable("MedicalHistoryQuestions", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<Guid?>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<int>("SignUpStatus")
.HasColumnType("integer");
b.Property<string>("StudentId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<Guid?>("UniversityId")
.HasColumnType("uuid");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Claims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("Logins", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", 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<System.Guid>", 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
}
}
}

View File

@ -0,0 +1,108 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DocuMed.Repository.Migrations
{
/// <inheritdoc />
public partial class editMHAddDouble : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<double>(
name: "Temperature",
schema: "public",
table: "MedicalHistories",
type: "double precision",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<double>(
name: "SystolicBloodPressure",
schema: "public",
table: "MedicalHistories",
type: "double precision",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<double>(
name: "SPO2",
schema: "public",
table: "MedicalHistories",
type: "double precision",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<double>(
name: "PulseRate",
schema: "public",
table: "MedicalHistories",
type: "double precision",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<double>(
name: "DiastolicBloodPressure",
schema: "public",
table: "MedicalHistories",
type: "double precision",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Temperature",
schema: "public",
table: "MedicalHistories",
type: "integer",
nullable: false,
oldClrType: typeof(double),
oldType: "double precision");
migrationBuilder.AlterColumn<int>(
name: "SystolicBloodPressure",
schema: "public",
table: "MedicalHistories",
type: "integer",
nullable: false,
oldClrType: typeof(double),
oldType: "double precision");
migrationBuilder.AlterColumn<int>(
name: "SPO2",
schema: "public",
table: "MedicalHistories",
type: "integer",
nullable: false,
oldClrType: typeof(double),
oldType: "double precision");
migrationBuilder.AlterColumn<int>(
name: "PulseRate",
schema: "public",
table: "MedicalHistories",
type: "integer",
nullable: false,
oldClrType: typeof(double),
oldType: "double precision");
migrationBuilder.AlterColumn<int>(
name: "DiastolicBloodPressure",
schema: "public",
table: "MedicalHistories",
type: "integer",
nullable: false,
oldClrType: typeof(double),
oldType: "double precision");
}
}
}

View File

@ -0,0 +1,871 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UniversityId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UniversityId");
b.ToTable("Sections", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CityId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Universities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AddictionHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("AllergyDetail")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DiastolicBloodPressure")
.HasColumnType("double precision");
b.Property<string>("DrugHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FamilyHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FatherName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("GeneralAppearanceDetail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastDiseasesHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastSurgeryHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PresentIllnessDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PulseRate")
.HasColumnType("double precision");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SPO2")
.HasColumnType("double precision");
b.Property<Guid>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SystemReviewDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SystolicBloodPressure")
.HasColumnType("double precision");
b.Property<double>("Temperature")
.HasColumnType("double precision");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryId");
b.ToTable("MedicalHistoryAnswers", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BodySystem")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsSign")
.HasColumnType("boolean");
b.Property<bool>("IsSymptom")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryTemplateId");
b.ToTable("MedicalHistoryQuestions", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<Guid?>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<int>("SignUpStatus")
.HasColumnType("integer");
b.Property<string>("StudentId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<Guid?>("UniversityId")
.HasColumnType("uuid");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Claims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("Logins", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", 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<System.Guid>", 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
}
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DocuMed.Repository.Migrations
{
/// <inheritdoc />
public partial class editMHAddCode : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Code",
schema: "public",
table: "MedicalHistories",
type: "text",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Code",
schema: "public",
table: "MedicalHistories");
}
}
}

View File

@ -0,0 +1,868 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.Section", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UniversityId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UniversityId");
b.ToTable("Sections", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.City.University", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CityId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Universities", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistory.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AddictionHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("AllergyDetail")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("DiastolicBloodPressure")
.HasColumnType("double precision");
b.Property<string>("DrugHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FamilyHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FatherName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("GeneralAppearanceDetail")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastDiseasesHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PastSurgeryHistoryDetail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PresentIllnessDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PulseRate")
.HasColumnType("double precision");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SPO2")
.HasColumnType("double precision");
b.Property<Guid>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SystemReviewDetail")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SystolicBloodPressure")
.HasColumnType("double precision");
b.Property<double>("Temperature")
.HasColumnType("double precision");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryId");
b.ToTable("MedicalHistoryAnswers", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("BodySystem")
.HasColumnType("integer");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsSign")
.HasColumnType("boolean");
b.Property<bool>("IsSymptom")
.HasColumnType("boolean");
b.Property<Guid>("MedicalHistoryTemplateId")
.HasColumnType("uuid");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Part")
.HasColumnType("integer");
b.Property<string>("Question")
.IsRequired()
.HasColumnType("text");
b.Property<int>("QuestionType")
.HasColumnType("integer");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("MedicalHistoryTemplateId");
b.ToTable("MedicalHistoryQuestions", "public");
});
modelBuilder.Entity("DocuMed.Domain.Entities.MedicalHistoryTemplate.MedicalHistoryTemplate", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ApplicationUserId")
.HasColumnType("uuid");
b.Property<string>("ChiefComplaint")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EnglishName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime>("BirthDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NationalId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<Guid?>("SectionId")
.HasColumnType("uuid");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<int>("SignUpStatus")
.HasColumnType("integer");
b.Property<string>("StudentId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<Guid?>("UniversityId")
.HasColumnType("uuid");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("RoleClaims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Claims", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("Logins", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles", "public");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("DocuMed.Domain.Entities.User.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", 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<System.Guid>", 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
}
}
}

View File

@ -1,9 +1,15 @@
namespace DocuMed.Repository.Models; namespace DocuMed.Repository.Models;
public class ApplicationContext(DbContextOptions<ApplicationContext> options, ILogger<ApplicationContext> logger) public class ApplicationContext : IdentityDbContext<ApplicationUser,ApplicationRole,Guid>
: IdentityDbContext<ApplicationUser, ApplicationRole, Guid>(options)
{ {
private readonly Assembly _projectAssembly = options.GetExtension<DbContextOptionCustomExtensions>().ProjectAssembly; private readonly ILogger<ApplicationContext> _logger;
private readonly Assembly _projectAssembly;
public ApplicationContext( DbContextOptions<ApplicationContext> options, ILogger<ApplicationContext> logger): base(options)
{
_logger = logger;
_projectAssembly = options.GetExtension<DbContextOptionCustomExtensions>().ProjectAssembly;
}
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
@ -12,9 +18,9 @@ public class ApplicationContext(DbContextOptions<ApplicationContext> options, IL
stopwatch.Start(); stopwatch.Start();
base.OnModelCreating(builder); base.OnModelCreating(builder);
var entitiesAssembly = _projectAssembly; var entitiesAssembly = _projectAssembly;
builder.RegisterAllEntities<ApiEntity>(logger, entitiesAssembly); builder.RegisterAllEntities<ApiEntity>(_logger, entitiesAssembly);
stopwatch.Stop(); stopwatch.Stop();
logger.LogInformation($"!!!!!!! RegisterAllEntities : {stopwatch.ElapsedMilliseconds}ms !!!!!!!"); _logger.LogInformation($"!!!!!!! RegisterAllEntities : {stopwatch.ElapsedMilliseconds}ms !!!!!!!");
RenameIdentityTables(builder); RenameIdentityTables(builder);

View File

@ -2,11 +2,14 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class BaseRepository<T>(ApplicationContext dbContext, ICurrentUserService currentUserService) public class BaseRepository<T> : Repository<T>, IBaseRepository<T> where T : class, IApiEntity
: Repository<T>(dbContext), IBaseRepository<T>
where T : class, IApiEntity
{ {
protected readonly ICurrentUserService CurrentUserService = currentUserService; protected readonly ICurrentUserService CurrentUserService;
public BaseRepository(ApplicationContext dbContext,ICurrentUserService currentUserService) : base(dbContext)
{
CurrentUserService = currentUserService;
}
public virtual async ValueTask<T> GetByIdAsync(CancellationToken cancellationToken, params object[] ids) public virtual async ValueTask<T> GetByIdAsync(CancellationToken cancellationToken, params object[] ids)
{ {

View File

@ -1,9 +1,12 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class ReadRepository<T>(ApplicationContext dbContext) public class ReadRepository<T> : Repository<T>, IDisposable, IReadRepository<T> where T : class, IApiEntity
: Repository<T>(dbContext), IDisposable, IReadRepository<T>
where T : class, IApiEntity
{ {
public ReadRepository(
ApplicationContext dbContext) : base(dbContext)
{
}
public void Dispose() public void Dispose()
{ {
DbContext?.Dispose(); DbContext?.Dispose();

View File

@ -1,10 +1,16 @@
namespace DocuMed.Repository.Repositories.Base; namespace DocuMed.Repository.Repositories.Base;
public class RepositoryWrapper(ApplicationContext context, ICurrentUserService currentUserService) public class RepositoryWrapper : IRepositoryWrapper
: IRepositoryWrapper
{ {
private readonly ApplicationContext _context;
private readonly ICurrentUserService _currentUserService;
private IDbContextTransaction? _currentTransaction; private IDbContextTransaction? _currentTransaction;
public RepositoryWrapper(ApplicationContext context,ICurrentUserService currentUserService)
{
_context = context;
_currentUserService = currentUserService;
}
public IBaseRepository<T> SetRepository<T>() where T : ApiEntity => new BaseRepository<T>(context, currentUserService); public IBaseRepository<T> SetRepository<T>() where T : ApiEntity => new BaseRepository<T>(_context, _currentUserService);
public async Task RollBackAsync(CancellationToken cancellationToken) public async Task RollBackAsync(CancellationToken cancellationToken)
@ -21,26 +27,26 @@ public class RepositoryWrapper(ApplicationContext context, ICurrentUserService c
} }
public async Task BeginTransaction(CancellationToken cancellationToken) 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) public async Task SaveChangesAsync(CancellationToken cancellationToken = default)
{ {
SetAuditables(); SetAuditables();
await context.SaveChangesAsync(cancellationToken); await _context.SaveChangesAsync(cancellationToken);
} }
private void SetAuditables() private void SetAuditables()
{ {
IEnumerable<EntityEntry<IApiEntity>> entries = context.ChangeTracker.Entries<IApiEntity>(); IEnumerable<EntityEntry<IApiEntity>> entries = _context.ChangeTracker.Entries<IApiEntity>();
foreach (EntityEntry<IApiEntity> entity in entries) foreach (EntityEntry<IApiEntity> entity in entries)
{ {
if (entity.State == EntityState.Added) if (entity.State == EntityState.Added)
{ {
entity.Property(e => e.CreatedAt) entity.Property(e => e.CreatedAt)
.CurrentValue = DateTime.Now; .CurrentValue = DateTime.Now;
if (currentUserService.UserName != null) if (_currentUserService.UserName != null)
entity.Property(e => e.CreatedBy) entity.Property(e => e.CreatedBy)
.CurrentValue = currentUserService.UserName; .CurrentValue = _currentUserService.UserName;
} }
if (entity.State == EntityState.Modified) if (entity.State == EntityState.Modified)
@ -49,9 +55,9 @@ public class RepositoryWrapper(ApplicationContext context, ICurrentUserService c
{ {
entity.Property(e => e.ModifiedAt) entity.Property(e => e.ModifiedAt)
.CurrentValue = DateTime.Now; .CurrentValue = DateTime.Now;
if (currentUserService.UserName != null) if (_currentUserService.UserName != null)
entity.Property(e => e.ModifiedBy) entity.Property(e => e.ModifiedBy)
.CurrentValue = currentUserService.UserName; .CurrentValue = _currentUserService.UserName;
} }
} }
} }
@ -59,6 +65,6 @@ public class RepositoryWrapper(ApplicationContext context, ICurrentUserService c
public void Dispose() public void Dispose()
{ {
_currentTransaction?.Dispose(); _currentTransaction?.Dispose();
context?.Dispose(); _context?.Dispose();
} }
} }

View File

@ -1,9 +1,11 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class WriteRepository<T>(ApplicationContext dbContext) public class WriteRepository<T> : Repository<T>, IDisposable, IWriteRepository<T> where T : class, IApiEntity
: Repository<T>(dbContext), IDisposable, IWriteRepository<T>
where T : class, IApiEntity
{ {
public WriteRepository(ApplicationContext dbContext) : base(dbContext)
{
}
public void Dispose() public void Dispose()
{ {
DbContext?.Dispose(); DbContext?.Dispose();

View File

@ -1,8 +1,11 @@
namespace DocuMed.Repository.Repositories.Entities; namespace DocuMed.Repository.Repositories.Entities;
public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) public class MedicalHistoryRepository : BaseRepository<MedicalHistory>,IMedicalHistoryRepository
: BaseRepository<MedicalHistory>(dbContext, currentUserService), IMedicalHistoryRepository
{ {
public MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) : base(dbContext, currentUserService)
{
}
public async Task<List<MedicalHistorySDto>> GetMedicalHistoriesAsync(int page = 0, CancellationToken cancellationToken = default) public async Task<List<MedicalHistorySDto>> GetMedicalHistoriesAsync(int page = 0, CancellationToken cancellationToken = default)
{ {
if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId))

View File

@ -1,8 +1,11 @@
namespace DocuMed.Repository.Repositories.Entities; namespace DocuMed.Repository.Repositories.Entities;
public class MedicalHistoryTemplateRepository(ApplicationContext dbContext, ICurrentUserService currentUserService) public class MedicalHistoryTemplateRepository : BaseRepository<MedicalHistoryTemplate>, IMedicalHistoryTemplateRepository
: BaseRepository<MedicalHistoryTemplate>(dbContext, currentUserService), IMedicalHistoryTemplateRepository
{ {
public MedicalHistoryTemplateRepository(ApplicationContext dbContext,ICurrentUserService currentUserService) : base(dbContext,currentUserService)
{
}
public async Task<List<MedicalHistoryTemplateSDto>> GetMedicalHistoryTemplatesAsync(int page = 0, CancellationToken cancellationToken = default) public async Task<List<MedicalHistoryTemplateSDto>> GetMedicalHistoryTemplatesAsync(int page = 0, CancellationToken cancellationToken = default)
{ {
if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId)) if (!Guid.TryParse(CurrentUserService.UserId, out Guid userId))

View File

@ -1,8 +1,13 @@
namespace DocuMed.Repository.Repositories.UnitOfWork; namespace DocuMed.Repository.Repositories.UnitOfWork;
public class UnitOfWork(ApplicationContext applicationContext) : IUnitOfWork public class UnitOfWork : IUnitOfWork
{ {
private readonly ApplicationContext _applicationContext;
private IDbContextTransaction? _currentTransaction ; private IDbContextTransaction? _currentTransaction ;
public UnitOfWork(ApplicationContext applicationContext)
{
_applicationContext = applicationContext;
}
public async Task RollBackAsync() public async Task RollBackAsync()
{ {
@ -18,17 +23,17 @@ public class UnitOfWork(ApplicationContext applicationContext) : IUnitOfWork
} }
public async Task BeginTransaction() public async Task BeginTransaction()
{ {
_currentTransaction = await applicationContext.Database.BeginTransactionAsync(); _currentTransaction = await _applicationContext.Database.BeginTransactionAsync();
} }
public async Task SaveChangesAsync(CancellationToken cancellationToken = default) public async Task SaveChangesAsync(CancellationToken cancellationToken = default)
{ {
SetAuditables(); SetAuditables();
await applicationContext.SaveChangesAsync(cancellationToken); await _applicationContext.SaveChangesAsync(cancellationToken);
} }
private void SetAuditables() private void SetAuditables()
{ {
IEnumerable<EntityEntry<IApiEntity>> entries = applicationContext.ChangeTracker.Entries<IApiEntity>(); IEnumerable<EntityEntry<IApiEntity>> entries = _applicationContext.ChangeTracker.Entries<IApiEntity>();
foreach (EntityEntry<IApiEntity> entity in entries) foreach (EntityEntry<IApiEntity> entity in entries)
{ {
if (entity.State == EntityState.Added) if (entity.State == EntityState.Added)

View File

@ -1,23 +1,37 @@
namespace DocuMed.Repository.Services; namespace DocuMed.Repository.Services;
public class DbInitializerService( public class DbInitializerService : IDbInitializerService
ApplicationContext context,
RoleManager<ApplicationRole> roleManager,
UserManager<ApplicationUser> userManager,
IOptionsSnapshot<SiteSettings> adminUserSeedOptions,
ILogger<DbInitializerService> logger)
: IDbInitializerService
{ {
private readonly IOptionsSnapshot<SiteSettings> _adminUserSeedOptions;
private readonly ApplicationContext _context;
private readonly ILogger<DbInitializerService> _logger;
private readonly RoleManager<ApplicationRole> _roleManager;
private readonly UserManager<ApplicationUser> _userManager;
public DbInitializerService(
ApplicationContext context,
RoleManager<ApplicationRole> roleManager,
UserManager<ApplicationUser> userManager,
IOptionsSnapshot<SiteSettings> adminUserSeedOptions,
ILogger<DbInitializerService> logger)
{
_context = context;
_roleManager = roleManager;
_userManager = userManager;
_adminUserSeedOptions = adminUserSeedOptions;
_logger = logger;
}
public void Initialize() public void Initialize()
{ {
try try
{ {
context.Database.Migrate(); _context.Database.Migrate();
logger.LogInformation("Migration SUCCESS !!!!"); _logger.LogInformation("Migration SUCCESS !!!!");
} }
catch (Exception e) catch (Exception e)
{ {
logger.LogError(e, e.Message); _logger.LogError(e, e.Message);
} }
} }
@ -27,8 +41,8 @@ public class DbInitializerService(
{ {
await SeedRoles(); await SeedRoles();
var seedAdmin = adminUserSeedOptions.Value.UserSetting; var seedAdmin = _adminUserSeedOptions.Value.UserSetting;
var user = await userManager.FindByNameAsync(seedAdmin.Username); var user = await _userManager.FindByNameAsync(seedAdmin.Username);
if (user == null) if (user == null)
{ {
var adminUser = new ApplicationUser var adminUser = new ApplicationUser
@ -44,8 +58,8 @@ public class DbInitializerService(
PhoneNumber = seedAdmin.Phone, PhoneNumber = seedAdmin.Phone,
BirthDate = DateTime.Now.AddYears(-23) BirthDate = DateTime.Now.AddYears(-23)
}; };
var adminUserResult = await userManager.CreateAsync(adminUser, seedAdmin.Password); var adminUserResult = await _userManager.CreateAsync(adminUser, seedAdmin.Password);
if (adminUserResult.Succeeded) await userManager.AddToRoleAsync(adminUser, seedAdmin.RoleName); if (adminUserResult.Succeeded) await _userManager.AddToRoleAsync(adminUser, seedAdmin.RoleName);
} }
} }
catch (Exception e) catch (Exception e)
@ -57,8 +71,8 @@ public class DbInitializerService(
public async Task SeedRoles() public async Task SeedRoles()
{ {
var seedAdmin = adminUserSeedOptions.Value.UserSetting; var seedAdmin = _adminUserSeedOptions.Value.UserSetting;
var managerRole = await roleManager.FindByNameAsync(seedAdmin.RoleName); var managerRole = await _roleManager.FindByNameAsync(seedAdmin.RoleName);
if (managerRole == null) if (managerRole == null)
{ {
@ -68,9 +82,9 @@ public class DbInitializerService(
EnglishName = seedAdmin.RoleName, EnglishName = seedAdmin.RoleName,
Description = "root admin role" Description = "root admin role"
}; };
var adminRoleResult = await roleManager.CreateAsync(managerRole); var adminRoleResult = await _roleManager.CreateAsync(managerRole);
foreach (var claim in ApplicationClaims.AllClaims) foreach (var claim in ApplicationClaims.AllClaims)
await roleManager.AddClaimAsync(managerRole, claim); await _roleManager.AddClaimAsync(managerRole, claim);
} }
} }
} }