Exemple #1
0
        public async Task <EmptyResponse <StoreServiceResponseCode> > BuyItemAsync(int magicItemId, int accountId)
        {
            var item = (await repo.GetMagicItemsAsync(new List <int> {
                magicItemId
            }))?.FirstOrDefault();

            if (item == null)
            {
                return(StoreServiceResponseCode.ItemDoesNotExist);
            }

            if (item?.Quantity == 0)
            {
                return(StoreServiceResponseCode.NoStockAvailable);
            }

            await repo.BuyItemAsync(item, 1);

            // TODO: Allocate item to account...

            return(StoreServiceResponseCode.Success);
        }