public IActionResult Edit(int id) { ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); var objcategory = _unitofWork.city.Get(id); if (objcategory == null) { return(NotFound()); } var model = new CityRegistrationCreateViewModel() { id = objcategory.id, countryid = _unitofWork.state.Get(objcategory.stateid).countryid, stateid = objcategory.stateid, cityName = objcategory.cityName }; ViewBag.States = _unitofWork.state.GetAll().Where(x => x.isdeleted == false && x.countryid == model.countryid).Select(x => new SelectListItem() { Text = x.StateName, Value = x.id.ToString() }); return(View(model)); }
public async Task <IActionResult> Create(CityRegistrationCreateViewModel model) { if (ModelState.IsValid) { var objcategory = new CityRegistration { id = model.id , stateid = model.stateid , cityName = model.cityName , isdeleted = false , isactive = false }; _unitofWork.city.Add(objcategory); bool res = _unitofWork.Save(); TempData["success"] = "Record Save successfully"; return(RedirectToAction(nameof(Index))); } else { ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); return(View(model)); } }
public async Task <IActionResult> Edit(CityRegistrationCreateViewModel model) { if (ModelState.IsValid) { var storeobj = _unitofWork.city.Get(model.id); if (storeobj == null) { TempData["error"] = "Record Not Found"; return(NotFound()); } storeobj.id = model.id; storeobj.stateid = model.stateid; storeobj.cityName = model.cityName; _unitofWork.city.Update(storeobj); bool res = _unitofWork.Save(); TempData["success"] = "Record Update successfully"; return(RedirectToAction(nameof(Index))); } else { ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); return(View(model)); } }
public IActionResult Create() { ViewBag.Allcountry = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); var model = new CityRegistrationCreateViewModel(); return(View(model)); }