예제 #1
0
        public virtual ActionResult SaveContent(AdGenViewModel model)
        {
            Content content = model.Content;
            content.CampaignID = model.SelectedCampaignId;
            adgenRepository.CreateOrUpdateContent(content);

            return RedirectToAction(MVC.AdGen.Index());
        }
예제 #2
0
        public virtual ActionResult AddContent()
        {
            var viewModel = new AdGenViewModel
            {
                Content = new Content(),
                Campaigns = adgenRepository.GetAllCampaigns()
            };

            return View(viewModel);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }