Ejemplo n.º 1
0
        // 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));
        }
Ejemplo n.º 2
0
        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());
            }
        }