Example #1
0
        public ActionResult Create(Org org)
        {
            try
            {
                if (ViewData.ModelState.IsValid)
                {
                    org.LastUpdateTimeStamp = DateTime.Now;
                    org.LastUpdateUser      = GetCurrentUser().Id;
                    ActionConfirmation saveOrUpdateConfirmation =
                        _orgManagementService.SaveOrUpdate(org);

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

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

            Org org =
                OrgInstanceFactory.CreateValidTransientOrg();

            _orgRepository.Expect(r => r.Get(1))
            .Return(org);

            // Act
            OrgFormViewModel viewModelRetrieved =
                _orgManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Org.ShouldNotBeNull();
            viewModelRetrieved.Org.ShouldEqual(org);
        }