public async Task <ActionResult <decimal> > GetTrolleyTotalWithoutWooliesApi([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "answers2/trolleyTotal")]
                                                                                     HttpRequest req, ILogger log)
        {
            var requestBody    = await new StreamReader(req.Body).ReadToEndAsync();
            var trolleyRequest = JsonConvert.DeserializeObject <TrolleyRequest>(requestBody);

            var trolleyTotal = _trolleyService.CalculateTrolleyTotal(trolleyRequest.Products,
                                                                     trolleyRequest.Specials, trolleyRequest.Quantities);

            return(trolleyTotal);
        }
        public async Task <IActionResult> GetTrolleyTotal([FromBody] TrolleyRequest trolleyRequest)
        {
            var validationResult = new TrolleyRequestValidator().Validate(trolleyRequest);

            if (!validationResult.IsValid)
            {
                var errors = validationResult.Errors.Select(e => e.ErrorMessage).ToList();
                return(BadRequest(errors));
            }

            try
            {
                _logger.LogInformation("GetTrolleyTotal Requested:", trolleyRequest);

                var trolleyTotal = await _trolleyService.CalculateTrolleyTotal(trolleyRequest);

                return(Ok(trolleyTotal));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "An error has occured while calculating trolley total.");
                throw;
            }
        }
 public IActionResult Post([FromBody] JToken request)
 {
     return(Ok(_trolleyService.CalculateTrolleyTotal(request)));
 }