public ActionResult CreateEdit(CityViewModel model) { try { if (ModelState.IsValid) { if (CityDataAccess.Update(model)) { return(Json(new { success = true, message = "success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { succes = false, message = CityDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Please full fill required fields" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(int id) { CustomerViewModel model = CustomerDataAccess.GetById(id); ViewBag.ProvinceList = new SelectList(ProvinceDataAccess.GetAll(), "Code", "Name"); ViewBag.CityList = new SelectList(CityDataAccess.GetByProvince(model.Province_Code), "Code", "Name"); return(View(model)); }
public ActionResult NewSupplier() { ViewBag.ProvinceList = new SelectList(ProvinceDataAccess.GetAll(), "Code", "Name"); ViewBag.CityList = new SelectList(CityDataAccess.GetByProvince(""), "Code", "Name"); SupplierViewModel model = new SupplierViewModel(); return(PartialView("_SupplierForm", model)); }
public void DeleteCity(DeleteCityRequest request) { if (request != null) { var dataAccess = new CityDataAccess(request.Context); var city = dataAccess.GetById(request.IdCity); dataAccess.Delete(city.FirstOrDefault()); } }
public ActionResult DeleteConfirm(int id) { if (CityDataAccess.Delete(id)) { return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = CityDataAccess.Message }, JsonRequestBehavior.AllowGet)); } }
public City UpdateCity(UpdateCityRequest request) { City city = null; if (request != null && request.City != null) { var dataAccess = new CityDataAccess(request.Context); city = dataAccess.Update(request.City); } return(city); }
public City GetCityById(GetCityByIdRequest request) { City city = null; if (request != null) { var dataAccess = new CityDataAccess(request.Context); var cityQuery = dataAccess.GetById(request.IdCity); cityQuery = cityQuery.Include(c => c.State); city = cityQuery.FirstOrDefault(); } return(city); }
public List <City> GetAllCities(GetAllCitiesRequest request) { List <City> cities = null; if (request != null) { var dataAccess = new CityDataAccess(request.Context); var citiesQuery = dataAccess.GetAll(); citiesQuery = citiesQuery.Include(c => c.State); cities = citiesQuery.ToList(); } return(cities); }
public ActionResult Create() { ViewBag.ProvinceList = new SelectList(ProvinceDataAccess.GetAll(), "Code", "Name"); ViewBag.CityList = new SelectList(CityDataAccess.GetByProvince(""), "Code", "Name"); return(View()); }
public ActionResult GetByProvince(string provinceCode) // get from CityDataAccess { return(View(CityDataAccess.GetByProvince(provinceCode))); }
public ActionResult Delete(int id) { return(View(CityDataAccess.GetById(id))); }
public ActionResult Edit(int id) { ViewBag.ProvinceList = new SelectList(ProvinceDataAccess.GetAll(), "Code", "Name"); return(View(CityDataAccess.GetById(id))); }
public ActionResult List() { return(View(CityDataAccess.GetAll())); }