Пример #1
0
        //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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
0
        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);
 }
Пример #6
0
 public void GetFollowing(Gig gig, GigsDetailsViewModel viewModel, string userId)
 {
     viewModel.IsFollowing = _context.Followings
                             .Any(f => f.FolloweeId == gig.ArtistId && f.FollowerId == userId);
 }
Пример #7
0
 public bool FollowingOrNot(Gig gig, GigsDetailsViewModel gigsvm, string userId)
 {
     return(gigsvm.Following = _ctx.Followings
                               .Any(g => g.FolloweeId == gig.ArtistId && g.FollowerId == userId));
 }