public ActionResult Index(string query = null)
        {
            var upcomingGigs = _gigRepository.GetUpcomingGigs();

            if (!string.IsNullOrEmpty(query))
            {
                upcomingGigs = upcomingGigs.Where(g => g.Artist.Name.Contains(query) ||
                                                  g.Genre.Name.Contains(query) ||
                                                  g.Venue.Contains(query));
            }

            var userId = User.Identity.GetUserId();

            var attendances = _attendanceRepository.GetUserAttendances(userId)
                              //ToLookup() is like a dictionary, so internaly uses hash table to quickly lookup tables, here we lookup using GigId
                              .ToLookup(a => a.GigId);

            var homeViewModel = new GigsViewModel()
            {
                UpcomingGigs = upcomingGigs,
                ShowActions  = User.Identity.IsAuthenticated,
                Heading      = "Upcoming Gigs",
                SearchTerm   = query,
                Attendances  = attendances
            };

            return(View("Gigs", homeViewModel));
        }
    public void GetUpcomingGigsByArtist_GigsInThePast_ShouldNotBeReturned()
    {
        var gig = new Gig()
        {
            DateTime = DateTime.Now.AddDays(-1), ArtistId = "1"
        };

        _mockGigs.SetSource(new List <Gig> {
            gig
        });
        mockContext.SetupGet(c => c.Gigs).Returns(_mockGigs.Object);
        var gigs = _repository.GetUpcomingGigs("1");

        gigs.Should().BeEmpty();
    }