Inheritance: Entity
        public void CanEnsureStatusCreationIsValid()
        {
            Status statusFromForm = new Status();
            ViewResult result = controller.Create(statusFromForm).AssertViewRendered();

            result.ViewData.Model.ShouldNotBeNull();
            result.ViewData.Model.ShouldBeOfType(typeof(StatusFormViewModel));
        }
        public void CanCompareStatuses()
        {
            Status instance = new Status();
            instance.Name = "Active";

            Status instanceToCompareTo = new Status();
            instanceToCompareTo.Name = "Active";

            instance.ShouldEqual(instanceToCompareTo);
        }
        public ActionResult Create(Status status)
        {
            if (ViewData.ModelState.IsValid)
            {
                ActionConfirmation saveOrUpdateConfirmation = statusManagementService.SaveOrUpdate(status);

                if (saveOrUpdateConfirmation.WasSuccessful)
                {
                    TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = saveOrUpdateConfirmation.Message;
                    return RedirectToAction("Index");
                }
            }

            StatusFormViewModel viewModel = statusManagementService.CreateFormViewModelFor(status);
            return View(viewModel);
        }
        /// <summary>
        /// Creates a valid, transient Status; typical of something retrieved back from a form submission
        /// </summary>
        private Status CreateTransientStatus()
        {
            Status status = new Status() {
                Name = "Active"
            };

            return status;
        }
        public ActionConfirmation SaveOrUpdate(Status status)
        {
            if (status.IsValid())
            {
                statusRepository.SaveOrUpdate(status);

                ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The status was successfully saved.");
                saveOrUpdateConfirmation.Value = status;

                return saveOrUpdateConfirmation;
            }
            else
            {
                statusRepository.DbContext.RollbackTransaction();

                return ActionConfirmation.CreateFailureConfirmation(
                    "The status could not be saved due to missing or invalid information.");
            }
        }
 public StatusFormViewModel CreateFormViewModelFor(Status status)
 {
     StatusFormViewModel viewModel = CreateFormViewModel();
     viewModel.Status = status;
     return viewModel;
 }
 private void TransferFormValuesTo(Status statusToUpdate, Status statusFromForm)
 {
     statusToUpdate.Name = statusFromForm.Name;
 }
        public ActionConfirmation UpdateWith(Status statusFromForm)
        {
            Status statusToUpdate = statusRepository.Get(statusFromForm.Id);
            TransferFormValuesTo(statusToUpdate, statusFromForm);

            if (statusToUpdate.IsValid())
            {
                ActionConfirmation updateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The user was successfully updated.");
                updateConfirmation.Value = statusToUpdate;

                return updateConfirmation;
            }
            else
            {
                statusRepository.DbContext.RollbackTransaction();

                return ActionConfirmation.CreateFailureConfirmation(
                    "The user could not be saved due to missing or invalid information.");
            }
        }