public ActionResult Create(WebSample WebSample) { if (ViewData.ModelState.IsValid && WebSample.IsValid()) { WebSampleRepository.SaveOrUpdate(WebSample); TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The WebSample was successfully created."; return RedirectToAction("Index"); } WebSampleFormViewModel viewModel = WebSampleFormViewModel.CreateWebSampleFormViewModel(); viewModel.WebSample = WebSample; return View(viewModel); }
public ActionResult Edit(WebSample WebSample) { WebSample WebSampleToUpdate = WebSampleRepository.Get(WebSample.Id); TransferFormValuesTo(WebSampleToUpdate, WebSample); if (ViewData.ModelState.IsValid && WebSample.IsValid()) { TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = "The WebSample was successfully updated."; return RedirectToAction("Index"); } else { WebSampleRepository.DbContext.RollbackTransaction(); WebSampleFormViewModel viewModel = WebSampleFormViewModel.CreateWebSampleFormViewModel(); viewModel.WebSample = WebSample; return View(viewModel); } }