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 CanSaveOrUpdateValidOrg()
        {
            // Establish Context
            Org validOrg =
                OrgInstanceFactory.CreateValidTransientOrg();

            // Act
            ActionConfirmation confirmation =
                _orgManagementService.SaveOrUpdate(validOrg);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(validOrg);
        }