This commit is contained in:
@@ -14,7 +14,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("EventLogProcessor");
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Add an entry to the log
|
||||
/// </summary>
|
||||
/// <param name="newEvent"></param>
|
||||
@@ -23,7 +23,24 @@ namespace AyaNova.Biz
|
||||
internal static void AddEntry(Event newEvent, AyContext ct)
|
||||
{
|
||||
ct.Event.Add(newEvent);
|
||||
ct.SaveChanges();
|
||||
ct.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handle delete
|
||||
/// remove all prior entries for object, add one deleted entry
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="ayType"></param>
|
||||
/// <param name="ayId"></param>
|
||||
/// <param name="textra"></param>
|
||||
/// <param name="ct"></param>
|
||||
internal static void DeleteObject(long userId, AyaType ayType, long ayId, string textra, AyContext ct)
|
||||
{
|
||||
ct.Database.ExecuteSqlCommand("delete from aevent where aytype = {0} and ayid={1}", new object[] { (int)ayType }, new object[] { ayId });
|
||||
ct.Event.Add(new Event(userId, ayId, ayType, AyaEvent.Deleted, textra));
|
||||
ct.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace AyaNova.Biz
|
||||
internal class WidgetBiz : BizObject, IJobObject
|
||||
{
|
||||
private readonly AyContext ct;
|
||||
private readonly long userId;
|
||||
public readonly long userId;
|
||||
private readonly AuthorizationRoles userRoles;
|
||||
|
||||
|
||||
@@ -38,43 +38,13 @@ namespace AyaNova.Biz
|
||||
return null;
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
using (var trans = ct.Database.BeginTransaction())
|
||||
{
|
||||
// try
|
||||
// {
|
||||
//do stuff with widget
|
||||
Widget outObj = inObj;
|
||||
outObj.OwnerId = userId;
|
||||
//SearchHelper(break down text fields, save to db)
|
||||
//TagHelper(collection of tags??)
|
||||
await ct.Widget.AddAsync(outObj);
|
||||
|
||||
//Log creation
|
||||
Event ev = new Event();
|
||||
ev.AyEvent = AyaEvent.Created;
|
||||
ev.AyId = outObj.Id;
|
||||
ev.AyType = AyaType.Widget;
|
||||
ev.OwnerId = outObj.OwnerId;
|
||||
await ct.Event.AddAsync(ev);
|
||||
|
||||
|
||||
// Commit transaction if all commands succeed, transaction will auto-rollback
|
||||
// when disposed if either commands fails
|
||||
trans.Commit();
|
||||
|
||||
return outObj;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw ex;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//do stuff with widget
|
||||
Widget outObj = inObj;
|
||||
outObj.OwnerId = userId;
|
||||
//SearchHelper(break down text fields, save to db)
|
||||
//TagHelper(collection of tags??)
|
||||
await ct.Widget.AddAsync(outObj);
|
||||
return outObj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user