public IActionResult GetAuditLogsList() { var auditLogsJson = new List <AuditLogJson>(); var auditLogs = _auditService.GetAllAuditLogsForDepartment(DepartmentId); var department = _departmentsService.GetDepartmentById(DepartmentId, false); foreach (var auditLog in auditLogs) { var auditJson = new AuditLogJson(); auditJson.AuditLogId = auditLog.AuditLogId; //auditJson.Name = UserHelper.GetFullNameForUser(null, auditLog.UserId); auditJson.Message = auditLog.Message; if (auditLog.LoggedOn.HasValue) { auditJson.Timestamp = auditLog.LoggedOn.Value.TimeConverterToString(department); } else { auditJson.Timestamp = "Unknown"; } auditJson.Type = _auditService.GetAuditLogTypeString((AuditLogTypes)auditLog.LogType); auditLogsJson.Add(auditJson); } return(Json(auditLogsJson)); }
// Audit logs public static IAsyncEnumerable <IReadOnlyCollection <RestAuditLogEntry> > GetAuditLogsAsync(IGuild guild, BaseDiscordClient client, ulong?from, int?limit, RequestOptions options, ulong?userId = null, ActionType?actionType = null) { return(new PagedAsyncEnumerable <RestAuditLogEntry>( DiscordConfig.MaxAuditLogEntriesPerBatch, async(info, ct) => { GetAuditLogsParams args = new GetAuditLogsParams { Limit = info.PageSize }; if (info.Position != null) { args.BeforeEntryId = info.Position.Value; } if (userId.HasValue) { args.UserId = userId.Value; } if (actionType.HasValue) { args.ActionType = (int)actionType.Value; } AuditLogJson model = await client.ApiClient.GetAuditLogsAsync(guild.Id, args, options); return model.Entries.Select((x) => RestAuditLogEntry.Create(client, model, x)).ToImmutableArray(); }, nextPage: (info, lastPage) => { if (lastPage.Count != DiscordConfig.MaxAuditLogEntriesPerBatch) { return false; } info.Position = lastPage.Min(x => x.Id); return true; }, start: from, count: limit )); }