Ejemplo n.º 1
0
        public void CanSaveOrUpdateValidAgency()
        {
            // Establish Context
            Agency validAgency =
                AgencyInstanceFactory.CreateValidTransientAgency();

            // Act
            ActionConfirmation confirmation =
                _agencyManagementService.SaveOrUpdate(validAgency);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(validAgency);
        }
Ejemplo n.º 2
0
        public ActionResult Create(Agency agency)
        {
            try
            {
                if (ViewData.ModelState.IsValid)
                {
                    agency.LastUpdateTimeStamp = DateTime.Now;
                    agency.LastUpdateUser      = GetCurrentUser().Id;
                    ActionConfirmation saveOrUpdateConfirmation =
                        _agencyManagementService.SaveOrUpdate(agency);

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

            AgencyFormViewModel viewModel =
                _agencyManagementService.CreateFormViewModelFor(agency);

            return(View(viewModel));
        }