public ActionResult Create(Select2DropdownVM vm) { try { var id = vms.OrderByDescending(i => i.Id).Select(i => i.Id).FirstOrDefault(); vm.Id = ++id; vms.Add(vm); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Select2DropdownVM vm) { try { var vmSource = vms.Where(i => i.Id == id).SingleOrDefault(); vmSource.SelectedCountryId = vm.SelectedCountryId; vmSource.SelectedStateId = vm.SelectedStateId; return RedirectToAction("Index"); } catch { return View(); } }
// GET: Location/Create public ActionResult Create() { var vm = new Select2DropdownVM(); vm.StateSelectItems = new List<SelectListItem>(); return View(vm); }