This commit is contained in:
2020-05-13 20:22:17 +00:00
parent 36cfa793e0
commit 8a88dcabe4
19 changed files with 22 additions and 31 deletions

View File

@@ -115,35 +115,26 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Post Customer
/// Create Customer
/// </summary>
/// <param name="inObj"></param>
/// <param name="newObject"></param>
/// <param name="apiVersion">From route path</param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> PostCustomer([FromBody] Customer inObj, ApiVersion apiVersion)
public async Task<IActionResult> PostCustomer([FromBody] Customer newObject, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
//Instantiate the business object handler
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
//If a user has change roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
//Create and validate
Customer o = await biz.CreateAsync(inObj);
Customer o = await biz.CreateAsync(newObject);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return CreatedAtAction(nameof(CustomerController.GetCustomer), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
}
/// <summary>