public ActionResult GetThanhphoByTinh(string matinh) { List <Thanhpho> thanhphos = new List <Thanhpho>(); if (!string.IsNullOrWhiteSpace(matinh)) { thanhphos = _thanhphoRepository.ListThanhphoByTinh(matinh).ToList(); if (thanhphos.Count() == 0) { var empty = new Thanhpho { Matp = "", Tentp = "Không có thông tin" }; thanhphos.Insert(0, empty); } else { var empty = new Thanhpho { Matp = "", Tentp = "-- Chọn thông tin --" }; thanhphos.Insert(0, empty); } } return(Json(thanhphos)); }
public ActionResult ThemThanhpho(string matinh) { var thanhpho = new Thanhpho(); thanhpho.Matp = _thanhphoRepository.newMatp(matinh); thanhpho.Matinh = matinh; return(PartialView(thanhpho)); }
public void listThanhphoByTinh(string matinh, string selected) { List <Thanhpho> thanhpho = _thanhphoRepository.ListThanhphoByTinh(matinh).ToList(); var empty = new Thanhpho { Matp = "", Tentp = "-- Chọn thông tin --" }; thanhpho.Insert(0, empty); ViewBag.thanhpho = new SelectList(thanhpho, "Matp", "Tentp", selected); }
public ActionResult ThemThanhpho(Thanhpho thanhpho) { int result = _thanhphoRepository.themThanhpho(thanhpho); return(Json(JsonConvert.SerializeObject(result))); }