Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            RequestStatusFormViewModel viewModel =
                _requestStatusManagementService.CreateFormViewModelFor(id);

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public RequestStatusFormViewModel CreateFormViewModelFor(RequestStatus requestStatus)
        {
            RequestStatusFormViewModel viewModel = CreateFormViewModel();

            viewModel.RequestStatus = requestStatus;
            return(viewModel);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            RequestStatusFormViewModel viewModel =
                _requestStatusManagementService.CreateFormViewModel();

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public void CanCreateFormViewModel()
        {
            // Establish Context
            var viewModelToExpect = new RequestStatusFormViewModel();

            // Act
            RequestStatusFormViewModel viewModelRetrieved =
                _requestStatusManagementService.CreateFormViewModel();

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestStatus.ShouldBeNull();
        }
        public void CanInitEdit()
        {
            // Establish Context
            var viewModel = new RequestStatusFormViewModel();

            _requestStatusManagementService.Expect(r => r.CreateFormViewModelFor(1))
            .Return(viewModel);

            // Act
            ViewResult result = _requestStatusesController.Edit(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestStatusFormViewModel).ShouldNotBeNull();
        }
Exemplo n.º 7
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);
        }
        public void CannotUpdateInvalidRequestStatusFromForm()
        {
            // Establish Context
            var requestStatusFromForm = new RequestStatus();
            var viewModelToExpect     = new RequestStatusFormViewModel();
            var testUser = PersonInstanceFactory.CreateValidTransientPerson();

            testUser.SetAssignedIdTo(1);

            _authenticationProvider.Expect(r => r.GetLoggedInUser()).Return("testuser");
            _personManagementService.Expect(r => r.GetByUserName(Arg <string> .Is.Anything)).Return(testUser);
            _requestStatusManagementService.Expect(r => r.UpdateWith(requestStatusFromForm, 0))
            .Return(ActionConfirmation.CreateFailureConfirmation("not updated"));
            _requestStatusManagementService.Expect(r => r.CreateFormViewModelFor(requestStatusFromForm))
            .Return(viewModelToExpect);

            // Act
            ViewResult result =
                _requestStatusesController.Edit(requestStatusFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestStatusFormViewModel).ShouldNotBeNull();
        }
Exemplo n.º 9
0
        public RequestStatusFormViewModel CreateFormViewModel()
        {
            var viewModel = new RequestStatusFormViewModel();

            return(viewModel);
        }