public async Task <Item> ModifyItem(Guid playerId, Guid itemid, ModifiedItem item) { Player player = await this.GetPlayer(playerId); Item newItem = new Item(); newItem.Level = item.Level; newItem.Type = item.Type; Item[] itemList = player.Items.ToArray(); for (int i = 0; i < itemList.Count(); i++) { if (itemList[i].id == itemid) { newItem.id = itemList[i].id; newItem.CreationTime = itemList[i].CreationTime; itemList[i] = newItem; } } player.Items = itemList.ToList(); await _collection.ReplaceOneAsync(Builders <Player> .Filter.Eq("Id", playerId), player); return(newItem); }
public Task <Item> ModifyItem(Guid id, Guid itemID, ModifiedItem item) { foreach (var player in playerList) { if (player.Id == id) { foreach (var item1 in player.Items) { if (item1.id == itemID) { item1.Level = item.Level; item1.Type = item.Type; return(Task.FromResult(item1)); } } } } return(Task.FromResult((Item)null)); }
public Task <Item> ModifyItem(Guid id, Guid itemID, [FromBody] ModifiedItem item) { return(IP.ModifyItem(id, itemID, item)); }