Example #1
0
        public void HasFeaturedCampaignShouldReturnTrueIfViewMModelHasAFeaturedCampaign()
        {
            var sut = new IndexViewModel
            {
                FeaturedCampaign = new CampaignSummaryViewModel { Id = 1, Title = "Something" }
            };

            Assert.True(sut.HasFeaturedCampaign);
        }
Example #2
0
        public async Task<IActionResult> Index()
        {
            var model = new IndexViewModel
            {
                FeaturedCampaign = await mediator.SendAsync(new FeaturedCampaignQuery()),
                ActiveOrUpcomingCampaigns = await mediator.SendAsync(new ActiveOrUpcomingCampaignsQuery())
            };

            return View(model);
        }
Example #3
0
        public async Task<IActionResult> Index()
        {
            var model = new IndexViewModel
            {
                FeaturedCampaign = await mediator.SendAsync(new FeaturedCampaignQuery()),
                ActiveOrUpcomingCampaigns = await mediator.SendAsync(new ActiveOrUpcomingCampaignsQuery())
            };

            if (model.HasFeaturedCampaign)
            {
                var indexOfFeaturedCampaign = model.ActiveOrUpcomingCampaigns.FindIndex(s => s.Id == model.FeaturedCampaign.Id);
                model.ActiveOrUpcomingCampaigns.RemoveAt(indexOfFeaturedCampaign);
            }

            return View(model);
        }
Example #4
0
 public void HasFeaturedCampaignShouldReturnFalseIfViewModelHasNoFeaturedCampaign()
 {
     var sut = new IndexViewModel();
     Assert.False(sut.HasFeaturedCampaign);
 }