public async Task <Player> ModifyInventory(Guid id, ModifiedPlayerInventory player) { var filter = Builders <Player> .Filter.Eq("Id", id); Player _player = await Get(id); _player.Items = player.Items; await _collection.ReplaceOneAsync(filter, _player); return(_player); }
public async Task <Item> CreateItem(Guid playerId, Item item) { Player _p = await Get(playerId); _p.Items.Add(item); ModifiedPlayerInventory _modP = new ModifiedPlayerInventory(); _modP.Items = _p.Items; await ModifyInventory(_p.Id, _modP); return(item); }
public async Task <Item> DeleteItem(Guid playerId, Guid itemId) { Player _p = await Get(playerId); for (int i = 0; i < _p.Items.Count; i++) { if (_p.Items[i].Id == itemId) { _p.Items.Remove(_p.Items[i]); ModifiedPlayerInventory _modP = new ModifiedPlayerInventory(); _modP.Items = _p.Items; await ModifyInventory(playerId, _modP); return(_p.Items[i]); } } throw new System.ArgumentException("Unable to find given ID."); }
Task <Player> IRepository.ModifyInventory(Guid id, ModifiedPlayerInventory player) { throw new NotImplementedException("nope"); }