public ActionResult Update(string id) { if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { var ID = Guid.Parse(id); InfoBankDetailModel bank = new InfoBankDetailModel(); if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); } else { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Bank/"); //HTTP POST var postTask = client.GetAsync("GetBank?BankID=" + ID); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); InfoBankResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <InfoBankResponseModel>(content.Result); bank = resutl.data; } else //web api sent error response { //log response status here.. bank = null; TempData["CustomError"] = "Server Error. Please contact administrator."; } } } return(View(bank)); } else { TempData["CustomError"] = "Please login before using the web."; if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV") { return(RedirectToAction("AdminLogon", "Login")); } else if (HttpContext.Session.GetString(Loginfrom) == "MDO") { return(RedirectToAction("OwnerLogon", "Login")); } else { return(RedirectToAction("BuyerLogon", "Login")); } //return RedirectToAction("Logon", "Login"); } }
public ActionResult <InfoBankResponseModel> GetBank(Guid BankID) { InfoBankResponseModel res = new InfoBankResponseModel(); try { BankBL posBL = new BankBL(DbContext); var data = posBL.GetDetailBank(BankID); res.data = data; res.Message = "Success"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }