This commit is contained in:
@@ -128,49 +128,49 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Put (update) FormCustom
|
||||
// ///
|
||||
// /// Required roles:
|
||||
// /// Any (public filter) or owned only (private filter)
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="id"></param>
|
||||
// /// <param name="inObj"></param>
|
||||
// /// <returns></returns>
|
||||
// [HttpPut("{id}")]
|
||||
// public async Task<IActionResult> PutFormCustom([FromRoute] long id, [FromBody] FormCustom inObj)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
/// <summary>
|
||||
/// Put (update) FormCustom
|
||||
///
|
||||
/// Required roles:
|
||||
/// Any (public filter) or owned only (private filter)
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="inObj"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutFormCustom([FromRoute] long id, [FromBody] FormCustom inObj)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
|
||||
//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));
|
||||
var o = await biz.GetNoLogAsync(id);
|
||||
if (o == null)
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
// if (!Authorized.IsAuthorizedToModify(HttpContext.Items, biz.BizType, o.OwnerId))
|
||||
// return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
if (!Authorized.IsAuthorizedToModify(HttpContext.Items, biz.BizType, o.OwnerId))
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
|
||||
// try
|
||||
// {
|
||||
// if (!biz.Put(o, inObj))
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// }
|
||||
// catch (DbUpdateConcurrencyException)
|
||||
// {
|
||||
// if (!await biz.ExistsAsync(id))
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
// else
|
||||
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
||||
// }
|
||||
// return Ok(new ApiOkResponse(new { ConcurrencyToken = o.ConcurrencyToken }));
|
||||
// }
|
||||
try
|
||||
{
|
||||
if (!biz.Put(o, inObj))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!await biz.ExistsAsync(id))
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
else
|
||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
||||
}
|
||||
return Ok(new ApiOkResponse(new { ConcurrencyToken = o.ConcurrencyToken }));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user