// GET: /<controller>/ public IActionResult Index() { HttpContext.Session.SetString(SessionKeyEdit, ""); if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); return(View()); } else { IEnumerable <GetUserBankOutputModel> accounts = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Profile/"); GetUserBankInputModel filter = new GetUserBankInputModel(); filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID).ToString()); var responseTask = client.PostAsJsonAsync <GetUserBankInputModel>("GetUserBankAccount", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); GetUserBankResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <GetUserBankResponseModel>(content.Result); accounts = resutl.data; } else //web api sent error response { //log response status here.. accounts = Enumerable.Empty <GetUserBankOutputModel>(); ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(View(accounts)); } } else { TempData["CustomError"] = "Silakan masuk sebelum menggunakan situs 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("OwnerLogon", "Login"); //} return(RedirectToAction("Logon", "Login")); } }
public ActionResult Update(string id) { if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { HttpContext.Session.SetString(SessionKeyEdit, id); var ID = Guid.Parse(id); IEnumerable <GetUserBankOutputModel> accounts = null; EditBankAccount data = new EditBankAccount(); if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); } else { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Profile/"); GetUserBankInputModel filter = new GetUserBankInputModel(); filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID).ToString()); var responseTask = client.PostAsJsonAsync <GetUserBankInputModel>("GetUserBankAccount", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); GetUserBankResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <GetUserBankResponseModel>(content.Result); accounts = resutl.data; data.item = accounts.Where(x => x.UserBankID == ID).First(); } else //web api sent error response { ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } } } return(View(data)); } 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 List <GetUserBankOutputModel> GetUserBankAccount(GetUserBankInputModel data) { var query = (from b in DbContext.Bank join ub in DbContext.UserBank on b.ID equals ub.BankID join u in DbContext.User on ub.UserID equals u.ID where ub.UserID == data.UserID && ub.DeletedDate == null select new GetUserBankOutputModel() { AccountNumber = ub.AccountNumber, BankID = b.ID, BankName = b.BankName, UserBankID = ub.ID, AccountName = ub.AccountName }); return(query.ToList()); }
public ActionResult <GetUserBankResponseModel> GetBank([FromBody] GetUserBankInputModel data) { GetUserBankResponseModel res = new GetUserBankResponseModel(); try { BankBL posBL = new BankBL(DbContext); var result = posBL.GetUserBankAccount(data); res.data = result; res.Message = "Success"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }