Ejemplo n.º 1
0
        public ActionResult Index(string query = null)
        {
            var upcomingGigs = _context.Gigs
                               .Include(g => g.Artist)
                               .Where(g => g.DateTime > DateTime.Now && !g.IsCanceled)
                               .Include(g => g.Genre);
            var userId      = User.Identity.GetUserId();
            var attendences = _context.Attendences
                              .Where(a => a.AttendeeId == userId && a.Gig.DateTime > DateTime.Now)
                              .ToList()
                              .ToLookup(a => a.GigId);

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

            model.UpComingGigs = upcomingGigs;
            model.ShowActions  = User.Identity.IsAuthenticated;
            model.SearchTerm   = query;
            model.Attendences  = attendences;


            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult FollowingArtist()
        {
            var userId      = User.Identity.GetUserId();
            var followings  = _context.Followings.Where(f => f.FollowerId == userId).Select(f => f.Followee).Include(f => f.Followers).ToList();
            var attendences = _context.Attendences
                              .Where(a => a.AttendeeId == userId && a.Gig.DateTime > DateTime.Now)
                              .ToList()
                              .ToLookup(a => a.GigId);

            GigsListingViewModel model = new GigsListingViewModel();

            model.Followers   = followings;
            model.Attendences = attendences;
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Attending()
        {
            var userId = User.Identity.GetUserId();
            var gigs   = _context.Attendences
                         .Where(a => a.AttendeeId == userId)
                         .Select(a => a.Gig)
                         .Include(g => g.Artist)
                         .Include(g => g.Genre).ToList();
            var attendences = _context.Attendences
                              .Where(a => a.AttendeeId == userId && a.Gig.DateTime > DateTime.Now)
                              .ToList()
                              .ToLookup(a => a.GigId);

            var model = new GigsListingViewModel
            {
                UpComingGigs = gigs,
                ShowActions  = User.Identity.IsAuthenticated,
                Attendences  = attendences
            };

            return(View(model));
        }
Ejemplo n.º 4
0
 public ActionResult Search(GigsListingViewModel viewModel)
 {
     return(RedirectToAction("Index", "Home", new { query = viewModel.SearchTerm }));
 }