Esempio n. 1
0
        public ActionResult Edit(int id)
        {
            ChannelFormViewModel viewModel =
                channelManagementService.CreateFormViewModelFor(id);

            return(View(viewModel));
        }
Esempio n. 2
0
        public ChannelFormViewModel CreateFormViewModelFor(Channel channel)
        {
            ChannelFormViewModel viewModel = CreateFormViewModel();

            viewModel.Channel = channel;
            return(viewModel);
        }
Esempio n. 3
0
        public ActionResult Create()
        {
            ChannelFormViewModel viewModel =
                channelManagementService.CreateFormViewModel();

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

            // Act
            ChannelFormViewModel viewModelRetrieved =
                channelManagementService.CreateFormViewModel();

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Channel.ShouldBeNull();
        }
Esempio n. 5
0
        public void CanInitEdit()
        {
            // Establish Context
            ChannelFormViewModel viewModel = new ChannelFormViewModel();

            channelManagementService.Expect(r => r.CreateFormViewModelFor(1))
            .Return(viewModel);

            // Act
            ViewResult result = channelsController.Edit(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ChannelFormViewModel).ShouldNotBeNull();
        }
Esempio n. 6
0
        public void CannotUpdateInvalidChannelFromForm()
        {
            // Establish Context
            Channel channelFromForm = new Channel();
            ChannelFormViewModel viewModelToExpect = new ChannelFormViewModel();

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

            // Act
            ViewResult result =
                channelsController.Edit(channelFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ChannelFormViewModel).ShouldNotBeNull();
        }
Esempio n. 7
0
        public ActionResult Edit(Channel channel)
        {
            if (ViewData.ModelState.IsValid)
            {
                ActionConfirmation updateConfirmation =
                    channelManagementService.UpdateWith(channel, channel.Id);

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

            ChannelFormViewModel viewModel =
                channelManagementService.CreateFormViewModelFor(channel);

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

            Channel channel =
                ChannelInstanceFactory.CreateValidTransientChannel();

            channelRepository.Expect(r => r.Get(1))
            .Return(channel);

            // Act
            ChannelFormViewModel viewModelRetrieved =
                channelManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Channel.ShouldNotBeNull();
            viewModelRetrieved.Channel.ShouldEqual(channel);
        }
Esempio n. 9
0
        public ActionResult Create(Channel channel)
        {
            if (ViewData.ModelState.IsValid)
            {
                ActionConfirmation saveOrUpdateConfirmation =
                    channelManagementService.SaveOrUpdate(channel);

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

            ChannelFormViewModel viewModel =
                channelManagementService.CreateFormViewModelFor(channel);

            return(View(viewModel));
        }
Esempio n. 10
0
        public ChannelFormViewModel CreateFormViewModel()
        {
            ChannelFormViewModel viewModel = new ChannelFormViewModel();

            return(viewModel);
        }
Esempio n. 11
0
 /// <summary>
 /// Creation method for creating the view model. Services may be passed to the creation 
 /// method to instantiate items such as lists for drop down boxes.
 /// </summary>
 public static ChannelFormViewModel CreateChannelFormViewModel()
 {
     ChannelFormViewModel viewModel = new ChannelFormViewModel();
     return viewModel;
 }