This commit is contained in:
2018-10-04 00:16:17 +00:00
parent f95dc34b41
commit 0f9ac2600c
20 changed files with 127 additions and 145 deletions

View File

@@ -297,6 +297,9 @@ namespace AyaNova.Api.Controllers
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
//Instantiate the business object handler
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
//If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner
if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, WidgetBiz.BizType))
{
@@ -308,9 +311,6 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
}
//Instantiate the business object handler
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
//Create and validate
Widget o = await biz.CreateAsync(inObj);
@@ -352,6 +352,9 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
}
//Instantiate the business object handler
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
var dbObj = await ct.Widget.SingleOrDefaultAsync(m => m.Id == id);
if (dbObj == null)
{
@@ -363,9 +366,6 @@ namespace AyaNova.Api.Controllers
return StatusCode(401, new ApiNotAuthorizedResponse());
}
//Instantiate the business object handler
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
if (!biz.Delete(dbObj))
{
return BadRequest(new ApiErrorResponse(biz.Errors));