Ejemplo n.º 1
0
        public async Task TestItemManagerCrud()
        {
            var item = await _bankItems.GetBankItemAsync(new GuildBank(1, "bank") { Id = 1 }, "item");

            Assert.Null(item);

            var bank = await _bank.CreateGuildBankAsync(1, 1, new GuildBank(1, "bank"));

            var i = await _bankItems.CreateBankItemAsync(bank, new GuildBankItem("item") { Description = "d", Value = -0.3, Quantity = -1.6 }, 1);

            item = (await _bankItems.GetBankItemAsync(bank, i.Id)) !;
            Assert.Equal("d", item.Description);

            await _bankItems.UpdateBankItemAsync(bank, i.Id, 1, bankItem => bankItem.Description = "t", 1);

            Assert.Equal("t", item.Description);

            item = (await _bankItems.GetBankItemAsync(bank, 1)) !;
            Assert.Equal("t", item.Description);

            await _bankItems.RemoveBankItemAsync(bank, i.Id, 1);

            item = await _bankItems.GetBankItemAsync(bank, 1);

            Assert.Null(item);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetBankItem(ulong guildId, int bankId, int itemId)
        {
            var bank = await _bank.GetGuildBankAsync(guildId, bankId);

            if (bank == null)
            {
                throw new BankNotFoundException();
            }

            var item = await _items.GetBankItemAsync(bank, itemId);

            if (item == null)
            {
                throw new BankItemNotFoundException();
            }

            return(Content(new ApiGuildBankItem(item)));
        }