public ActionResult Create(RequestType requestType)
        {
            if (ViewData.ModelState.IsValid)
            {
                requestType.LastUpdateTimeStamp = DateTime.Now;
                requestType.LastUpdateUser      = GetCurrentUser().Id;
                ActionConfirmation saveOrUpdateConfirmation =
                    _requestTypeManagementService.SaveOrUpdate(requestType);

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

            RequestTypeFormViewModel viewModel =
                _requestTypeManagementService.CreateFormViewModelFor(requestType);

            return(View(viewModel));
        }
Example #2
0
        public RequestTypeFormViewModel CreateFormViewModelFor(RequestType requestType)
        {
            RequestTypeFormViewModel viewModel = CreateFormViewModel();

            viewModel.RequestType = requestType;
            return(viewModel);
        }
        public ActionResult Edit(int id)
        {
            RequestTypeFormViewModel viewModel =
                _requestTypeManagementService.CreateFormViewModelFor(id);

            return(View(viewModel));
        }
        public ActionResult Create()
        {
            RequestTypeFormViewModel viewModel =
                _requestTypeManagementService.CreateFormViewModel();

            return(View(viewModel));
        }
        public void CanCreateFormViewModel()
        {
            // Establish Context
            var viewModelToExpect = new RequestTypeFormViewModel();

            // Act
            RequestTypeFormViewModel viewModelRetrieved =
                _requestTypeManagementService.CreateFormViewModel();

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestType.ShouldBeNull();
        }
Example #6
0
        public void CanInitEdit()
        {
            // Establish Context
            var viewModel = new RequestTypeFormViewModel();

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

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

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestTypeFormViewModel).ShouldNotBeNull();
        }
        public void CanCreateFormViewModelForRequestType()
        {
            // Establish Context
            var viewModelToExpect = new RequestTypeFormViewModel();

            RequestType requestType =
                RequestTypeInstanceFactory.CreateValidTransientRequestType();

            _requestTypeRepository.Expect(r => r.Get(1))
            .Return(requestType);

            // Act
            RequestTypeFormViewModel viewModelRetrieved =
                _requestTypeManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.RequestType.ShouldNotBeNull();
            viewModelRetrieved.RequestType.ShouldEqual(requestType);
        }
Example #8
0
        public void CannotUpdateInvalidRequestTypeFromForm()
        {
            // Establish Context
            var requestTypeFromForm = new RequestType();
            var viewModelToExpect   = new RequestTypeFormViewModel();
            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);
            _requestTypeManagementService.Expect(r => r.UpdateWith(requestTypeFromForm, 0))
            .Return(ActionConfirmation.CreateFailureConfirmation("not updated"));
            _requestTypeManagementService.Expect(r => r.CreateFormViewModelFor(requestTypeFromForm))
            .Return(viewModelToExpect);

            // Act
            ViewResult result =
                _requestTypesController.Edit(requestTypeFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as RequestTypeFormViewModel).ShouldNotBeNull();
        }
Example #9
0
        public RequestTypeFormViewModel CreateFormViewModel()
        {
            var viewModel = new RequestTypeFormViewModel();

            return(viewModel);
        }