This commit is contained in:
@@ -14,13 +14,13 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("8.0")]
|
||||
[Route("api/v{version:apiVersion}/form-setting")]
|
||||
[Route("api/v{version:apiVersion}/form-user-options")]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
public class FormSettingController : ControllerBase
|
||||
public class FormUserOptionsController : ControllerBase
|
||||
{
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<FormSettingController> log;
|
||||
private readonly ILogger<FormUserOptionsController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// <param name="dbcontext"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="apiServerState"></param>
|
||||
public FormSettingController(AyContext dbcontext, ILogger<FormSettingController> logger, ApiServerState apiServerState)
|
||||
public FormUserOptionsController(AyContext dbcontext, ILogger<FormUserOptionsController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
@@ -37,40 +37,40 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create FormSetting
|
||||
/// Create FormUserOptions
|
||||
/// </summary>
|
||||
/// <param name="newObject"></param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostFormSetting([FromBody] FormSetting newObject, ApiVersion apiVersion)
|
||||
public async Task<IActionResult> PostFormUserOptions([FromBody] FormUserOptions newObject, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
FormSettingBiz biz = FormSettingBiz.GetBiz(ct, HttpContext);
|
||||
FormUserOptionsBiz biz = FormUserOptionsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
FormSetting o = await biz.CreateAsync(newObject);
|
||||
FormUserOptions o = await biz.CreateAsync(newObject);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(FormSettingController.GetFormSetting), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
return CreatedAtAction(nameof(FormUserOptionsController.GetFormUserOptions), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get FormSetting
|
||||
/// Get FormUserOptions
|
||||
/// </summary>
|
||||
/// <param name="formKey"></param>
|
||||
/// <returns>FormSetting</returns>
|
||||
/// <returns>FormUserOptions</returns>
|
||||
[HttpGet("{formKey}")]
|
||||
public async Task<IActionResult> GetFormSetting([FromRoute] string formKey)
|
||||
public async Task<IActionResult> GetFormUserOptions([FromRoute] string formKey)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
FormSettingBiz biz = FormSettingBiz.GetBiz(ct, HttpContext);
|
||||
FormUserOptionsBiz biz = FormUserOptionsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
@@ -81,18 +81,18 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update FormSetting
|
||||
/// Update FormUserOptions
|
||||
/// </summary>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> PutFormSetting([FromBody] FormSetting updatedObject)
|
||||
public async Task<IActionResult> PutFormUserOptions([FromBody] FormUserOptions updatedObject)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
FormSettingBiz biz = FormSettingBiz.GetBiz(ct, HttpContext);
|
||||
FormUserOptionsBiz biz = FormUserOptionsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);
|
||||
@@ -107,18 +107,18 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete FormSetting
|
||||
/// Delete FormUserOptions
|
||||
/// </summary>
|
||||
/// <param name="formKey"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{formKey}")]
|
||||
public async Task<IActionResult> DeleteFormSetting([FromRoute] string formKey)
|
||||
public async Task<IActionResult> DeleteFormUserOptions([FromRoute] string formKey)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
FormSettingBiz biz = FormSettingBiz.GetBiz(ct, HttpContext);
|
||||
FormUserOptionsBiz biz = FormUserOptionsBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.DeleteAsync(formKey))
|
||||
Reference in New Issue
Block a user