แก้ไฟล์ build
This commit is contained in:
parent
9fb82fb45a
commit
d6573a6d0c
15 changed files with 1676 additions and 374 deletions
|
|
@ -1,90 +1,90 @@
|
|||
using BMA.EHR.Core;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Report.Service.Responses;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BMA.EHR.Profile.Service.Controllers
|
||||
{
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
#region " Methods "
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
#region " Methods "
|
||||
|
||||
#region " Protected "
|
||||
#region " Protected "
|
||||
|
||||
#region " IActionResult "
|
||||
#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(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> Success(object? result = null)
|
||||
{
|
||||
return 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, 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(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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
return Error(msg, msg, statusCode);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue