Inheritance: System.Entity
Exemplo n.º 1
0
        public void CanCompareWebSamples()
        {
            WebSample instance = new WebSample();
            EntityIdSetter.SetIdOf<int>(instance, 1);

            WebSample instanceToCompareTo = new WebSample();
            EntityIdSetter.SetIdOf<int>(instanceToCompareTo, 1);

            instance.ShouldEqual(instanceToCompareTo);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void TransferFormValuesTo(WebSample WebSampleToUpdate, WebSample WebSampleFromForm)
 {
     // __BEGIN__PROPERTY__
     WebSampleToUpdate.Property = WebSampleFromForm.Property;
     // __END__PROPERTY__
 }
Exemplo n.º 4
0
        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);
            }
        }