예제 #1
0
        public ChannelsSlideFormViewModel CreateFormViewModelFor(ChannelsSlide channelsSlide)
        {
            ChannelsSlideFormViewModel viewModel = CreateFormViewModel();

            viewModel.ChannelsSlide = channelsSlide;
            return(viewModel);
        }
예제 #2
0
        public ActionConfirmation Delete(int id)
        {
            ChannelsSlide channelsSlideToDelete = channelsSlideRepository.Get(id);

            if (channelsSlideToDelete != null)
            {
                channelsSlideRepository.Delete(channelsSlideToDelete);

                try {
                    channelsSlideRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccessConfirmation(
                               "The channelsSlide was successfully deleted."));
                }
                catch {
                    channelsSlideRepository.DbContext.RollbackTransaction();

                    return(ActionConfirmation.CreateFailureConfirmation(
                               "A problem was encountered preventing the channelsSlide from being deleted. " +
                               "Another item likely depends on this channelsSlide."));
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailureConfirmation(
                           "The channelsSlide could not be found for deletion. It may already have been deleted."));
            }
        }
예제 #3
0
 private void TransferFormValuesTo(ChannelsSlide channelsSlideToUpdate, ChannelsSlide channelsSlideFromForm)
 {
     channelsSlideToUpdate.Channel         = channelsSlideFromForm.Channel;
     channelsSlideToUpdate.Slide           = channelsSlideFromForm.Slide;
     channelsSlideToUpdate.ClickThroughURL = channelsSlideFromForm.ClickThroughURL;
     channelsSlideToUpdate.DisplayDuration = channelsSlideFromForm.DisplayDuration;
     channelsSlideToUpdate.Schedule        = channelsSlideFromForm.Schedule;
     channelsSlideToUpdate.PresentationConvertedSchedule = channelsSlideFromForm.PresentationConvertedSchedule;
 }
        public void CannotSaveOrUpdateInvalidChannelsSlide()
        {
            // Establish Context
            ChannelsSlide invalidChannelsSlide = new ChannelsSlide();

            // Act
            ActionConfirmation confirmation =
                channelsSlideManagementService.SaveOrUpdate(invalidChannelsSlide);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeFalse();
            confirmation.Value.ShouldBeNull();
        }
예제 #5
0
        public void CanCompareChannelsSlides()
        {
            ChannelsSlide instance = new ChannelsSlide();

            instance.Channel = null;
            instance.Slide   = null;

            ChannelsSlide instanceToCompareTo = new ChannelsSlide();

            instanceToCompareTo.Channel = null;
            instanceToCompareTo.Slide   = null;

            instance.ShouldEqual(instanceToCompareTo);
        }
        public void CanSaveOrUpdateValidChannelsSlide()
        {
            // Establish Context
            ChannelsSlide validChannelsSlide =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            // Act
            ActionConfirmation confirmation =
                channelsSlideManagementService.SaveOrUpdate(validChannelsSlide);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(validChannelsSlide);
        }
        public void CanDeleteChannelsSlide()
        {
            // Establish Context
            ChannelsSlide channelsSlideToDelete = new ChannelsSlide();

            channelsSlideRepository.Expect(r => r.Get(1))
            .Return(channelsSlideToDelete);

            // Act
            ActionConfirmation confirmation =
                channelsSlideManagementService.Delete(1);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldBeNull();
        }
        public void CanGetChannelsSlide()
        {
            // Establish Context
            ChannelsSlide channelsSlideToExpect =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            channelsSlideRepository.Expect(r => r.Get(1))
            .Return(channelsSlideToExpect);

            // Act
            ChannelsSlide channelsSlideRetrieved =
                channelsSlideManagementService.Get(1);

            // Assert
            channelsSlideRetrieved.ShouldNotBeNull();
            channelsSlideRetrieved.ShouldEqual(channelsSlideToExpect);
        }
        public void CanCreateValidChannelsSlideFromForm()
        {
            // Establish Context
            ChannelsSlide channelsSlideFromForm = new ChannelsSlide();

            channelsSlideManagementService.Expect(r => r.SaveOrUpdate(channelsSlideFromForm))
            .Return(ActionConfirmation.CreateSuccessConfirmation("saved"));

            // Act
            RedirectToRouteResult redirectResult =
                channelsSlidesController.Create(channelsSlideFromForm)
                .AssertActionRedirect().ToAction("Index");

            // Assert
            channelsSlidesController.TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()].ToString()
            .ShouldEqual("saved");
        }
        public void CanShowChannelsSlide()
        {
            // Establish Context
            ChannelsSlide channelsSlide =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            channelsSlideManagementService.Expect(r => r.Get(1))
            .Return(channelsSlide);

            // Act
            ViewResult result = channelsSlidesController.Show(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ChannelsSlide).ShouldNotBeNull();
            (result.ViewData.Model as ChannelsSlide).ShouldEqual(channelsSlide);
        }
        public void CannotUpdateInvalidChannelsSlideFromForm()
        {
            // Establish Context
            ChannelsSlide channelsSlideFromForm          = new ChannelsSlide();
            ChannelsSlideFormViewModel viewModelToExpect = new ChannelsSlideFormViewModel();

            channelsSlideManagementService.Expect(r => r.UpdateWith(channelsSlideFromForm, 0))
            .Return(ActionConfirmation.CreateFailureConfirmation("not updated"));
            channelsSlideManagementService.Expect(r => r.CreateFormViewModelFor(channelsSlideFromForm))
            .Return(viewModelToExpect);

            // Act
            ViewResult result =
                channelsSlidesController.Edit(channelsSlideFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ChannelsSlideFormViewModel).ShouldNotBeNull();
        }
예제 #12
0
        public ActionConfirmation SaveOrUpdate(ChannelsSlide channelsSlide)
        {
            if (channelsSlide.IsValid())
            {
                channelsSlideRepository.SaveOrUpdate(channelsSlide);

                ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The channelsSlide was successfully saved.");
                saveOrUpdateConfirmation.Value = channelsSlide;

                return(saveOrUpdateConfirmation);
            }
            else
            {
                channelsSlideRepository.DbContext.RollbackTransaction();

                return(ActionConfirmation.CreateFailureConfirmation(
                           "The channelsSlide could not be saved due to missing or invalid information."));
            }
        }
예제 #13
0
        public ActionResult Edit(ChannelsSlide channelsSlide)
        {
            if (ViewData.ModelState.IsValid)
            {
                ActionConfirmation updateConfirmation =
                    channelsSlideManagementService.UpdateWith(channelsSlide, channelsSlide.Id);

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

            ChannelsSlideFormViewModel viewModel =
                channelsSlideManagementService.CreateFormViewModelFor(channelsSlide);

            return(View(viewModel));
        }
        public void CanCreateFormViewModelForChannelsSlide()
        {
            // Establish Context
            ChannelsSlideFormViewModel viewModelToExpect = new ChannelsSlideFormViewModel();

            ChannelsSlide channelsSlide =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            channelsSlideRepository.Expect(r => r.Get(1))
            .Return(channelsSlide);

            // Act
            ChannelsSlideFormViewModel viewModelRetrieved =
                channelsSlideManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.ChannelsSlide.ShouldNotBeNull();
            viewModelRetrieved.ChannelsSlide.ShouldEqual(channelsSlide);
        }
        public void CannotUpdateWithInvalidChannelsSlideFromForm()
        {
            // Establish Context
            ChannelsSlide invalidChannelsSlideFromForm = new ChannelsSlide();

            // Intentionally empty to ensure successful transfer of values
            ChannelsSlide channelsSlideFromDb = new ChannelsSlide();

            channelsSlideRepository.Expect(r => r.Get(1))
            .Return(channelsSlideFromDb);

            // Act
            ActionConfirmation confirmation =
                channelsSlideManagementService.UpdateWith(invalidChannelsSlideFromForm, 1);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeFalse();
            confirmation.Value.ShouldBeNull();
        }
        public void CanGetAllChannelsSlides()
        {
            // Establish Context
            IList <ChannelsSlide> channelsSlidesToExpect = new List <ChannelsSlide>();

            ChannelsSlide channelsSlide =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            channelsSlidesToExpect.Add(channelsSlide);

            channelsSlideRepository.Expect(r => r.GetAll())
            .Return(channelsSlidesToExpect);

            // Act
            IList <ChannelsSlide> channelsSlidesRetrieved =
                channelsSlideManagementService.GetAll();

            // Assert
            channelsSlidesRetrieved.ShouldNotBeNull();
            channelsSlidesRetrieved.Count.ShouldEqual(1);
            channelsSlidesRetrieved[0].ShouldNotBeNull();
            channelsSlidesRetrieved[0].ShouldEqual(channelsSlide);
        }
예제 #17
0
        public ActionConfirmation UpdateWith(ChannelsSlide channelsSlideFromForm, int idOfChannelsSlideToUpdate)
        {
            ChannelsSlide channelsSlideToUpdate =
                channelsSlideRepository.Get(idOfChannelsSlideToUpdate);

            TransferFormValuesTo(channelsSlideToUpdate, channelsSlideFromForm);

            if (channelsSlideToUpdate.IsValid())
            {
                ActionConfirmation updateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The channelsSlide was successfully updated.");
                updateConfirmation.Value = channelsSlideToUpdate;

                return(updateConfirmation);
            }
            else
            {
                channelsSlideRepository.DbContext.RollbackTransaction();

                return(ActionConfirmation.CreateFailureConfirmation(
                           "The channelsSlide could not be saved due to missing or invalid information."));
            }
        }
        public void CanUpdateWithValidChannelsSlideFromForm()
        {
            // Establish Context
            ChannelsSlide validChannelsSlideFromForm =
                ChannelsSlideInstanceFactory.CreateValidTransientChannelsSlide();

            // Intentionally empty to ensure successful transfer of values
            ChannelsSlide channelsSlideFromDb = new ChannelsSlide();

            channelsSlideRepository.Expect(r => r.Get(1))
            .Return(channelsSlideFromDb);

            // Act
            ActionConfirmation confirmation =
                channelsSlideManagementService.UpdateWith(validChannelsSlideFromForm, 1);

            // Assert
            confirmation.ShouldNotBeNull();
            confirmation.WasSuccessful.ShouldBeTrue();
            confirmation.Value.ShouldNotBeNull();
            confirmation.Value.ShouldEqual(channelsSlideFromDb);
            confirmation.Value.ShouldEqual(validChannelsSlideFromForm);
        }
예제 #19
0
        public ActionResult Create(ChannelsSlide channelsSlide)
        {
            if (ViewData.ModelState.IsValid)
            {
                ActionConfirmation saveOrUpdateConfirmation =
                    channelsSlideManagementService.SaveOrUpdate(channelsSlide);

                if (saveOrUpdateConfirmation.WasSuccessful)
                {
                    TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
                        saveOrUpdateConfirmation.Message;
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                channelsSlide = null;
            }

            ChannelsSlideFormViewModel viewModel =
                channelsSlideManagementService.CreateFormViewModelFor(channelsSlide);

            return(View(viewModel));
        }
예제 #20
0
        public ActionResult Show(int id)
        {
            ChannelsSlide channelsSlide = channelsSlideManagementService.Get(id);

            return(View(channelsSlide));
        }
예제 #21
0
        public ChannelsSlideFormViewModel CreateFormViewModelFor(int channelsSlideId)
        {
            ChannelsSlide channelsSlide = channelsSlideRepository.Get(channelsSlideId);

            return(CreateFormViewModelFor(channelsSlide));
        }