Change DATABASE

master
Amir Hossein Khademi 2024-09-28 12:34:36 +03:30
parent 1ceb063d14
commit ae1e8859c0
88 changed files with 2094 additions and 6854 deletions

View File

@ -0,0 +1,65 @@
using DocuMed.Domain.Entities.MedicalHistory;
namespace DocuMed.Api.Controllers;
public class HospitalController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("Hospital")
.MapGroup("api/hospital")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
group.MapGet("", GetAllAsync)
.WithDisplayName("GetAll")
.HasApiVersion(1.0);
group.MapGet("{id}", GetAsync)
.WithDisplayName("GetOne")
.HasApiVersion(1.0);
group.MapPost("", Post)
.HasApiVersion(1.0);
group.MapPut("", Put)
.HasApiVersion(1.0);
group.MapDelete("", Delete)
.HasApiVersion(1.0);
}
// GET:Get All Entity
public virtual async Task<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,19 +1,18 @@
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")
@ -37,13 +36,6 @@ 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)
@ -53,7 +45,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.UniversityId); var ent = Section.Create(dto.Name,dto.Detail,dto.HospitalId);
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);
@ -62,7 +54,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.UniversityId); var ent = Section.Create(dto.Name,dto.Detail, dto.HospitalId);
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,4 +1,6 @@
namespace DocuMed.Api.Controllers; using DocuMed.Domain.Entities.Hospitals;
namespace DocuMed.Api.Controllers;
public class UniversityController : ICarterModule public class UniversityController : ICarterModule
{ {
@ -9,11 +11,15 @@ public class UniversityController : ICarterModule
.MapGroup($"api/university"); .MapGroup($"api/university");
group.MapGet("", GetAllAsync) group.MapGet("", GetAllAsync)
.WithDisplayName("GetAll") .WithDisplayName("Get All")
.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("GetOne") .WithDisplayName("Get One")
.HasApiVersion(1.0); .HasApiVersion(1.0);
group.MapPost("", Post) group.MapPost("", Post)
@ -27,6 +33,14 @@ 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

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

View File

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

@ -1,13 +0,0 @@
namespace DocuMed.Api
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

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

View File

@ -15,22 +15,11 @@ 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;
@ -39,15 +28,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>
{ {
@ -84,22 +73,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>
{ {
@ -168,7 +157,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,28 +10,19 @@ public static class PerformanceMiddlewareExtensions
} }
} }
public class PerformanceMiddleware public class PerformanceMiddleware(
RequestDelegate next,
ILogger<ExceptionHandlerMiddleware> logger)
{ {
private readonly ILogger<ExceptionHandlerMiddleware> _logger; private readonly Stopwatch _timer = new();
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,17 +139,12 @@ public class SetVersionInPaths : IDocumentFilter
} }
} }
public class UnauthorizedResponsesOperationFilter : IOperationFilter public class UnauthorizedResponsesOperationFilter(
bool includeUnauthorizedAndForbiddenResponses,
string schemeName = "Bearer")
: IOperationFilter
{ {
private readonly bool includeUnauthorizedAndForbiddenResponses; private readonly string schemeName = schemeName;
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,21 +5,14 @@ using System.Text;
namespace DocuMed.Core.BaseServices; namespace DocuMed.Core.BaseServices;
public class JwtService : IJwtService public class JwtService(
IOptionsSnapshot<SiteSettings> siteSettings,
SignInManager<ApplicationUser> userSignInManager,
RoleManager<ApplicationRole> roleManager)
: IJwtService
{ {
private readonly SignInManager<ApplicationUser> _signInManager; private readonly SiteSettings _siteSettings = siteSettings.Value;
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);
@ -82,7 +75,7 @@ public class JwtService : IJwtService
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 _signInManager.ClaimsFactory.CreateAsync(baseUser)); var clFac = (await userSignInManager.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));
@ -98,8 +91,8 @@ public class JwtService : IJwtService
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()));

View File

@ -1,55 +1,34 @@
using DocuMed.Domain.Entities.City; using DocuMed.Domain.Entities.City;
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.Core.CoreServices; namespace DocuMed.Core.CoreServices;
public class AccountService(
public class AccountService : IAccountService UserManager<ApplicationUser> userManager,
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;
} }
@ -58,7 +37,7 @@ public class AccountService : IAccountService
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;
@ -69,23 +48,23 @@ public class AccountService : IAccountService
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);
@ -93,11 +72,11 @@ public class AccountService : IAccountService
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)
@ -106,7 +85,7 @@ public class AccountService : IAccountService
{ {
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));
} }
@ -115,9 +94,9 @@ public class AccountService : IAccountService
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);
@ -131,7 +110,7 @@ public class AccountService : IAccountService
user.LastName = requestDto.LastName; user.LastName = requestDto.LastName;
user.SignUpStatus = SignUpStatus.SignUpCompleted; user.SignUpStatus = SignUpStatus.SignUpCompleted;
user.UniversityId = requestDto.UniversityId; user.UniversityId = requestDto.UniversityId;
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));
@ -141,11 +120,11 @@ public class AccountService : IAccountService
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);
if (token.User.SectionId != Guid.Empty) if (token.User.SectionId != Guid.Empty)
{ {
var section = await _repositoryWrapper.SetRepository<Section>().TableNoTracking var section = await repositoryWrapper.SetRepository<Section>().TableNoTracking
.FirstOrDefaultAsync(s => s.Id == user.SectionId, cancellationToken); .FirstOrDefaultAsync(s => s.Id == user.SectionId, cancellationToken);
if (section != null) if (section != null)
{ {

View File

@ -1,21 +1,14 @@
namespace DocuMed.Core.EntityServices; namespace DocuMed.Core.EntityServices;
public class MedicalHistoryService : IMedicalHistoryService public class MedicalHistoryService(
IRepositoryWrapper repositoryWrapper,
ICurrentUserService currentUserService,
IMedicalHistoryRepository medicalHistoryRepository)
: IMedicalHistoryService
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
public MedicalHistoryService(IRepositoryWrapper repositoryWrapper, ICurrentUserService currentUserService, IMedicalHistoryRepository medicalHistoryRepository)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
_medicalHistoryRepository = medicalHistoryRepository;
}
public async Task<bool> EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken) public async Task<bool> EditAsync(MedicalHistoryLDto template, CancellationToken cancellationToken)
{ {
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) if (!Guid.TryParse(currentUserService.UserId, out Guid userId))
throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); 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);
@ -37,27 +30,27 @@ public class MedicalHistoryService : IMedicalHistoryService
foreach (var answer in template.Answers.Where(a => a.Id != Guid.Empty)) foreach (var answer in template.Answers.Where(a => a.Id != Guid.Empty))
{ {
var dbAnswer = await _repositoryWrapper.SetRepository<MedicalHistoryAnswer>().TableNoTracking var dbAnswer = await repositoryWrapper.SetRepository<MedicalHistoryAnswer>().TableNoTracking
.FirstOrDefaultAsync(a => a.Id == answer.Id, cancellationToken); .FirstOrDefaultAsync(a => a.Id == answer.Id, cancellationToken);
if (dbAnswer != null && dbAnswer.Answer != answer.Answer && answer.Answer != null) if (dbAnswer != null && dbAnswer.Answer != answer.Answer && answer.Answer != null)
{ {
dbAnswer = MedicalHistoryAnswer.Create(answer.Answer, answer.Question, answer.Part, answer.QuestionType, dbAnswer = MedicalHistoryAnswer.Create(answer.Answer, answer.Question, answer.Part, answer.QuestionType,
dbAnswer.MedicalHistoryId); dbAnswer.MedicalHistoryId);
dbAnswer.Id = answer.Id; dbAnswer.Id = answer.Id;
_repositoryWrapper.SetRepository<MedicalHistoryAnswer>().Update(dbAnswer); repositoryWrapper.SetRepository<MedicalHistoryAnswer>().Update(dbAnswer);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
} }
} }
_medicalHistoryRepository.Update(ent); medicalHistoryRepository.Update(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
public async Task<bool> AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken) public async Task<bool> AddAsync(MedicalHistoryLDto template, CancellationToken cancellationToken)
{ {
if (!Guid.TryParse(_currentUserService.UserId, out Guid userId)) if (!Guid.TryParse(currentUserService.UserId, out Guid userId))
throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized); throw new AppException("دسترسی غیرمجاز", ApiResultStatusCode.UnAuthorized);
var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, template.FirstName, var ent = MedicalHistory.Create(template.ChiefComplaint, template.SectionId, template.FirstName,
template.LastName, template.FatherName, template.NationalId, template.Age, template.BirthDate, template.LastName, template.FatherName, template.NationalId, template.Age, template.BirthDate,
@ -70,8 +63,8 @@ public class MedicalHistoryService : IMedicalHistoryService
foreach (var answer in template.Answers) foreach (var answer in template.Answers)
ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType); ent.AddAnswer(answer.Answer, answer.Question, answer.Part, answer.QuestionType);
_medicalHistoryRepository.Add(ent); medicalHistoryRepository.Add(ent);
await _repositoryWrapper.SaveChangesAsync(cancellationToken); await repositoryWrapper.SaveChangesAsync(cancellationToken);
return true; return true;
} }
} }

View File

@ -5,28 +5,22 @@ using System.Threading;
namespace DocuMed.Core.EntityServices; namespace DocuMed.Core.EntityServices;
public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService public class MedicalHistoryTemplateService(
IRepositoryWrapper repositoryWrapper,
ICurrentUserService currentUserService,
IMedicalHistoryTemplateRepository medicalHistoryTemplateRepository)
: IMedicalHistoryTemplateService
{ {
private readonly IRepositoryWrapper _repositoryWrapper;
private readonly ICurrentUserService _currentUserService;
private readonly IMedicalHistoryTemplateRepository _medicalHistoryTemplateRepository;
public MedicalHistoryTemplateService(IRepositoryWrapper repositoryWrapper,ICurrentUserService currentUserService,IMedicalHistoryTemplateRepository medicalHistoryTemplateRepository)
{
_repositoryWrapper = repositoryWrapper;
_currentUserService = currentUserService;
_medicalHistoryTemplateRepository = medicalHistoryTemplateRepository;
}
public async Task<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);
@ -34,28 +28,28 @@ public class MedicalHistoryTemplateService : IMedicalHistoryTemplateService
{ {
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,33 +1,24 @@
namespace DocuMed.Core.EntityServices; namespace DocuMed.Core.EntityServices;
public class UserService : IUserService public class UserService(
ICurrentUserService currentUserService,
UserManager<ApplicationUser> userManager,
RoleManager<ApplicationRole> roleManager,
IRepositoryWrapper repositoryWrapper)
: IUserService
{ {
private readonly ICurrentUserService _currentUserService; private readonly IRepositoryWrapper _repositoryWrapper = repositoryWrapper;
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)
{ {
@ -37,7 +28,7 @@ public class UserService : IUserService
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;
@ -59,18 +50,18 @@ public class UserService : IUserService
}; };
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));
@ -79,10 +70,10 @@ public class UserService : IUserService
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;
@ -100,15 +91,15 @@ public class UserService : IUserService
if (request.SectionId != Guid.Empty) if (request.SectionId != Guid.Empty)
user.SectionId = request.SectionId; 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));
} }
@ -117,10 +108,10 @@ public class UserService : IUserService
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;
@ -131,7 +122,7 @@ public class UserService : IUserService
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);
@ -140,12 +131,12 @@ public class UserService : IUserService
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();
@ -164,12 +155,12 @@ public class UserService : IUserService
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;
} }
@ -177,7 +168,7 @@ public class UserService : IUserService
{ {
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("نقش پیدا نشد");
@ -186,10 +177,10 @@ public class UserService : IUserService
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))
@ -200,20 +191,20 @@ public class UserService : IUserService
} }
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,19 +1,12 @@
namespace DocuMed.Core.Models.Api; namespace DocuMed.Core.Models.Api;
public class ApiResult public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null)
{ {
public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) public bool IsSuccess { get; set; } = isSuccess;
{ 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; } public string Message { get; set; } = message ?? statusCode.ToDisplay();
#region Implicit Operators #region Implicit Operators
@ -62,17 +55,12 @@ public class ApiResult
#endregion #endregion
} }
public class ApiResult<TData> : ApiResult public class ApiResult<TData>(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null)
: 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; } public TData Data { get; set; } = data;
#region Implicit Operators #region Implicit Operators

View File

@ -0,0 +1,5 @@
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

@ -0,0 +1,4 @@
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,11 +42,10 @@
</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\Patient\" /> <Folder Include="Entities\Patients\" />
<Folder Include="Entities\User\" /> <Folder Include="Entities\User\" />
</ItemGroup> </ItemGroup>
@ -56,11 +55,15 @@
<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

@ -0,0 +1,9 @@
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 UniversityId { get; set; } public Guid HospitalId { get; set; }
} }

View File

@ -0,0 +1,18 @@
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

@ -22,12 +22,4 @@ 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,8 +1,10 @@
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

@ -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<Section> Sections { get; internal set; } = new(); public List<Hospitals.Section> Sections { get; internal set; } = new();
} }

View File

@ -0,0 +1,15 @@
namespace DocuMed.Domain.Entities.Hospitals;
public partial class Hospital
{
public static Hospital Create(string name, string detail, string address, Guid universityId)
=> new Hospital(name, detail, address, universityId);
}
public partial class Section
{
public static Hospitals.Section Create(string name, string detail, Guid universityId)
{
return new Hospitals.Section(name, detail, universityId);
}
}

View File

@ -0,0 +1,26 @@
namespace DocuMed.Domain.Entities.Hospitals;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper]
public partial class Hospital : ApiEntity
{
public Hospital()
{
}
public Hospital(string name, string detail, string address, Guid universityId)
{
Name = name;
Detail = detail;
Address = address;
UniversityId = universityId;
}
public string Name { get; internal set; } = string.Empty;
public string Detail { get; internal set; } = string.Empty;
public string Address { get; internal set; } = string.Empty;
public Guid UniversityId { get; internal set; }
public University? University { get; internal set; }
public virtual List<Section> Sections { get; internal set; } = new ();
}

View File

@ -1,4 +1,4 @@
namespace DocuMed.Domain.Entities.City; namespace DocuMed.Domain.Entities.Hospitals;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [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 universityId) public Section(string name, string detail, Guid hospitalId)
{ {
Name = name; Name = name;
Detail = detail; Detail = detail;
UniversityId = universityId; HospitalId = hospitalId;
} }
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 UniversityId { get; internal set; } public Guid HospitalId { get; internal set; }
public University? University { get; internal set; } public Hospital? Hospital { get; internal set; }
} }

View File

@ -1,9 +1,11 @@
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()

View File

@ -1,7 +1,10 @@
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]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,11 +1,9 @@
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

@ -1,12 +0,0 @@
namespace DocuMed.Domain.Entities.Patient;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper]
public class Patient
{
public string FirstName { get; internal set; } = string.Empty;
public string LastName { get; internal set; } = string.Empty;
public string FatherName { get; internal set; } = string.Empty;
public string NationalId { get; internal set; } = string.Empty;
public int Age { get; internal set; }
public DateTime BirthDate { get; internal set; }
}

View File

@ -0,0 +1,7 @@
namespace DocuMed.Domain.Entities.Patients;
public partial class Patient
{
public static Patient Create(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId)
=> new Patient(unitNumber, room, bed, admissionAt, sectionId, userId);
}

View File

@ -0,0 +1,33 @@
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.Domain.Entities.Patients;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper]
public partial class Patient : ApiEntity
{
public Patient()
{
}
public Patient(string unitNumber, string room, string bed, DateTime admissionAt, Guid sectionId, Guid userId)
{
UnitNumber = unitNumber;
Room = room;
Bed = bed;
AdmissionAt = admissionAt;
SectionId = sectionId;
UserId = userId;
}
public string UnitNumber { get; internal set; } = string.Empty;
public string Room { get; internal set; } = string.Empty;
public string Bed { get; internal set; } = string.Empty;
public DateTime AdmissionAt { get; internal set; }
public Guid SectionId { get; internal set; }
public Section? Section { get; internal set; }
public Guid UserId { get; internal set; }
public ApplicationUser? User { get; internal set; }
}

View File

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

View File

@ -0,0 +1,31 @@
using Section = DocuMed.Domain.Entities.Hospitals.Section;
namespace DocuMed.Domain.Entities.Staffs;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper]
public partial class Student : ApiEntity
{
public Student()
{
}
public Student(Guid universityId, Guid sectionId, Guid userId)
{
UniversityId = universityId;
SectionId = sectionId;
UserId = userId;
}
public string StudentId { get; set; } = string.Empty;
public Guid UniversityId { get; internal set; }
public University? University { get; internal set; }
public Guid SectionId { get; internal set; }
public Section? Section { get; internal set; }
public Guid UserId { get; internal set; }
public ApplicationUser? User { get; internal set; }
}

View File

@ -1,4 +1,6 @@
namespace DocuMed.Domain.Entities.User; using DocuMed.Domain.Entities.Patients;
namespace DocuMed.Domain.Entities.User;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)] [AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget | MapType.Projection)]
[GenerateMapper] [GenerateMapper]
@ -7,14 +9,10 @@ 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 Guid? UniversityId { get; set; } public Student? Student { get; set; }
public University? University { get; set; } public Patient? Patient { get; set; }
public Guid? SectionId { get; set; }
public Section? Section { get; set; }
} }

View File

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

View File

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

View File

@ -0,0 +1,78 @@
using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.Hospitals;
namespace DocuMed.Domain.Mappers
{
public static partial class HospitalMapper
{
public static Hospital AdaptToHospital(this HospitalSDto p1)
{
return p1 == null ? null : new Hospital()
{
Name = p1.Name,
Detail = p1.Detail,
Address = p1.Address,
Id = p1.Id
};
}
public static Hospital AdaptTo(this HospitalSDto p2, Hospital p3)
{
if (p2 == null)
{
return null;
}
Hospital result = p3 ?? new Hospital();
result.Name = p2.Name;
result.Detail = p2.Detail;
result.Address = p2.Address;
result.Id = p2.Id;
return result;
}
public static Expression<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,60 +40,49 @@ namespace DocuMed.Domain.Mappers
return result; return result;
} }
public static Expression<Func<MedicalHistoryQuestionSDto, MedicalHistoryQuestion>> ProjectToMedicalHistoryQuestion => p4 => new MedicalHistoryQuestion() public static MedicalHistoryQuestionSDto AdaptToSDto(this MedicalHistoryQuestion p4)
{ {
Question = p4.Question, return p4 == null ? null : new MedicalHistoryQuestionSDto()
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 = p5.Question, Question = p4.Question,
Part = p5.Part, Part = p4.Part,
QuestionType = p5.QuestionType, QuestionType = p4.QuestionType,
MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId, MedicalHistoryTemplateId = p4.MedicalHistoryTemplateId,
BodySystem = p5.BodySystem, BodySystem = p4.BodySystem,
IsSign = p5.IsSign, IsSign = p4.IsSign,
IsSymptom = p5.IsSymptom, IsSymptom = p4.IsSymptom,
Id = p5.Id Id = p4.Id
}; };
} }
public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p6, MedicalHistoryQuestionSDto p7) public static MedicalHistoryQuestionSDto AdaptTo(this MedicalHistoryQuestion p5, MedicalHistoryQuestionSDto p6)
{ {
if (p6 == null) if (p5 == null)
{ {
return null; return null;
} }
MedicalHistoryQuestionSDto result = p7 ?? new MedicalHistoryQuestionSDto(); MedicalHistoryQuestionSDto result = p6 ?? new MedicalHistoryQuestionSDto();
result.Question = p6.Question; result.Question = p5.Question;
result.Part = p6.Part; result.Part = p5.Part;
result.QuestionType = p6.QuestionType; result.QuestionType = p5.QuestionType;
result.MedicalHistoryTemplateId = p6.MedicalHistoryTemplateId; result.MedicalHistoryTemplateId = p5.MedicalHistoryTemplateId;
result.BodySystem = p6.BodySystem; result.BodySystem = p5.BodySystem;
result.IsSign = p6.IsSign; result.IsSign = p5.IsSign;
result.IsSymptom = p6.IsSymptom; result.IsSymptom = p5.IsSymptom;
result.Id = p6.Id; result.Id = p5.Id;
return result; return result;
} }
public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p8 => new MedicalHistoryQuestionSDto() public static Expression<Func<MedicalHistoryQuestion, MedicalHistoryQuestionSDto>> ProjectToSDto => p7 => new MedicalHistoryQuestionSDto()
{ {
Question = p8.Question, Question = p7.Question,
Part = p8.Part, Part = p7.Part,
QuestionType = p8.QuestionType, QuestionType = p7.QuestionType,
MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId, MedicalHistoryTemplateId = p7.MedicalHistoryTemplateId,
BodySystem = p8.BodySystem, BodySystem = p7.BodySystem,
IsSign = p8.IsSign, IsSign = p7.IsSign,
IsSymptom = p8.IsSymptom, IsSymptom = p7.IsSymptom,
Id = p8.Id Id = p7.Id
}; };
} }
} }

View File

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

View File

@ -0,0 +1,157 @@
using System;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.City;
using DocuMed.Domain.Entities.Hospitals;
using DocuMed.Domain.Entities.Staffs;
using DocuMed.Domain.Entities.User;
using Mapster.Models;
namespace DocuMed.Domain.Mappers
{
public static partial class StudentMapper
{
public static Student AdaptToStudent(this StudentSDto p1)
{
return p1 == null ? null : new Student()
{
StudentId = p1.StudentId,
UniversityId = p1.UniversityId,
University = new University()
{
Name = p1.UniversityName,
Id = p1.UniversityId
},
SectionId = p1.SectionId,
Section = new Section()
{
Name = p1.SectionName,
Id = p1.SectionId
},
UserId = p1.UserId,
User = new ApplicationUser() {Id = p1.UserId},
Id = p1.Id
};
}
public static Student AdaptTo(this StudentSDto p2, Student p3)
{
if (p2 == null)
{
return null;
}
Student result = p3 ?? new Student();
result.StudentId = p2.StudentId;
result.UniversityId = p2.UniversityId;
result.University = funcMain1(new Never(), result.University, p2);
result.SectionId = p2.SectionId;
result.Section = funcMain2(new Never(), result.Section, p2);
result.UserId = p2.UserId;
result.User = funcMain3(new Never(), result.User, p2);
result.Id = p2.Id;
return result;
}
public static Expression<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,8 +9,13 @@ public class MapsterRegister : IRegister
.TwoWays(); .TwoWays();
config.NewConfig<ApplicationUser, ApplicationUserSDto>() config.NewConfig<Student, StudentSDto>()
.Map("SectionName", org => org.Section != null ? org.Section.Name : string.Empty) .Map(des=>des.SectionName, org => org.Section != null ? org.Section.Name : string.Empty)
.Map(des=>des.UniversityName, org => org.University != null ? org.University.Name : string.Empty)
.Map(des => des.PhoneNumber, org => org.User != null ? org.User.PhoneNumber : string.Empty)
.Map(des=>des.FirstName, org => org.User != null ? org.User.FirstName : string.Empty)
.Map(des=>des.LastName, org => org.User != null ? org.User.LastName : string.Empty)
.Map(des=>des.NationalId, org => org.User != null ? org.User.NationalId : string.Empty)
.TwoWays(); .TwoWays();
} }
} }

View File

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

View File

@ -4,7 +4,9 @@ public interface IKaveNegarRestApi
{ {
[Post("/{apiKey}/verify/lookup.json")] [Post("/{apiKey}/verify/lookup.json")]
Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string token, [Query] string token2, [Query] string token10, [Query] string token20, [Query] string template); Task<KaveNegarResponse> SendLookUp(string apiKey, [Query] string receptor, [Query] string template, [Query] string token, [Query] string? token2 = null,
[Query] string? token3 = null, [Query] string? token10 = null, [Query] string? token20 = null);
[Post("/{apiKey}/sms/send.json")] [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,33 +1,71 @@
namespace DocuMed.Infrastructure.Services; using Microsoft.Extensions.Hosting;
using System;
namespace DocuMed.Infrastructure.Services;
public class SmsService : ISmsService public class SmsService(
IRestApiWrapper restApiWrapper,
IOptionsSnapshot<SiteSettings> optionsSnapshot,
ILogger<SmsService> logger,
IHostEnvironment environment) : ISmsService
{ {
private readonly IRestApiWrapper _restApiWrapper; private readonly ILogger<SmsService> _logger = logger;
private readonly ILogger<SmsService> _logger; private readonly SiteSettings _siteSettings = optionsSnapshot.Value;
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, newPassword, null, null, null, "forgetPassword"); var rest = await restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber, "forgetPassword", newPassword,
null, null , null, null);
if (rest.Return?.status != 200) 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");
if (rest.Return?.status != 200) try
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="7.8.0" /> <PackageReference Include="MudBlazor" Version="6.13.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:32770/api"; public static string BaseAddress = "http://localhost:32780/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,25 +1,16 @@
namespace DocuMed.PWA.Models.Api; namespace DocuMed.PWA.Models.Api;
public class ApiResult public class ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null)
{ {
public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, string message = null) public bool IsSuccess { get; set; } = isSuccess;
{ public ApiResultStatusCode StatusCode { get; set; } = statusCode;
IsSuccess = isSuccess;
StatusCode = statusCode;
Message = message ?? statusCode.ToDisplay();
}
public bool IsSuccess { get; set; } public string Message { get; set; } = message ?? statusCode.ToDisplay();
public ApiResultStatusCode StatusCode { get; set; }
public string Message { get; set; }
} }
public class ApiResult<TData> : ApiResult where TData : class public class ApiResult<TData>(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null)
: ApiResult(isSuccess, statusCode, message)
where TData : class
{ {
public ApiResult(bool isSuccess, ApiResultStatusCode statusCode, TData data, string message = null) : base(isSuccess, statusCode, message) public TData Data { get; set; } = data;
{
Data = data;
}
public TData Data { get; set; }
} }

View File

@ -17,11 +17,8 @@ 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; } public TPageDto PageDto { get; set; } = Activator.CreateInstance<TPageDto>();
public BaseViewModel()
{
PageDto = Activator.CreateInstance<TPageDto>();
}
public virtual void Initialize() public virtual void Initialize()
{ {

View File

@ -3,20 +3,11 @@ using DocuMed.Domain.Enums.QueryFilters;
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class HomePageViewModel : BaseViewModel<List<MedicalHistorySDto>> public class HomePageViewModel(IUserUtility userUtility, IRestWrapper restWrapper, ISnackbar snackbar)
: 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();
@ -27,9 +18,9 @@ public class HomePageViewModel : BaseViewModel<List<MedicalHistorySDto>>
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;
@ -38,11 +29,11 @@ public class HomePageViewModel : BaseViewModel<List<MedicalHistorySDto>>
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 flex-col w-screen h-screen"> <div class="flex h-screen w-screen flex-col">
<div class="w-full overflow-hidden basis-2/4"> <div class="w-full basis-2/4 overflow-hidden">
<MudCarousel class="w-full h-full" ShowArrows="false" ShowBullets="false" EnableSwipeGesture="true" <MudCarousel class="h-full w-full" ShowArrows="false" ShowBullets="false" EnableSwipeGesture="true"
AutoCycle="true" TData="object"> AutoCycle="true" TData="object">
<MudCarouselItem> <MudCarouselItem>
<div class="flex flex-col h-full mx-5"> <div class="mx-5 flex h-full flex-col">
<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 w-60 h-60" loop autoplay /> background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay />
</div> </div>
<p class="mx-auto text-lg font-extrabold text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-lg font-extrabold">
شرح حال نویسی بیمار راحت تر شرح حال نویسی بیمار راحت تر
از از
همیشه همیشه
</p> </p>
<p class="mx-auto text-xs text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-xs">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم مثل شرح حال نویسی همراه و همیار همیشگی پزشکان محترم
@ -41,17 +41,17 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="flex flex-col h-full mx-5"> <div class="mx-5 flex h-full flex-col">
<div class="my-auto"> <div class="my-auto">
<div class="-mt-8 -mb-3"> <div class="-mb-3 -mt-8">
<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 w-60 h-60" loop autoplay /> background="transparent" speed="1" class="m-auto h-60 w-60" loop autoplay />
</div> </div>
<p class="mx-auto text-lg font-extrabold text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-lg font-extrabold">
اوردر های شما همه در یک اوردر های شما همه در یک
اپلیکیشن اپلیکیشن
</p> </p>
<p class="mx-auto text-xs text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-xs">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل شرح حال نویسی همیار همیشگی پزشکان محترم مثل شرح حال نویسی همیار همیشگی پزشکان محترم
@ -60,16 +60,16 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="flex flex-col h-full mx-5"> <div class="mx-5 flex h-full flex-col">
<div class="my-auto"> <div class="my-auto">
<div class="-mt-8 -mb-10"> <div class="-mb-10 -mt-8">
<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 w-72 h-72" loop autoplay /> background="transparent" speed="1" class="m-auto h-72 w-72" loop autoplay />
</div> </div>
<p class="mx-auto text-lg font-extrabold text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-lg font-extrabold">
نرم افزار جامع داکیـــــومد نرم افزار جامع داکیـــــومد
</p> </p>
<p class="mx-auto text-xs text-center font-iranyekan"> <p class="font-iranyekan mx-auto text-center text-xs">
نرم افزار داکیومد با امکانات بسیار زیاد نرم افزار داکیومد با امکانات بسیار زیاد
خود خود
مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم مثل تهیه پیشنویس شرح حال همراه همیشگی پزشکان محترم
@ -79,14 +79,14 @@
</MudCarouselItem> </MudCarouselItem>
</MudCarousel> </MudCarousel>
</div> </div>
<MudPaper Elevation="10" class="w-full rounded-t-2xl bg-[#FFFBE6] basis-2/4"> <MudPaper Elevation="10" class="w-full basis-2/4 rounded-t-2xl bg-[#FFFBE6]">
<MudCarousel class="w-full h-full overflow-x-hidden overflow-y-scroll" @ref="_carousel" ShowArrows="false" <MudCarousel class="h-full w-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="flex flex-col h-full p-5 font-iranyekan"> <div class="font-iranyekan flex h-full flex-col p-5">
<MudStack class="my-auto"> <MudStack class="my-auto">
<p class="text-lg font-extrabold font-iranyekan">ورود | ثبت نام</p> <p class="font-iranyekan text-lg font-extrabold">ورود | ثبت نام</p>
<p class="text-xs text-justify"> <p class="text-justify text-xs">
برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را
وارد کنید وارد کنید
</p> </p>
@ -109,11 +109,11 @@
</div> </div>
</MudCarouselItem> </MudCarouselItem>
<MudCarouselItem> <MudCarouselItem>
<div class="flex flex-col h-full"> <div class="flex h-full flex-col">
<MudStack class="p-5 my-auto font-iranyekan"> <MudStack class="font-iranyekan my-auto p-5">
<p class="text-lg font-extrabold font-iranyekan">ورود | ثبت نام</p> <p class="font-iranyekan text-lg font-extrabold">ورود | ثبت نام</p>
<p class="text-xs text-justify"> <p class="text-justify text-xs">
برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را برای ورود یا ثبت نام به اپلیکیشن داکیومد باید شماره تلفن همراه خود را
وارد کنید وارد کنید
</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="flex flex-row mr-5"> <div class="mr-5 flex flex-row">
<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 flex-col h-full"> <div class="flex h-full flex-col">
<MudStack class="w-screen p-5 my-auto font-iranyekan"> <MudStack class="font-iranyekan my-auto w-screen p-5">
<p class="text-lg font-extrabold font-iranyekan">ثبت نام</p> <p class="font-iranyekan text-lg font-extrabold">ثبت نام</p>
<p class="text-xs text-justify"> <p class="text-justify text-xs">
برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد برای ثبت نام به اپلیکیشن داکیومد باید اطلاعات کامل خود را وارد
کنید کنید
</p> </p>
<MudForm @ref="_confirmSignUpForm"> <MudForm @ref="_confirmSignUpForm">
<MudFocusTrap> <MudFocusTrap>
<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.FirstName" 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 Required="true" RequiredError="نام خانوادگی خود را وارد کنید" @bind-Value="@_signUpRequest.LastName" class="my-5 text-sm" T="string" Label="نام خانوادگی" Variant="Variant.Outlined" />
<MudTextField class="text-sm my-5" T="string" @bind-Value="@_phoneNumber" Label="شماره تلفن همراه" <MudTextField class="my-5 text-sm" 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="flex flex-row w-full mx-auto"> <div class="mx-auto flex w-full flex-row">
<MudProgressCircular class="my-auto mr-1 -ml-4" Size="Size.Small" Indeterminate="true" /> <MudProgressCircular class="my-auto -ml-4 mr-1" Size="Size.Small" Indeterminate="true" />
<p class="font-bold my-1 mx-auto text-md">منتظر بمانید</p> <p class="text-md mx-auto my-1 font-bold">منتظر بمانید</p>
</div> </div>
</MudListItem> </MudListItem>
</MudList> </MudList>
@ -180,9 +180,9 @@
<ProgressIndicatorInPopoverTemplate> <ProgressIndicatorInPopoverTemplate>
<MudList Clickable="false"> <MudList Clickable="false">
<MudListItem> <MudListItem>
<div class="flex flex-row w-full mx-auto"> <div class="mx-auto flex w-full flex-row">
<MudProgressCircular class="my-auto mr-1 -ml-4" Size="Size.Small" Indeterminate="true" /> <MudProgressCircular class="my-auto -ml-4 mr-1" Size="Size.Small" Indeterminate="true" />
<p class="font-bold my-1 mx-auto text-md">منتظر بمانید</p> <p class="text-md mx-auto my-1 font-bold">منتظر بمانید</p>
</div> </div>
</MudListItem> </MudListItem>
</MudList> </MudList>

View File

@ -1,6 +1,7 @@
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,21 +1,14 @@
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class MedicalHistoryTemplatesPageViewModel : BaseViewModel<List<MedicalHistoryTemplateSDto>> public class MedicalHistoryTemplatesPageViewModel(
NavigationManager navigationManager,
IUserUtility userUtility,
IRestWrapper restWrapper,
ISnackbar snackbar)
: BaseViewModel<List<MedicalHistoryTemplateSDto>>
{ {
private readonly NavigationManager _navigationManager; public void CreateMedicalHistoryTemplateClicked() => navigationManager.NavigateTo("MedicalHistoryTemplateActionPage");
private readonly IUserUtility _userUtility; public void MedicalHistoryTemplateClicked(MedicalHistoryTemplateSDto template) => navigationManager.NavigateTo($"MedicalHistoryTemplateActionPage/{template.Id.ToString()}");
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()
{ {
@ -23,8 +16,8 @@ public class MedicalHistoryTemplatesPageViewModel : BaseViewModel<List<MedicalHi
{ {
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;
@ -33,11 +26,11 @@ public class MedicalHistoryTemplatesPageViewModel : BaseViewModel<List<MedicalHi
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,12 +3,16 @@ using Mapster;
namespace DocuMed.PWA.Pages; namespace DocuMed.PWA.Pages;
public class ProfilePageViewModel : BaseViewModel public class ProfilePageViewModel(
IUserUtility userUtility,
IRestWrapper restWrapper,
ISnackbar snackbar,
NavigationManager navigationManager)
: BaseViewModel
{ {
private readonly NavigationManager _navigationManager; public IUserUtility UserUtility { get; } = userUtility;
public IUserUtility UserUtility { get; } public IRestWrapper RestWrapper { get; } = restWrapper;
public IRestWrapper RestWrapper { get; } public ISnackbar Snackbar { get; } = snackbar;
public ISnackbar Snackbar { get; }
public ApplicationUserSDto User { get; set; } = new(); public ApplicationUserSDto User { get; set; } = new();
@ -21,14 +25,6 @@ public class ProfilePageViewModel : BaseViewModel
public readonly string Version = Assembly.GetAssembly(typeof(Program))?.GetName()?.Version?.ToString() ?? string.Empty; public 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();
@ -93,7 +89,7 @@ public class ProfilePageViewModel : BaseViewModel
public async Task LogoutAsync() public async Task LogoutAsync()
{ {
await UserUtility.LogoutAsync(); await UserUtility.LogoutAsync();
_navigationManager.NavigateTo(""); navigationManager.NavigateTo("");
} }

View File

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

View File

@ -2,24 +2,17 @@
namespace DocuMed.PWA.Utilities; namespace DocuMed.PWA.Utilities;
public class UserUtility : IUserUtility public class UserUtility(ILocalStorageService localStorageService) : IUserUtility
{ {
private readonly ILocalStorageService _localStorageService; public async Task<string> GetBearerTokenAsync() => await localStorageService.GetItemAsStringAsync(LocalStorageKeys.Token);
public async Task SetBearerTokenAsync(string token) => await localStorageService.SetItemAsStringAsync(LocalStorageKeys.Token, token);
public UserUtility(ILocalStorageService localStorageService) public async Task<ApplicationUserSDto> GetUserAsync() => await localStorageService.GetItemAsync<ApplicationUserSDto>(LocalStorageKeys.UserInfo);
{ 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,5 +1,111 @@
/* *, ::before, ::after {
! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com --tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}/*
! tailwindcss v3.4.13 | MIT License | https://tailwindcss.com
*//* *//*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) 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)
@ -402,115 +508,7 @@ video {
--color-secondary: rgba(253, 85, 35, 1); --color-secondary: rgba(253, 85, 35, 1);
--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

@ -0,0 +1,69 @@
<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,45 +24,49 @@
<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.Common.Extensions" /> <Using Include="DocuMed.Domain.CommandQueries.Queries" />
<Using Include="DocuMed.Common.Models" /> <Using Include="DocuMed.Domain.Entities.Hospitals" />
<Using Include="DocuMed.Common.Models.Api" /> <Using Include="DocuMed.Common.Extensions" />
<Using Include="DocuMed.Common.Models.Claims" /> <Using Include="DocuMed.Common.Models" />
<Using Include="DocuMed.Common.Models.Entity" /> <Using Include="DocuMed.Common.Models.Api" />
<Using Include="DocuMed.Common.Models.Exception" /> <Using Include="DocuMed.Common.Models.Claims" />
<Using Include="DocuMed.Domain.Dtos.LargDtos" /> <Using Include="DocuMed.Common.Models.Entity" />
<Using Include="DocuMed.Domain.Dtos.SmallDtos" /> <Using Include="DocuMed.Common.Models.Exception" />
<Using Include="DocuMed.Domain.Entities.MedicalHistory" /> <Using Include="DocuMed.Domain.CommandQueries.Commands" />
<Using Include="DocuMed.Domain.Entities.MedicalHistoryTemplate" /> <Using Include="DocuMed.Domain.Dtos.LargDtos" />
<Using Include="DocuMed.Domain.Entities.User" /> <Using Include="DocuMed.Domain.Dtos.SmallDtos" />
<Using Include="DocuMed.Domain.Enums" /> <Using Include="DocuMed.Domain.Entities.MedicalHistory" />
<Using Include="DocuMed.Domain.Enums.QueryFilters" /> <Using Include="DocuMed.Domain.Entities.MedicalHistoryTemplate" />
<Using Include="DocuMed.Domain.Mappers" /> <Using Include="DocuMed.Domain.Entities.User" />
<Using Include="DocuMed.Domain.Models.Settings" /> <Using Include="DocuMed.Domain.Enums" />
<Using Include="DocuMed.Repository.Abstracts" /> <Using Include="DocuMed.Domain.Enums.QueryFilters" />
<Using Include="DocuMed.Repository.Extensions" /> <Using Include="DocuMed.Domain.Mappers" />
<Using Include="DocuMed.Repository.Models" /> <Using Include="DocuMed.Domain.Models.Settings" />
<Using Include="DocuMed.Repository.Repositories.Base" /> <Using Include="DocuMed.Repository.Abstracts" />
<Using Include="DocuMed.Repository.Repositories.Base.Contracts" /> <Using Include="DocuMed.Repository.Extensions" />
<Using Include="DocuMed.Repository.Repositories.Entities.Abstracts" /> <Using Include="DocuMed.Repository.Models" />
<Using Include="DocuMed.Repository.Services.Contracts" /> <Using Include="DocuMed.Repository.Repositories.Base" />
<Using Include="Microsoft.AspNetCore.Identity" /> <Using Include="DocuMed.Repository.Repositories.Base.Contracts" />
<Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" /> <Using Include="DocuMed.Repository.Repositories.Entities.Abstracts" />
<Using Include="Microsoft.EntityFrameworkCore" /> <Using Include="DocuMed.Repository.Services.Contracts" />
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" /> <Using Include="MediatR" />
<Using Include="Microsoft.EntityFrameworkCore.Infrastructure" /> <Using Include="Microsoft.AspNetCore.Identity" />
<Using Include="Microsoft.EntityFrameworkCore.Storage" /> <Using Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<Using Include="Microsoft.Extensions.DependencyInjection" /> <Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.Extensions.Logging" /> <Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
<Using Include="Microsoft.Extensions.Options" /> <Using Include="Microsoft.EntityFrameworkCore.Infrastructure" />
<Using Include="Pluralize.NET" /> <Using Include="Microsoft.EntityFrameworkCore.Storage" />
<Using Include="System.Diagnostics" /> <Using Include="Microsoft.Extensions.DependencyInjection" />
<Using Include="System.Reflection" /> <Using Include="Microsoft.Extensions.Logging" />
</ItemGroup> <Using Include="Microsoft.Extensions.Options" />
<Using Include="Pluralize.NET" />
<Using Include="System.Diagnostics" />
<Using Include="System.Reflection" />
</ItemGroup>
</Project> </Project>

View File

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

View File

@ -0,0 +1,16 @@
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

@ -0,0 +1,19 @@
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

@ -0,0 +1,16 @@
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

@ -0,0 +1,16 @@
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

@ -0,0 +1,23 @@
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,863 +0,0 @@
// <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

@ -1,600 +0,0 @@
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

@ -1,867 +0,0 @@
// <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

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

@ -1,867 +0,0 @@
// <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

@ -1,108 +0,0 @@
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

@ -1,871 +0,0 @@
// <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

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

@ -1,868 +0,0 @@
// <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,15 +1,9 @@
namespace DocuMed.Repository.Models; namespace DocuMed.Repository.Models;
public class ApplicationContext : IdentityDbContext<ApplicationUser,ApplicationRole,Guid> public class ApplicationContext(DbContextOptions<ApplicationContext> options, ILogger<ApplicationContext> logger)
: IdentityDbContext<ApplicationUser, ApplicationRole, Guid>(options)
{ {
private readonly ILogger<ApplicationContext> _logger; private readonly Assembly _projectAssembly = options.GetExtension<DbContextOptionCustomExtensions>().ProjectAssembly;
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)
@ -18,9 +12,9 @@ public class ApplicationContext : IdentityDbContext<ApplicationUser,ApplicationR
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,14 +2,11 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class BaseRepository<T> : Repository<T>, IBaseRepository<T> where T : class, IApiEntity public class BaseRepository<T>(ApplicationContext dbContext, ICurrentUserService currentUserService)
: Repository<T>(dbContext), IBaseRepository<T>
where T : class, IApiEntity
{ {
protected readonly ICurrentUserService CurrentUserService; protected readonly ICurrentUserService CurrentUserService = 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,12 +1,9 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class ReadRepository<T> : Repository<T>, IDisposable, IReadRepository<T> where T : class, IApiEntity public class ReadRepository<T>(ApplicationContext dbContext)
: 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,16 +1,10 @@
namespace DocuMed.Repository.Repositories.Base; namespace DocuMed.Repository.Repositories.Base;
public class RepositoryWrapper : IRepositoryWrapper public class RepositoryWrapper(ApplicationContext context, ICurrentUserService currentUserService)
: IRepositoryWrapper
{ {
private readonly ApplicationContext _context;
private readonly ICurrentUserService _currentUserService;
private IDbContextTransaction? _currentTransaction; 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)
@ -27,26 +21,26 @@ public class RepositoryWrapper : IRepositoryWrapper
} }
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)
@ -55,9 +49,9 @@ public class RepositoryWrapper : IRepositoryWrapper
{ {
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;
} }
} }
} }
@ -65,6 +59,6 @@ public class RepositoryWrapper : IRepositoryWrapper
public void Dispose() public void Dispose()
{ {
_currentTransaction?.Dispose(); _currentTransaction?.Dispose();
_context?.Dispose(); context?.Dispose();
} }
} }

View File

@ -1,11 +1,9 @@
namespace DocuMed.Repository.Repositories.Base namespace DocuMed.Repository.Repositories.Base
{ {
public class WriteRepository<T> : Repository<T>, IDisposable, IWriteRepository<T> where T : class, IApiEntity public class WriteRepository<T>(ApplicationContext dbContext)
: 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,11 +1,8 @@
namespace DocuMed.Repository.Repositories.Entities; namespace DocuMed.Repository.Repositories.Entities;
public class MedicalHistoryRepository : BaseRepository<MedicalHistory>,IMedicalHistoryRepository public class MedicalHistoryRepository(ApplicationContext dbContext, ICurrentUserService currentUserService)
: 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,11 +1,8 @@
namespace DocuMed.Repository.Repositories.Entities; namespace DocuMed.Repository.Repositories.Entities;
public class MedicalHistoryTemplateRepository : BaseRepository<MedicalHistoryTemplate>, IMedicalHistoryTemplateRepository public class MedicalHistoryTemplateRepository(ApplicationContext dbContext, ICurrentUserService currentUserService)
: 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,13 +1,8 @@
namespace DocuMed.Repository.Repositories.UnitOfWork; namespace DocuMed.Repository.Repositories.UnitOfWork;
public class UnitOfWork : IUnitOfWork public class UnitOfWork(ApplicationContext applicationContext) : 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()
{ {
@ -23,17 +18,17 @@ public class UnitOfWork : 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,37 +1,23 @@
namespace DocuMed.Repository.Services; namespace DocuMed.Repository.Services;
public class DbInitializerService : IDbInitializerService public class DbInitializerService(
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);
} }
} }
@ -41,8 +27,8 @@ public class DbInitializerService : IDbInitializerService
{ {
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
@ -58,8 +44,8 @@ public class DbInitializerService : IDbInitializerService
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)
@ -71,8 +57,8 @@ public class DbInitializerService : IDbInitializerService
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)
{ {
@ -82,9 +68,9 @@ public class DbInitializerService : IDbInitializerService
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);
} }
} }
} }