public ActionResult Edit(int id) { ChannelFormViewModel viewModel = channelManagementService.CreateFormViewModelFor(id); return(View(viewModel)); }
public ChannelFormViewModel CreateFormViewModelFor(Channel channel) { ChannelFormViewModel viewModel = CreateFormViewModel(); viewModel.Channel = channel; return(viewModel); }
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(); }
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(); }
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(); }
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); }
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)); }
public ChannelFormViewModel CreateFormViewModel() { ChannelFormViewModel viewModel = new ChannelFormViewModel(); return(viewModel); }
/// <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; }