This commit is contained in:
@@ -127,28 +127,28 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get available types allowed for Custom fields
|
||||
/// Used to build UI for customizing a form
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull only has rights to customize forms
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>A list of type string values valid for custom fields</returns>
|
||||
[HttpGet("AvailableCustomTypes")]
|
||||
public ActionResult GetAvailableCustomTypes()
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
// /// <summary>
|
||||
// /// Get available types allowed for Custom fields
|
||||
// /// Used to build UI for customizing a form
|
||||
// ///
|
||||
// /// Required roles:
|
||||
// /// BizAdminFull only has rights to customize forms
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <returns>A list of type string values valid for custom fields</returns>
|
||||
// [HttpGet("AvailableCustomTypes")]
|
||||
// public ActionResult GetAvailableCustomTypes()
|
||||
// {
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
return Ok(ApiOkResponse.Response(CustomFieldType.ValidCustomFieldTypes, true));
|
||||
}
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// return Ok(ApiOkResponse.Response(CustomFieldType.ValidCustomFieldTypes, true));
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -221,38 +221,38 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Post FormCustom
|
||||
///
|
||||
/// Required roles: BizAdminFull
|
||||
/// </summary>
|
||||
/// <param name="inObj"></param>
|
||||
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
// /// <summary>
|
||||
// /// Post FormCustom
|
||||
// ///
|
||||
// /// Required roles: BizAdminFull
|
||||
// /// </summary>
|
||||
// /// <param name="inObj"></param>
|
||||
// /// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
|
||||
// /// <returns></returns>
|
||||
// [HttpPost]
|
||||
// public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj, ApiVersion apiVersion)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
//Instantiate the business object handler
|
||||
FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
|
||||
// //Instantiate the business object handler
|
||||
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
//check rights
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// //check rights
|
||||
// if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
//Create and validate
|
||||
FormCustom o = await biz.CreateAsync(inObj);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(FormCustomController.GetFormCustom), new { formkey = o.FormKey, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
// //Create and validate
|
||||
// FormCustom o = await biz.CreateAsync(inObj);
|
||||
// if (o == null)
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return CreatedAtAction(nameof(FormCustomController.GetFormCustom), new { formkey = o.FormKey, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user