public ActionResult Index(ViewModels.WorkViewModel vm, string buttonValue) { switch (buttonValue) { case "Save": if (ModelState.IsValid) { var work = vm.EditWork; _WorkRepo.SaveWork(work); vm.EditWork = null; ModelState.Clear(); } break; case "Delete": _WorkRepo.DeleteWork(vm.EditWork.WorkId); vm.EditWork = null; ModelState.Clear(); break; default: vm.EditWork = null; ModelState.Clear(); break; } prepWork(vm); return(View(vm)); }
public ActionResult Index(Models.WorkViewModel vm, string buttonValue) { bool clearEdit = false; switch (buttonValue) { case "OpenClose": _WorkRepo.ToggleWorkOpen(vm.SelectedContractorId, vm.SelectedCycle); ModelState.Clear(); break; case "Save": if (ModelState.IsValid) { var work = vm.EditWork; clearEdit = work.WorkId == 0; _WorkRepo.SaveWork(work); if (!clearEdit) { vm.EditWork = null; } ModelState.Clear(); } break; case "Delete": _WorkRepo.DeleteWork(vm.EditWork.WorkId); vm.EditWork = null; ModelState.Clear(); break; default: vm.EditWork = null; ModelState.Clear(); break; } prepWork(vm, clearEdit); return(View(vm)); }