public Task <ActionResult <GiftAidResponse> > GetGiftAid([FromQuery] GiftAidRequest model, CancellationToken cancellation) { if (!ModelState.IsValid) { var error = BuildErrorMessage(); return(Task.FromResult <ActionResult <GiftAidResponse> >(BadRequest(error))); } cancellation.ThrowIfCancellationRequested(); var giftAid = _calculator.Calculate(model.Amount); var result = new GiftAidResponse(model.Amount, giftAid); return(Task.FromResult <ActionResult <GiftAidResponse> >(Ok(result))); }
public IActionResult GetGiftAidAmount([FromQuery] GiftAidRequest request) { var validationResult = ValidateOperation(request.Amount); if (validationResult.StatusCode != 200) { return(validationResult); } var response = new GiftAidResponse { DonationAmount = Math.Round(request.Amount, 2), GiftAidAmount = _giftAidCalculator.CalculateGiftAid(request.Amount) }; return(Ok(response)); }