This commit is contained in:
2019-01-11 00:10:40 +00:00
parent 0a38df71dd
commit db67a570d0
2 changed files with 10 additions and 11 deletions

View File

@@ -131,15 +131,14 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Put (update) FormCustom /// Put (update) FormCustom
/// ///
/// Required roles: /// Required roles: BizAdminFull
/// Any (public filter) or owned only (private filter)
/// ///
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="formkey"></param>
/// <param name="inObj"></param> /// <param name="inObj"></param>
/// <returns></returns> /// <returns></returns>
[HttpPut("{id}")] [HttpPut("{formkey}")]
public async Task<IActionResult> PutFormCustom([FromRoute] long id, [FromBody] FormCustom inObj) public async Task<IActionResult> PutFormCustom([FromRoute] string formkey, [FromBody] FormCustom inObj)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -150,7 +149,7 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler //Instantiate the business object handler
FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext); FormCustomBiz biz = FormCustomBiz.GetBiz(ct, HttpContext);
var o = await biz.GetNoLogAsync(id); var o = await biz.GetNoLogAsync(formkey);
if (o == null) if (o == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
@@ -164,7 +163,7 @@ namespace AyaNova.Api.Controllers
} }
catch (DbUpdateConcurrencyException) catch (DbUpdateConcurrencyException)
{ {
if (!await biz.ExistsAsync(id)) if (!await biz.ExistsAsync(formkey))
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
else else
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT)); return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));

View File

@@ -37,17 +37,17 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//EXISTS //EXISTS
internal async Task<bool> ExistsAsync(long id) internal async Task<bool> ExistsAsync(string formKey)
{ {
return await ct.FormCustom.AnyAsync(e => e.Id == id); return await ct.FormCustom.AnyAsync(x => x.FormKey == formKey);
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
/// GET /// GET
internal async Task<FormCustom> GetNoLogAsync(long fetchId) internal async Task<FormCustom> GetNoLogAsync(string formKey)
{ {
//This is simple so nothing more here, but often will be copying to a different output object or some other ops //This is simple so nothing more here, but often will be copying to a different output object or some other ops
return await ct.FormCustom.SingleOrDefaultAsync(m => m.Id == fetchId); return await ct.FormCustom.SingleOrDefaultAsync(x => x.FormKey == formKey);
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////