Example #1
0
        public ActionResult Edit(SupportTeam supportTeam)
        {
            try
            {
                if (ViewData.ModelState.IsValid)
                {
                    supportTeam.LastUpdateTimeStamp = DateTime.Now;
                    supportTeam.LastUpdateUser      = GetCurrentUser().Id;
                    ActionConfirmation updateConfirmation =
                        _supportTeamManagementService.UpdateWith(supportTeam, supportTeam.Id);

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

            SupportTeamFormViewModel viewModel =
                _supportTeamManagementService.CreateFormViewModelFor(supportTeam);

            return(View(viewModel));
        }
Example #2
0
        public void CanUpdateWithValidSupportTeamFromForm()
        {
            // Establish Context
            SupportTeam validSupportTeamFromForm =
                SupportTeamInstanceFactory.CreateValidTransientSupportTeam();

            // Intentionally empty to ensure successful transfer of values
            var supportTeamFromDb = new SupportTeam();

            supportTeamRepository.Expect(r => r.Get(1))
            .Return(supportTeamFromDb);

            // Act
            ActionConfirmation confirmation =
                supportTeamManagementService.UpdateWith(validSupportTeamFromForm, 1);

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