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

View File

@@ -37,17 +37,17 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//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
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
return await ct.FormCustom.SingleOrDefaultAsync(m => m.Id == fetchId);
return await ct.FormCustom.SingleOrDefaultAsync(x => x.FormKey == formKey);
}
////////////////////////////////////////////////////////////////////////////////////////////////