This commit is contained in:
@@ -187,7 +187,7 @@ namespace AyaNova.Api.Controllers
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, o.Id, AyaType.Locale, AyaEvent.Created), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, o.Id, AyaType.Locale, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
return CreatedAtAction("GetLocale", new { id = o.Id }, new ApiCreatedResponse(o));
|
||||
@@ -247,7 +247,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oDbParent.Id, AyaType.Locale, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oDbParent.Id, AyaType.Locale, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -317,7 +317,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oFromDb.Id, AyaType.Locale, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oFromDb.Id, AyaType.Locale, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -387,7 +387,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
//Log
|
||||
EventLogProcessor.DeleteObject(biz.userId, AyaType.Locale, dbObj.Id, dbObj.Name, ct);
|
||||
EventLogProcessor.DeleteObject(biz.UserId, AyaType.Locale, dbObj.Id, dbObj.Name, ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Delete children / attached objects
|
||||
|
||||
@@ -141,8 +141,11 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
TagBiz biz = new TagBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
//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, AyaType.Tag))
|
||||
if (!Authorized.IsAuthorizedToCreate(HttpContext.Items, TagBiz.BizType))
|
||||
{
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
@@ -152,8 +155,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
TagBiz biz = new TagBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
|
||||
//Create and validate
|
||||
Tag o = await biz.CreateAsync(inObj.Name);
|
||||
@@ -169,7 +171,7 @@ namespace AyaNova.Api.Controllers
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, o.Id, AyaType.Tag, AyaEvent.Created), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, o.Id, AyaType.Tag, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
return CreatedAtAction("GetTag", new { id = o.Id }, new ApiCreatedResponse(o));
|
||||
@@ -222,7 +224,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oFromDb.Id, AyaType.Tag, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oFromDb.Id, AyaType.Tag, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -294,7 +296,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oFromDb.Id, AyaType.Tag, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oFromDb.Id, AyaType.Tag, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -407,7 +409,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
//Log
|
||||
EventLogProcessor.DeleteObject(biz.userId, AyaType.Tag, dbObj.Id, dbObj.Name, ct);
|
||||
EventLogProcessor.DeleteObject(biz.UserId, AyaType.Tag, dbObj.Id, dbObj.Name, ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace AyaNova.Api.Controllers
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, o.Id, AyaType.TagGroup, AyaEvent.Created), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, o.Id, AyaType.TagGroup, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
return CreatedAtAction("GetTagGroup", new { id = o.Id }, new ApiCreatedResponse(o));
|
||||
@@ -257,7 +257,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oFromDb.Id, AyaType.TagGroup, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oFromDb.Id, AyaType.TagGroup, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -329,7 +329,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, oFromDb.Id, AyaType.TagGroup, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, oFromDb.Id, AyaType.TagGroup, AyaEvent.Modified), ct);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
//Log
|
||||
EventLogProcessor.DeleteObject(biz.userId, AyaType.TagGroup, dbObj.Id, dbObj.Name, ct);
|
||||
EventLogProcessor.DeleteObject(biz.UserId, AyaType.TagGroup, dbObj.Id, dbObj.Name, ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
|
||||
@@ -452,8 +452,8 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
//BIZLOG: Not going to log this for now, it's too common an operation and would require bringing in more info. If decide to implement should log the parent object with text of tag instead
|
||||
//and don't forget about import from v7 as well
|
||||
|
||||
return Ok(new ApiOkResponse(l));
|
||||
|
||||
return Ok(new ApiOkResponse(l));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
}
|
||||
|
||||
|
||||
return Ok(new ApiOkResponse(o));
|
||||
}
|
||||
|
||||
@@ -297,6 +297,9 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
UserBiz biz = UserBiz.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, UserBiz.BizType))
|
||||
{
|
||||
@@ -308,8 +311,7 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
|
||||
//Create and validate
|
||||
User o = await biz.CreateAsync(inObj);
|
||||
@@ -354,6 +356,9 @@ namespace AyaNova.Api.Controllers
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
var dbObj = await ct.User.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (dbObj == null)
|
||||
{
|
||||
@@ -365,8 +370,7 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
//Instantiate the business object handler
|
||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
if (!biz.Delete(dbObj))
|
||||
{
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace AyaNova.Api.Controllers
|
||||
try
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, o.Id, AyaType.UserOptions, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, o.Id, AyaType.UserOptions, AyaEvent.Modified), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
@@ -207,7 +207,7 @@ namespace AyaNova.Api.Controllers
|
||||
try
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.userId, o.Id, AyaType.UserOptions, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntryToContextNoSave(new Event(biz.UserId, o.Id, AyaType.UserOptions, AyaEvent.Modified), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user