Exemple #1
0
        public async Task <IActionResult> Purchase([FromBody] OrderModel order)
        {
            var coins      = order.Coins.Select(x => new KeyValuePair <decimal, int>(x.Value, x.Count)).ToDictionary(x => x.Key, x => x.Value);
            var returnings = new Dictionary <decimal, int>();
            var succeed    = await service.PurchaseAsync(order.ProductId, coins, returnings);

            return(Ok(new
            {
                Message = succeed ? "Thank you" : "Insufficient amount",
                Coins = returnings.Select(x => new CoinModel()
                {
                    Value = x.Key, Count = x.Value
                })
            }));
        }