This commit is contained in:
@@ -64,8 +64,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
var result = await EventLogProcessor.GetLogForObjectAsync(opt, ct);
|
var ret = await EventLogProcessor.GetLogForObjectAsync(opt, ct);
|
||||||
return Ok(ApiOkResponse.Response(result, true));
|
return Ok(ApiOkResponse.Response(ret, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -94,9 +94,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await EventLogProcessor.GetLogForUserAsync(opt, ct);
|
var ret = await EventLogProcessor.GetLogForUserAsync(opt, ct);
|
||||||
|
return Ok(ApiOkResponse.Response(ret, true));
|
||||||
return Ok(ApiOkResponse.Response(result, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,6 +127,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
public int? Limit { get; set; }
|
public int? Limit { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class ObjectEventLog
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public ObjectEventLogItem[] Events { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class ObjectEventLogItem
|
public sealed class ObjectEventLogItem
|
||||||
{
|
{
|
||||||
//DateTime, UserId, Event, Textra
|
//DateTime, UserId, Event, Textra
|
||||||
@@ -138,6 +143,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
public string Textra { get; set; }
|
public string Textra { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class UserEventLog
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public UserEventLogItem[] Events { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class UserEventLogItem
|
public sealed class UserEventLogItem
|
||||||
{
|
{
|
||||||
//DateTime, ObjectType, ObjectId, Event, Textra
|
//DateTime, ObjectType, ObjectId, Event, Textra
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ namespace AyaNova.Biz
|
|||||||
/// Get the event log for a specified object
|
/// Get the event log for a specified object
|
||||||
/// Presentation is the client's responsibility (localization internationalization etc)
|
/// Presentation is the client's responsibility (localization internationalization etc)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.ObjectEventLogItem[]> GetLogForObjectAsync(AyaNova.Api.Controllers.EventLogController.EventLogOptions opt, AyContext ct)
|
internal static async Task<AyaNova.Api.Controllers.EventLogController.ObjectEventLog> GetLogForObjectAsync(AyaNova.Api.Controllers.EventLogController.EventLogOptions opt, AyContext ct)
|
||||||
{
|
{
|
||||||
//This is also an example of conditional where statements
|
AyaNova.Api.Controllers.EventLogController.ObjectEventLog ret = new Api.Controllers.EventLogController.ObjectEventLog();
|
||||||
|
|
||||||
//Set up the query
|
//Set up the query
|
||||||
var q = ct.Event.Select(m => m).AsNoTracking();
|
var q = ct.Event.Select(m => m).AsNoTracking();
|
||||||
@@ -64,7 +64,7 @@ namespace AyaNova.Biz
|
|||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
ct.Database.OpenConnection();
|
ct.Database.OpenConnection();
|
||||||
var ret = EventItems.Select(m => new AyaNova.Api.Controllers.EventLogController.ObjectEventLogItem()
|
ret.Events = EventItems.Select(m => new AyaNova.Api.Controllers.EventLogController.ObjectEventLogItem()
|
||||||
{
|
{
|
||||||
Date = m.Created,
|
Date = m.Created,
|
||||||
UserId = m.UserId,
|
UserId = m.UserId,
|
||||||
@@ -73,6 +73,7 @@ namespace AyaNova.Biz
|
|||||||
Name = BizObjectNameFetcherDirect.Name(AyaType.User, m.UserId, command)
|
Name = BizObjectNameFetcherDirect.Name(AyaType.User, m.UserId, command)
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
|
ret.Name = BizObjectNameFetcherDirect.Name(opt.AyType, opt.AyId, command);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +84,11 @@ namespace AyaNova.Biz
|
|||||||
/// Get the event log for a specified User
|
/// Get the event log for a specified User
|
||||||
/// Presentation is the client's responsibility (localization internationalization etc)
|
/// Presentation is the client's responsibility (localization internationalization etc)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLogItem[]> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.UserEventLogOptions opt, AyContext ct)
|
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLog> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.UserEventLogOptions opt, AyContext ct)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
AyaNova.Api.Controllers.EventLogController.UserEventLog ret = new Api.Controllers.EventLogController.UserEventLog();
|
||||||
|
|
||||||
//Set up the query
|
//Set up the query
|
||||||
var q = ct.Event.Select(m => m);
|
var q = ct.Event.Select(m => m);
|
||||||
|
|
||||||
@@ -100,7 +104,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
ct.Database.OpenConnection();
|
ct.Database.OpenConnection();
|
||||||
//convert the Event array to the correct return type array
|
//convert the Event array to the correct return type array
|
||||||
var ret = EventItems.Select(m => new AyaNova.Api.Controllers.EventLogController.UserEventLogItem()
|
ret.Events = EventItems.Select(m => new AyaNova.Api.Controllers.EventLogController.UserEventLogItem()
|
||||||
{
|
{
|
||||||
|
|
||||||
Date = m.Created,
|
Date = m.Created,
|
||||||
@@ -111,6 +115,7 @@ namespace AyaNova.Biz
|
|||||||
Name = BizObjectNameFetcherDirect.Name(m.AyType, m.AyId, command)
|
Name = BizObjectNameFetcherDirect.Name(m.AyType, m.AyId, command)
|
||||||
|
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
ret.Name = BizObjectNameFetcherDirect.Name(AyaType.User, opt.UserId, command);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user