public async Task savePdFiles(User player, string filesJSON, string targetPlayerId) { var targetChar = Utils.Utils.GetDatabaseCharacter(int.Parse(targetPlayerId)); var dbChar = Utils.Utils.GetDatabaseCharacter(player); NotifyHandler.sendPdNotify($"{dbChar.firstName} {dbChar.lastName} hat die Akte von {targetChar.firstName} {targetChar.lastName} erweitert!", 3000); var files = JsonConvert.DeserializeObject <List <int> >(filesJSON); foreach (var fileID in files) { targetChar.Akten.Add(fileID); } Main.database.CharacterCollection.ReplaceOne(c => c.playerId == targetChar.playerId, targetChar); }
public async Task deletePdFiles(User player, string filesJSON, string targetPlayerId) { var targetChar = Utils.Utils.GetDatabaseCharacter(int.Parse(targetPlayerId)); var dbChar = Utils.Utils.GetDatabaseCharacter(player); var files = JsonConvert.DeserializeObject <List <int> >(filesJSON); foreach (var fileID in files) { if (!targetChar.Akten.Contains(fileID)) { break; } targetChar.Akten.Remove(fileID); } NotifyHandler.sendPdNotify($"{dbChar.firstName} {dbChar.lastName} hat Akten von {targetChar.firstName} {targetChar.lastName} gelöscht!", 3000); Main.database.CharacterCollection.ReplaceOne(c => c.playerId == targetChar.playerId, targetChar); }