/// <summary> /// Withdraws money from an account /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <HttpResponseMessage> Withdraw(CreateDepositWithdrawViewModel model) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri("http://40.76.130.186"); var response = await client.PostAsJsonAsync("api/transaction/withdraw", new { AccountId = model.AccountId, amount = model.Amount }); return(response); } }
public IActionResult Withdraw(int id) { if (HttpContext.Session.GetString("IsEmployee") == null) { return(RedirectToAction("Login", "Authentication")); } else { CreateDepositWithdrawViewModel model = new CreateDepositWithdrawViewModel() { AccountId = id }; return(View(model)); } }
public async Task <IActionResult> Deposit(CreateDepositWithdrawViewModel model) { if (!ModelState.IsValid) { return(View(model)); } TransactionStatusViewModel transactionStatus = new TransactionStatusViewModel(); try { var response = await _transactionProvider.Deposit(model); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var jsoncontent = await response.Content.ReadAsStringAsync(); transactionStatus = JsonConvert.DeserializeObject <TransactionStatusViewModel>(jsoncontent); return(View("TransactionStatus", transactionStatus)); } else if (response.StatusCode == System.Net.HttpStatusCode.NotFound) { ModelState.AddModelError("", "Having server issue while adding record"); return(View(model)); } else if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { ViewBag.Message = "Internal Server Error! Please try again later"; return(View(model)); } } catch (Exception ex) { _logger.Error("Exceptions Occured as " + ex.Message); } ModelState.AddModelError("", "Having some unexpected error while processing transaction"); return(View(model)); }