//to view details of artists public ActionResult Details(int id) { // we are loading gig with given Id var gig = _context.Gigs .Include(g => g.Artist) .Include(g => g.Genre) .SingleOrDefault(g => g.Id == id); //if gig is null if (gig == null) { return(HttpNotFound()); } //initializing the viewmodel var viewModel = new GigsDetailsViewModel() { Gig = gig }; //validate the user if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId(); viewModel.IsAttending = _context.Attendances .Any(a => a.GigId == gig.Id && a.AttendeeId == userId); } return(View("Details", viewModel)); }
public ActionResult Details(int id) { var gig = _unitOfWork.Gigs.GetGigWithArtist(id); if (gig == null) { return(HttpNotFound()); } var gigDetailsViewModel = new GigsDetailsViewModel() { Gig = gig }; if (User.Identity.IsAuthenticated) { var isFollowing = _unitOfWork.Followings.GetFollower(_userId, gig.ArtistId) != null; var isAttending = _unitOfWork.Attendances.GetAttendance(gig.Id, _userId) != null; gigDetailsViewModel.isFollowing = isFollowing; gigDetailsViewModel.isAttending = isAttending; } return(View(gigDetailsViewModel)); }
public ActionResult Details(int id) { Gig gig = _unitOfWork.Gigs.GetGig(id); if (gig == null) { return(HttpNotFound()); } var viewModel = new GigsDetailsViewModel { Gig = gig }; if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId(); _unitOfWork.Attendances.GetAttendance(gig, viewModel, userId); _unitOfWork.Followings.GetFollowing(gig, viewModel, userId); } return(View("Details", viewModel)); }
public ActionResult Details(int id) { var gig = unitofwork.Gigs.GetGigToSeeDetails(id); if (gig == null) { return(HttpNotFound()); } var gigsvm = new GigsDetailsViewModel { Gig = gig }; if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId(); gigsvm.Attending = unitofwork.Attedances.GetUserAttendance(gig, userId); gigsvm.Following = unitofwork.Follows.FollowingOrNot(gig, gigsvm, userId); } return(View("Details", gigsvm)); }
public void GetAttendance(Gig gig, GigsDetailsViewModel viewModel, string userId) { viewModel.IsAttending = _context.Attendances .Any(a => a.GigId == gig.Id && a.AttendeeId == userId); }
public void GetFollowing(Gig gig, GigsDetailsViewModel viewModel, string userId) { viewModel.IsFollowing = _context.Followings .Any(f => f.FolloweeId == gig.ArtistId && f.FollowerId == userId); }
public bool FollowingOrNot(Gig gig, GigsDetailsViewModel gigsvm, string userId) { return(gigsvm.Following = _ctx.Followings .Any(g => g.FolloweeId == gig.ArtistId && g.FollowerId == userId)); }