public async Task <int> ClearOldDataAsync(DateTime before, SocketGuild guild) { var oldData = await GrillBotRepository.AuditLogs.GetAuditLogsBeforeDate(before, guild.Id).ToListAsync(); foreach (var item in oldData.Where(o => o.Files.Count > 0)) { GrillBotRepository.RemoveCollection(item.Files); } GrillBotRepository.RemoveCollection(oldData); await GrillBotRepository.CommitAsync(); return(oldData.Count); }
public async Task DeleteItemAsync(long id) { var item = await GrillBotRepository.AuditLogs.FindItemByIdAsync(id); if (item == null) { return; } if (item.Files.Count > 0) { GrillBotRepository.RemoveCollection(item.Files); } GrillBotRepository.Remove(item); await GrillBotRepository.CommitAsync(); }