Example #1
0
        public ActionResult Create(RequestStatus requestStatus)
        {
            if (ViewData.ModelState.IsValid)
            {
                requestStatus.LastUpdateTimeStamp = DateTime.Now;
                requestStatus.LastUpdateUser      = GetCurrentUser().Id;
                ActionConfirmation saveOrUpdateConfirmation =
                    _requestStatusManagementService.SaveOrUpdate(requestStatus);

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

            RequestStatusFormViewModel viewModel =
                _requestStatusManagementService.CreateFormViewModelFor(requestStatus);

            return(View(viewModel));
        }
Example #2
0
        public void CanCreateFormViewModelForRequestStatus()
        {
            // Establish Context
            var viewModelToExpect = new RequestStatusFormViewModel();

            RequestStatus requestStatus =
                RequestStatusInstanceFactory.CreateValidTransientRequestStatus();

            _requestStatusRepository.Expect(r => r.Get(1))
            .Return(requestStatus);

            // Act
            RequestStatusFormViewModel viewModelRetrieved =
                _requestStatusManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestStatus.ShouldNotBeNull();
            viewModelRetrieved.RequestStatus.ShouldEqual(requestStatus);
        }