Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 11s
Some checks failed
release-dev / release-dev (push) Failing after 11s
This commit is contained in:
commit
3f7c3e6852
15 changed files with 1147 additions and 91 deletions
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-executive")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลประเภทตำแหน่ง เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionExecutiveController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionExecutiveService _positionExecutiveService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionExecutiveController(PositionExecutiveService positionExecutiveService)
|
||||||
|
{
|
||||||
|
_positionExecutiveService = positionExecutiveService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionExecutiveService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-executive-side")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลด้านการบริหาร เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionExecutiveSideController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionExecutiveSideService _positionExecutiveSideService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionExecutiveSideController(PositionExecutiveSideService positionExecutiveSideService)
|
||||||
|
{
|
||||||
|
_positionExecutiveSideService = positionExecutiveSideService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionExecutiveSideService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-level")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลระดับตำแหน่ง เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionLevelController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionLevelService _positionLevelService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionLevelController(PositionLevelService positionLevelService)
|
||||||
|
{
|
||||||
|
_positionLevelService = positionLevelService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionLevelService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-line")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลสายงานตำแหน่ง เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionLineController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionLineService _positionLineService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionLineController(PositionLineService positionLineService)
|
||||||
|
{
|
||||||
|
_positionLineService = positionLineService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionLineService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-path")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลสายงาน เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionPathController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionPathService _positionPathService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionPathController(PositionPathService positionPathService)
|
||||||
|
{
|
||||||
|
_positionPathService = positionPathService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionPathService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-path-side")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลด้าน/สาขา เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionPathSideController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionPathSideService _positionPathSideService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionPathSideController(PositionPathSideService positionPathSideService)
|
||||||
|
{
|
||||||
|
_positionPathSideService = positionPathSideService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionPathSideService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.MetaData.Service.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/metadata/position-type")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("จัดการข้อมูลประเภทตำแหน่ง เพื่อนำไปใช้งานในระบบ")]
|
||||||
|
public class PositionTypeController : BaseController
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly PositionTypeService _positionTypeService;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionTypeController(PositionTypeService positionTypeService)
|
||||||
|
{
|
||||||
|
_positionTypeService = positionTypeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อ่านข้อมูลจาก Relational Db โดยแสดงเฉพาะข้อมูลที่ Active เท่านั้น
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetsAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var items = await _positionTypeService.GetsAsync(showAll: false);
|
||||||
|
|
||||||
|
return Success(items);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,35 +19,35 @@ using System.Text;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
{
|
{
|
||||||
var issuer = builder.Configuration["Jwt:Issuer"];
|
var issuer = builder.Configuration["Jwt:Issuer"];
|
||||||
var key = builder.Configuration["Jwt:Key"];
|
var key = builder.Configuration["Jwt:Key"];
|
||||||
|
|
||||||
|
|
||||||
IdentityModelEventSource.ShowPII = true;
|
IdentityModelEventSource.ShowPII = true;
|
||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
builder.Services.AddApiVersioning(opt =>
|
builder.Services.AddApiVersioning(opt =>
|
||||||
{
|
{
|
||||||
opt.DefaultApiVersion = new ApiVersion(1, 0);
|
opt.DefaultApiVersion = new ApiVersion(1, 0);
|
||||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||||
opt.ReportApiVersions = true;
|
opt.ReportApiVersions = true;
|
||||||
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
|
||||||
new HeaderApiVersionReader("x-api-version"),
|
new HeaderApiVersionReader("x-api-version"),
|
||||||
new MediaTypeApiVersionReader("x-api-version"));
|
new MediaTypeApiVersionReader("x-api-version"));
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddVersionedApiExplorer(setup =>
|
builder.Services.AddVersionedApiExplorer(setup =>
|
||||||
{
|
{
|
||||||
setup.GroupNameFormat = "'v'VVV";
|
setup.GroupNameFormat = "'v'VVV";
|
||||||
setup.SubstituteApiVersionInUrl = true;
|
setup.SubstituteApiVersionInUrl = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
// Authorization
|
// Authorization
|
||||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(opt =>
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(opt =>
|
||||||
{
|
{
|
||||||
opt.RequireHttpsMetadata = false; //false for dev
|
opt.RequireHttpsMetadata = false; //false for dev
|
||||||
opt.Authority = issuer;
|
opt.Authority = issuer;
|
||||||
opt.TokenValidationParameters = new()
|
opt.TokenValidationParameters = new()
|
||||||
|
|
@ -60,104 +60,111 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key))
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
builder.Services.AddAuthorization();
|
builder.Services.AddAuthorization();
|
||||||
|
|
||||||
// use serilog
|
// use serilog
|
||||||
ConfigureLogs();
|
ConfigureLogs();
|
||||||
builder.Host.UseSerilog();
|
builder.Host.UseSerilog();
|
||||||
|
|
||||||
// Add config CORS
|
// Add config CORS
|
||||||
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
|
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.AllowAnyOrigin()
|
.AllowAnyOrigin()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.SetIsOriginAllowedToAllowWildcardSubdomains();
|
.SetIsOriginAllowedToAllowWildcardSubdomains();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddApplication();
|
builder.Services.AddApplication();
|
||||||
builder.Services.AddPersistence(builder.Configuration);
|
builder.Services.AddPersistence(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.AddTransient<HolidayService>();
|
builder.Services.AddTransient<HolidayService>();
|
||||||
builder.Services.AddControllers(options =>
|
builder.Services.AddTransient<PositionExecutiveService>();
|
||||||
{
|
builder.Services.AddTransient<PositionExecutiveSideService>();
|
||||||
options.SuppressAsyncSuffixInActionNames = false;
|
builder.Services.AddTransient<PositionLevelService>();
|
||||||
})
|
builder.Services.AddTransient<PositionLineService>();
|
||||||
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
builder.Services.AddTransient<PositionPathService>();
|
||||||
|
builder.Services.AddTransient<PositionPathSideService>();
|
||||||
|
builder.Services.AddTransient<PositionTypeService>();
|
||||||
|
builder.Services.AddControllers(options =>
|
||||||
|
{
|
||||||
|
options.SuppressAsyncSuffixInActionNames = false;
|
||||||
|
})
|
||||||
|
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
||||||
|
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
|
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
|
||||||
|
|
||||||
builder.Services.AddHealthChecks();
|
builder.Services.AddHealthChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
{
|
{
|
||||||
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
||||||
|
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options =>
|
app.UseSwaggerUI(options =>
|
||||||
{
|
{
|
||||||
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
||||||
{
|
{
|
||||||
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
||||||
description.GroupName.ToUpperInvariant());
|
description.GroupName.ToUpperInvariant());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.MapHealthChecks("/health");
|
||||||
|
|
||||||
app.MapHealthChecks("/health");
|
|
||||||
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.UseDefaultFiles();
|
app.UseDefaultFiles();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.UseMiddleware<ErrorHandlerMiddleware>();
|
app.UseMiddleware<ErrorHandlerMiddleware>();
|
||||||
|
|
||||||
// apply migrations
|
// apply migrations
|
||||||
await using var scope = app.Services.CreateAsyncScope();
|
await using var scope = app.Services.CreateAsyncScope();
|
||||||
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
|
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
|
||||||
await db.Database.MigrateAsync();
|
await db.Database.MigrateAsync();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureLogs()
|
void ConfigureLogs()
|
||||||
{
|
{
|
||||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||||
var configuration = new ConfigurationBuilder()
|
var configuration = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(
|
.AddJsonFile(
|
||||||
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json",
|
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json",
|
||||||
optional: true)
|
optional: true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
.MinimumLevel.Error()
|
.MinimumLevel.Error()
|
||||||
.WriteTo.Console()
|
.WriteTo.Console()
|
||||||
.Enrich.WithExceptionDetails()
|
.Enrich.WithExceptionDetails()
|
||||||
.WriteTo.Elasticsearch(ConfigureElasticSink(configuration, environment ?? ""))
|
.WriteTo.Elasticsearch(ConfigureElasticSink(configuration, environment ?? ""))
|
||||||
.Enrich.WithProperty("Environment", environment)
|
.Enrich.WithProperty("Environment", environment)
|
||||||
.ReadFrom.Configuration(configuration)
|
.ReadFrom.Configuration(configuration)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElasticsearchSinkOptions ConfigureElasticSink(IConfigurationRoot configuration, string environment)
|
ElasticsearchSinkOptions ConfigureElasticSink(IConfigurationRoot configuration, string environment)
|
||||||
{
|
{
|
||||||
return new ElasticsearchSinkOptions(new Uri(configuration["ElasticConfiguration:Uri"] ?? ""))
|
return new ElasticsearchSinkOptions(new Uri(configuration["ElasticConfiguration:Uri"] ?? ""))
|
||||||
{
|
{
|
||||||
AutoRegisterTemplate = true,
|
AutoRegisterTemplate = true,
|
||||||
IndexFormat = $"{Assembly.GetExecutingAssembly()?.GetName()?.Name?.ToLower().Replace(".", "-")}-{environment?.ToLower().Replace(".", "-")}"
|
IndexFormat = $"{Assembly.GetExecutingAssembly()?.GetName()?.Name?.ToLower().Replace(".", "-")}-{environment?.ToLower().Replace(".", "-")}"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionExecutiveService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionExecutiveService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionExecutive>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionExecutives.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionExecutives.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionExecutive?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionExecutives.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionExecutive updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionExecutives.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionExecutive inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionExecutives.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionExecutiveSideService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionExecutiveSideService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionExecutiveSide>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionExecutiveSides.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionExecutiveSides.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionExecutiveSide?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionExecutiveSides.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionExecutiveSide updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionExecutiveSides.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.Note = updated.Note;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionExecutiveSide inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionExecutiveSides.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
90
BMA.EHR.MetaData.Service/Services/PositionLevelService.cs
Normal file
90
BMA.EHR.MetaData.Service/Services/PositionLevelService.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionLevelService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionLevelService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionLevel>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionLevels.AsQueryable()
|
||||||
|
.OrderBy(d => d.Level)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionLevels.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Level)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionLevel?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionLevels.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionLevel updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionLevels.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.ShortName != updated.ShortName || existData.Level != updated.Level || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Level = updated.Level;
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.ShortName = updated.ShortName;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionLevel inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionLevels.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
89
BMA.EHR.MetaData.Service/Services/PositionLineService.cs
Normal file
89
BMA.EHR.MetaData.Service/Services/PositionLineService.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionLineService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionLineService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionLine>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionLines.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionLines.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionLine?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionLines.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionLine updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionLines.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionLine inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionLines.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
89
BMA.EHR.MetaData.Service/Services/PositionPathService.cs
Normal file
89
BMA.EHR.MetaData.Service/Services/PositionPathService.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionPathService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionPathService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionPath>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionPaths.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionPaths.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionPath?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionPath updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.Note = updated.Note;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionPath inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionPaths.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
89
BMA.EHR.MetaData.Service/Services/PositionPathSideService.cs
Normal file
89
BMA.EHR.MetaData.Service/Services/PositionPathSideService.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionPathSideService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionPathSideService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionPathSide>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionPathSides.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionPathSides.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionPathSide?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionPathSides.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionPathSide updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionPathSides.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.Note = updated.Note;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionPathSide inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionPathSides.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
88
BMA.EHR.MetaData.Service/Services/PositionTypeService.cs
Normal file
88
BMA.EHR.MetaData.Service/Services/PositionTypeService.cs
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
using System.Security.Claims;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.MetaData.Service.Services
|
||||||
|
{
|
||||||
|
public class PositionTypeService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public PositionTypeService(ApplicationDBContext context,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<IEnumerable<PositionType>> GetsAsync(bool showAll = true)
|
||||||
|
{
|
||||||
|
if (showAll)
|
||||||
|
return await _context.PositionTypes.AsQueryable()
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
else
|
||||||
|
return await _context.PositionTypes.AsQueryable()
|
||||||
|
.Where(p => p.IsActive)
|
||||||
|
.OrderBy(d => d.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PositionType?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.PositionTypes.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateAsync(Guid id, PositionType updated)
|
||||||
|
{
|
||||||
|
var existData = await _context.PositionTypes.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (existData != null)
|
||||||
|
{
|
||||||
|
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
|
||||||
|
{
|
||||||
|
existData.Name = updated.Name;
|
||||||
|
existData.IsActive = updated.IsActive;
|
||||||
|
existData.LastUpdatedAt = DateTime.Now;
|
||||||
|
existData.LastUpdateUserId = UserId ?? "";
|
||||||
|
existData.LastUpdateFullName = FullName ?? "";
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task CreateAsync(PositionType inserted)
|
||||||
|
{
|
||||||
|
inserted.CreatedUserId = UserId ?? "";
|
||||||
|
inserted.CreatedFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.CreatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdatedAt = DateTime.Now;
|
||||||
|
inserted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
inserted.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
||||||
|
await _context.PositionTypes.AddAsync(inserted);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue