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

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

            SupportTeamFormViewModel viewModel =
                _supportTeamManagementService.CreateFormViewModelFor(supportTeam);

            return(View(viewModel));
        }
Example #2
0
        public void CanCreateFormViewModelForSupportTeam()
        {
            // Establish Context
            var viewModelToExpect = new SupportTeamFormViewModel();

            SupportTeam supportTeam =
                SupportTeamInstanceFactory.CreateValidTransientSupportTeam();

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

            // Act
            SupportTeamFormViewModel viewModelRetrieved =
                supportTeamManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.SupportTeam.ShouldNotBeNull();
            viewModelRetrieved.SupportTeam.ShouldEqual(supportTeam);
        }