public ActionResult <ProvinceResponseModel> GetProvince() { ProvinceResponseModel res = new ProvinceResponseModel(); try { ProvinceRepository repo = new ProvinceRepository(db); var query = repo.GetAll(); var res2 = (from y in query select new ProviceOutputModel { ProvinceID = y.ID, Kode = y.Kode, Provinsi = y.Provinsi }).OrderBy(x => x.Provinsi).ToList(); res.data = res2; res.Message = "Success get data"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }
public IActionResult GetProvince() { List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); HttpContext.Session.SetString(SessionKeyCity, client.BaseAddress.ToString()); var provTask = client.PostAsync("GetProvince", null); provTask.Wait(); var results = provTask.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Provinsi).ToList(); } else { province = null; ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(Json(province)); }
public IActionResult Index() { List <BillboardTypeListOutputModel> billboardtype = new List <BillboardTypeListOutputModel>(); List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); LandingPageModel model = new LandingPageModel(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); var typeTank = client.GetAsync("GetBillboardType"); typeTank.Wait(); var results = typeTank.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); BillboardTypeListResponseModel billboardtypeResponse = JsonConvert.DeserializeObject <BillboardTypeListResponseModel>(content.Result); billboardtype = billboardtypeResponse.data.OrderBy(x => x.Kode).ToList(); model.BillBoardType = new List <BillboardTypeListOutputModel>(); model.BillBoardType = billboardtype; typeTank = client.PostAsync("GetProvince", null); typeTank.Wait(); results = typeTank.Result; if (results.IsSuccessStatusCode) { content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Provinsi).ToList(); model.Province = new List <ProvinceOutputModel>(); model.Province = province; HttpContext.Session.SetString(Loginfrom, "MDB"); } else { province = null; ModelState.AddModelError(string.Empty, "Terjadi kesalahan server. Hubungi admin."); } } else { billboardtype = null; ModelState.AddModelError(string.Empty, "Terjadi kesalahan server. Hubungi admin."); } } } catch (Exception e) { ModelState.AddModelError(string.Empty, "Terjadi kesalahan server. Hubungi admin."); } return(View(model)); }
// GET: /<controller>/ public IActionResult Index() { HttpContext.Session.SetString(SessionKeyEdit, ""); if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); } else { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); var provTask = client.PostAsync("GetProvince", null); provTask.Wait(); var results = provTask.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Kode).ToList(); } else { province = null; ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } } } return(View(province)); } 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"); } }
// GET: /<controller>/ public IActionResult Index() { HttpContext.Session.SetString(SessionKeyEdit, ""); if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); if (TempData["CustomError"] != null) { ModelState.AddModelError(string.Empty, TempData["CustomError"].ToString()); } else { using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); var provTask = client.PostAsync("GetProvince", null); provTask.Wait(); var results = provTask.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Kode).ToList(); } else { province = null; ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } } return(View(province)); } 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 JsonResult GetProvince(DataTableAjaxPostModel model) { int filteredResultsCount = 0; int totalResultsCount = 0; List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); var provTask = client.PostAsync("GetProvince", null); provTask.Wait(); var results = provTask.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Kode).ToList(); } else { province = null; ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } } var result = new List <JsonProvince>(); foreach (var x in province) { result.Add(new JsonProvince { ProvinceID = x.ProvinceID, kode = x.Kode.ToString(), provinsi = x.Provinsi }); } totalResultsCount = result.Count(); return(Json(new { draw = model.draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, data = result })); }
public IActionResult GetProvince() { List <ProvinceOutputModel> province = new List <ProvinceOutputModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Base/"); var provTask = client.PostAsync("GetProvince", null); provTask.Wait(); var results = provTask.Result; if (results.IsSuccessStatusCode) { var content = results.Content.ReadAsStringAsync(); ProvinceResponseModel provinceResponse = JsonConvert.DeserializeObject <ProvinceResponseModel>(content.Result); province = provinceResponse.data.OrderBy(x => x.Provinsi).ToList(); } else { province = null; ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } } return(Json(province)); }