예제 #1
0
        public async Task <IActionResult> GetCostByName(string name, string customerType)
        {
            if (customerType != "c" || customerType != "d")
            {
                return(StatusCode(400)); //Could be a 422 as well
            }

            var result = await _discountEngine.Apply(name, customerType);

            if (!result.Success)
            {
                return(StatusCode(500)); // Todo: Add more response codes depending on actual fault
            }

            return(await Task.FromResult(Ok()));
        }
예제 #2
0
        private async Task RecalculateTotal(ShoppingCart cart)
        {
            await _discountEngine.Apply(cart);

            await ApplyChanges(cart);
        }