コード例 #1
0
ファイル: WebSamplesController.cs プロジェクト: sztupy/shaml
        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);
        }
コード例 #2
0
ファイル: WebSamplesController.cs プロジェクト: sztupy/shaml
        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);
            }
        }