hrms-api-exam/Controllers/PrefixController.cs
2023-03-23 12:31:21 +07:00

59 lines
1.9 KiB
C#

using BMA.EHR.Recurit.Exam.Service.Response;
using BMA.EHR.Recurit.Exam.Service.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace BMA.EHR.Recurit.Exam.Service.Controllers
{
[Route("api/v{version:apiVersion}/prefix")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
public class PrefixController : BaseController
{
#region " Fields "
private readonly PrefixService _prefixService;
#endregion
#region " Constructor and Destructor "
public PrefixController(PrefixService prefixService)
{
_prefixService = prefixService;
}
#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 _prefixService.GetsAsync(showAll: false);
return Success(items);
}
catch (Exception ex)
{
return Error(ex);
}
}
#endregion
}
}