Exemple #1
0
        public ActionResult Create(WrmsSystem wrmsSystem)
        {
            try
            {
                if (ViewData.ModelState.IsValid)
                {
                    wrmsSystem.LastUpdateTimeStamp = DateTime.Now;
                    wrmsSystem.LastUpdateUser      = GetCurrentUser().Id;
                    ActionConfirmation saveOrUpdateConfirmation =
                        _wrmsSystemManagementService.SaveOrUpdate(wrmsSystem);

                    if (saveOrUpdateConfirmation.WasSuccessful)
                    {
                        TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
                            saveOrUpdateConfirmation.Message;
                        return(RedirectToAction("Search"));
                    }
                }
                else
                {
                    wrmsSystem = null;
                }
            }
            catch (PreconditionException pce)
            {
                TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
                    pce.Message;
            }
            WrmsSystemFormViewModel viewModel =
                _wrmsSystemManagementService.CreateFormViewModelFor(wrmsSystem);

            return(View(viewModel));
        }
Exemple #2
0
        public void CanCreateFormViewModelForWrmsSystem()
        {
            // Establish Context
            var viewModelToExpect = new WrmsSystemFormViewModel();

            WrmsSystem wrmsSystem =
                WrmsSystemInstanceFactory.CreateValidTransientWrmsSystem();

            _wrmsSystemRepository.Expect(r => r.Get(1))
            .Return(wrmsSystem);

            // Act
            WrmsSystemFormViewModel viewModelRetrieved =
                _wrmsSystemManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.WrmsSystem.ShouldNotBeNull();
            viewModelRetrieved.WrmsSystem.ShouldEqual(wrmsSystem);
        }