This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user