This commit is contained in:
@@ -15,6 +15,8 @@ todo: check attachment NOTES property is actually supported
|
||||
|
||||
todo: search tables in schema, I think there is a missing index here, need to look at the search query section again as it was changed several times from the original schema creation
|
||||
|
||||
API REFACTORING
|
||||
todo: all api route parameters, post object sb "newObject", put="updatedObject"
|
||||
todo: all api routes, re-arrange code in controller in this order POST (and postlike such as duplicate), GET, PUT, DELETE for consistency and logicality
|
||||
todo: all api route URI's sb lower case with dashes if necessary (use plural noun scheme)
|
||||
https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design#organize-the-api-around-resources
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Create Workorder
|
||||
/// </summary>
|
||||
/// <param name="inObj"></param>
|
||||
/// <param name="newObject"></param>
|
||||
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostWorkOrder([FromBody] WorkOrder inObj, ApiVersion apiVersion)
|
||||
public async Task<IActionResult> PostWorkOrder([FromBody] WorkOrder newObj, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -65,7 +65,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
//Create and validate
|
||||
WorkOrder o = await biz.CreateAsync(inObj);
|
||||
WorkOrder o = await biz.CreateAsync(newObj);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
@@ -159,10 +159,10 @@ namespace AyaNova.Api.Controllers
|
||||
/// Put (update) WorkOrder
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="inObj"></param>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutWorkOrder([FromRoute] long id, [FromBody] WorkOrder inObj)
|
||||
public async Task<IActionResult> PutWorkOrder([FromRoute] long id, [FromBody] WorkOrder updatedObject)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -182,7 +182,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
if (!await biz.PutAsync(o, inObj))
|
||||
if (!await biz.PutAsync(o, updatedObject))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
|
||||
Reference in New Issue
Block a user