This commit is contained in:
@@ -76,15 +76,11 @@ namespace AyaNova.Api.Controllers
|
||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
var o = await biz.GetAsync(id);
|
||||
|
||||
if (o == null)
|
||||
{
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(biz.UserId, o.Id, UserBiz.BizType, AyaEvent.Retrieved), ct);
|
||||
ct.SaveChanges();
|
||||
|
||||
return Ok(new ApiOkResponse(o));
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,7 @@ namespace AyaNova.Api.Controllers
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, WidgetBiz.BizType, AyaEvent.Retrieved), ct);
|
||||
ct.SaveChanges();
|
||||
|
||||
return Ok(new ApiOkResponse(o));
|
||||
}
|
||||
|
||||
@@ -209,7 +207,7 @@ namespace AyaNova.Api.Controllers
|
||||
try
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, WidgetBiz.BizType, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntry(new Event(biz.UserId, o.Id, WidgetBiz.BizType, AyaEvent.Modified), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
Search.ProcessUpdatedObjectKeywords(ct, UserLocaleIdFromContext.Id(HttpContext.Items), o.Id, WidgetBiz.BizType, o.Name, o.Notes, o.Name);
|
||||
}
|
||||
@@ -286,7 +284,7 @@ namespace AyaNova.Api.Controllers
|
||||
try
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, WidgetBiz.BizType, AyaEvent.Modified), ct);
|
||||
EventLogProcessor.AddEntry(new Event(biz.UserId, o.Id, WidgetBiz.BizType, AyaEvent.Modified), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//this will save the context as part of it's operations
|
||||
@@ -354,7 +352,7 @@ namespace AyaNova.Api.Controllers
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log now that we have the Id
|
||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, WidgetBiz.BizType, AyaEvent.Created), ct);
|
||||
EventLogProcessor.AddEntry(new Event(biz.UserId, o.Id, WidgetBiz.BizType, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//this will save the context as part of it's operations
|
||||
@@ -412,7 +410,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
//Log
|
||||
EventLogProcessor.DeleteObject(biz.userId, WidgetBiz.BizType, dbObj.Id, dbObj.Name, ct);
|
||||
EventLogProcessor.DeleteObject(biz.UserId, WidgetBiz.BizType, dbObj.Id, dbObj.Name, ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//This will directly execute and is not part of context for saving purposes
|
||||
|
||||
@@ -100,7 +100,14 @@ namespace AyaNova.Biz
|
||||
internal async Task<User> GetAsync(long fetchId)
|
||||
{
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
return await ct.User.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
var ret = await ct.User.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
if (ret != null)
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//get many (paged)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public static AyaType BizType = AyaType.Widget;
|
||||
private readonly AyContext ct;
|
||||
public readonly long userId;
|
||||
public readonly long UserId;
|
||||
public readonly long UserLocaleId;
|
||||
private readonly AuthorizationRoles userRoles;
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace AyaNova.Biz
|
||||
internal WidgetBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
|
||||
{
|
||||
ct = dbcontext;
|
||||
userId = currentUserId;
|
||||
UserId = currentUserId;
|
||||
UserLocaleId = userLocaleId;
|
||||
userRoles = UserRoles;
|
||||
}
|
||||
|
||||
@@ -52,10 +53,24 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//do stuff with widget
|
||||
Widget outObj = inObj;
|
||||
outObj.OwnerId = userId;
|
||||
outObj.OwnerId = UserId;
|
||||
|
||||
|
||||
//TagHelper(collection of tags??)
|
||||
await ct.Widget.AddAsync(outObj);
|
||||
|
||||
//save to get Id
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Handle child and associated items
|
||||
|
||||
//Log event
|
||||
EventLogProcessor.AddEntry(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//SEARCH INDEXING
|
||||
Search.ProcessNewObjectKeywords(ct, UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Notes, outObj.Name);
|
||||
HERE
|
||||
|
||||
return outObj;
|
||||
|
||||
}
|
||||
@@ -67,8 +82,15 @@ namespace AyaNova.Biz
|
||||
//Get one
|
||||
internal async Task<Widget> GetAsync(long fetchId)
|
||||
{
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
return await ct.Widget.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
var ret = await ct.Widget.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
if (ret != null)
|
||||
{
|
||||
//Log
|
||||
EventLogProcessor.AddEntry(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//get many (paged)
|
||||
|
||||
Reference in New Issue
Block a user