Task <Item> IRepository.ModifyItem(Guid playerId, Guid itemId, ModifiedItem item) { if (Items.ContainsKey(playerId)) { if (Items[playerId].ContainsKey(itemId)) { Items[playerId][itemId].Type = item.Type; return(Task.FromResult(Items[playerId][itemId])); } } return(Task.FromResult((Item)null)); }
public async Task <Item> ModifyItem(Guid playerId, Guid itemId, ModifiedItem modifiedItem) { Item[] items = await GetAllItems(playerId); foreach (Item item in items) { if (item.Id == itemId) { item.Type = modifiedItem.Type; FilterDefinition <Player> filter = Builders <Player> .Filter.Eq("_id", playerId); var update = Builders <Player> .Update.Set("Items", items.ToList()); await collection.FindOneAndUpdateAsync(filter, update); return(item); } } return(null); }
public Task <Item> Modify(Guid playerId, Guid itemId, ModifiedItem item) { return(_repository.ModifyItem(playerId, itemId, item)); }