public async Task Then_the_request_is_forwarded_to_the_client() { // Arrange var withdrawRequest = _fixture.Build <WithdrawRequest>().With(r => r.WithdrawalType, WithdrawalType.Employer).Create(); // Act await _sut.Withdraw(withdrawRequest); // Assert _testClient.VerifyPostAsAsync($"withdrawals", withdrawRequest, Times.Once()); }
public async Task <ActionResult> Withdraw(decimal amountToWithdraw, string accountNumber) { try { var withdrawalService = new WithdrawalService(); var result = await withdrawalService.Withdraw(amountToWithdraw, accountNumber, User.Identity.Name); if (result) { return(Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, responseText = "ewan ko ba" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { success = false, responseText = ex.Message }, JsonRequestBehavior.AllowGet)); } }