This commit is contained in:
2019-01-10 19:32:24 +00:00
parent 55266fd87f
commit d7c54cca70
3 changed files with 54 additions and 119 deletions

View File

@@ -127,30 +127,6 @@ namespace AyaNova.Api.Controllers
// /// <summary>
// /// Get FormCustom pick list
// ///
// /// Required roles: Any
// ///
// /// </summary>
// /// <returns>List of public or owned data filters for listKey provided</returns>
// [HttpGet("PickList", Name = nameof(FormCustomPickList))]
// public async Task<IActionResult> FormCustomPickList([FromQuery] string ListKey)
// {
// if (serverState.IsClosed)
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
// //Instantiate the business object handler
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
// var l = await biz.GetPickListAsync(ListKey);
// return Ok(new ApiOkResponse(l));
// }
// /// <summary>
// /// Put (update) FormCustom
@@ -197,75 +173,40 @@ namespace AyaNova.Api.Controllers
// }
// /// <summary>
// /// Post FormCustom
// ///
// /// Required roles:
// /// BizAdminFull, InventoryFull, TechFull
// /// </summary>
// /// <param name="inObj"></param>
// /// <returns></returns>
// [HttpPost]
// public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj)
// {
// 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>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> PostFormCustom([FromBody] FormCustom inObj)
{
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);
// //If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner
// if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, biz.BizType))
// return StatusCode(401, new ApiNotAuthorizedResponse());
//check rights
if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, biz.BizType))
return StatusCode(401, 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("GetFormCustom", new { id = o.Id }, new ApiCreatedResponse(o));
//Create and validate
FormCustom o = await biz.CreateAsync(inObj);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return CreatedAtAction("GetFormCustom", new { id = o.Id }, new ApiCreatedResponse(o));
// }
}
// /// <summary>
// /// Delete FormCustom
// ///
// /// Required roles:
// /// Any if public otherwise creator only
// ///
// /// </summary>
// /// <param name="id"></param>
// /// <returns>Ok</returns>
// [HttpDelete("{id}")]
// public async Task<IActionResult> DeleteFormCustom([FromRoute] long id)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
// //Instantiate the business object handler
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
// var o = await biz.GetNoLogAsync(id);
// if (o == null)
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// if (!Authorized.IsAuthorizedToDelete(HttpContext.Items, biz.BizType, o.OwnerId))
// return StatusCode(401, new ApiNotAuthorizedResponse());
// if (!biz.Delete(o))
// return BadRequest(new ApiErrorResponse(biz.Errors));
// return NoContent();
// }
//------------