// GET: Thana/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thana thana = _thanaManager.GetById((int)id); EditThanaViewModel thanaVM = new EditThanaViewModel() { Id = thana.Id, Name = thana.Name, DistrictId = thana.DistrictId }; ViewBag.DistrictId = new SelectList(_districtManager.GetAll(), "Id", "Name", thana.DistrictId); return(View(thanaVM)); }
public ActionResult Edit(EditThanaViewModel thanaViewModel) { try { Thana thana = new Thana(); thana.Id = thanaViewModel.Id; thana.Name = thanaViewModel.Name; thana.DistrictId = thanaViewModel.DistrictId; _thanaManager.Update(thana); return(RedirectToAction("Index")); } catch { return(View()); } }