public virtual ActionResult SaveContent(AdGenViewModel model) { Content content = model.Content; content.CampaignID = model.SelectedCampaignId; adgenRepository.CreateOrUpdateContent(content); return RedirectToAction(MVC.AdGen.Index()); }
public virtual ActionResult AddContent() { var viewModel = new AdGenViewModel { Content = new Content(), Campaigns = adgenRepository.GetAllCampaigns() }; return View(viewModel); }
public virtual ActionResult EditContent(int id) { var viewModel = new AdGenViewModel { Content = adgenRepository.GetContentById(id), Campaigns = adgenRepository.GetAllCampaigns(), }; viewModel.SelectedCampaignId = viewModel.Content.CampaignID; return View(viewModel); }
public void CanSaveContent() { // Arrange var fakeRepo = Substitute.For<IAdgenRepository>(); var controller = new AdGenController(fakeRepo); var fakeViewModel = new AdGenViewModel { Content = new Content(), SelectedCampaignId = 0 }; // Act controller.SaveContent(fakeViewModel); // Assert fakeRepo.Received().CreateOrUpdateContent(fakeViewModel.Content); }