All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m49s
105 lines
3.2 KiB
C#
105 lines
3.2 KiB
C#
using BMA.EHR.Domain.Extensions;
|
|
using BMA.EHR.Domain.Shared;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BMA.EHR.Domain.Common
|
|
{
|
|
public class BaseController : ControllerBase
|
|
{
|
|
#region " Methods "
|
|
|
|
#region " Protected "
|
|
|
|
#region " IActionResult "
|
|
|
|
protected virtual ActionResult<ResponseObject> Success(string message, object? result = null)
|
|
{
|
|
if (result != null)
|
|
{
|
|
return Ok(new ResponseObject
|
|
{
|
|
Status = StatusCodes.Status200OK,
|
|
Message = message,
|
|
Result = result
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return Ok(new ResponseObject
|
|
{
|
|
Status = StatusCodes.Status200OK,
|
|
Message = message
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
protected virtual ActionResult<ResponseObject> Success(object? result = null)
|
|
{
|
|
return Success(GlobalMessages.Success, result);
|
|
}
|
|
|
|
protected virtual ActionResult<ResponseObject> Error(string message, string result, int statusCode = StatusCodes.Status500InternalServerError)
|
|
{
|
|
return StatusCode((int)statusCode, new ResponseObject
|
|
{
|
|
Status = statusCode,
|
|
Message = message,
|
|
Result = result
|
|
});
|
|
}
|
|
|
|
protected virtual ActionResult<ResponseObject> Error(string message, int statusCode = StatusCodes.Status500InternalServerError)
|
|
{
|
|
return Error(message, message, statusCode);
|
|
}
|
|
|
|
protected virtual ActionResult<ResponseObject> Error(Exception exception, string message, int statusCode = StatusCodes.Status500InternalServerError)
|
|
{
|
|
var msg = exception.Message;
|
|
var inner = exception.InnerException;
|
|
while (inner != null)
|
|
{
|
|
msg += $" {inner.Message}\r\n";
|
|
inner = inner.InnerException;
|
|
}
|
|
|
|
return Error(message, msg, statusCode);
|
|
}
|
|
|
|
protected virtual ActionResult<ResponseObject> Error(Exception exception, int statusCode = StatusCodes.Status500InternalServerError)
|
|
{
|
|
var msg = exception.Message;
|
|
var inner = exception.InnerException;
|
|
while (inner != null)
|
|
{
|
|
msg += $" {inner.Message}\r\n";
|
|
inner = inner.InnerException;
|
|
}
|
|
|
|
return Error(msg, msg, statusCode);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region " Properties "
|
|
|
|
protected string? EmpType => User.GetEmpType();
|
|
protected Guid? OrgChild1DnaId => User.GetOrgChild1DnaId();
|
|
protected Guid? OrgChild2DnaId => User.GetOrgChild2DnaId();
|
|
protected Guid? OrgChild3DnaId => User.GetOrgChild3DnaId();
|
|
protected Guid? OrgChild4DnaId => User.GetOrgChild4DnaId();
|
|
protected Guid? OrgRootDnaId => User.GetOrgRootDnaId();
|
|
protected Guid? ProfileId => User.GetProfileId();
|
|
protected string? Prefix => User.GetPrefix();
|
|
protected string? FullNameFromClaim => User.GetName();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|