private void BindReviews(Guid setSongId)
        {
            var analysisService = new AnalysisService(Ioc.GetInstance<IAnalysisRepository>());

            var analyses = analysisService.GetAnalysisBySetSong(setSongId).OrderByDescending(x => x.UpdatedDate).ToList();

            if (analyses == null || analyses.Count <= 0)
            {
                phNoReviews.Visible = true;
                return;
            }

            rptReviews.DataSource = analyses;
            rptReviews.DataBind();
        }
        private FavoriteLiveSongList GetAnalysisPart(Song song)
        {
            var setSongService = new SetSongService(Ioc.GetInstance<ISetSongRepository>());
            var analysisService = new AnalysisService(Ioc.GetInstance<IAnalysisRepository>());
            var songService = new SongService(Ioc.GetInstance<ISongRepository>());

            //Get all Analysis for that Song but in groups of SetSong
            var analysis = analysisService.GetAnalysisBySong(song.SongId).GroupBy(x => x.SetSongId);

            double highestRating = 0;
            double? rating = 0;
            List<Guid> setSongIds = new List<Guid>();

            //If there are no analysis then there is nothing to see here
            if (analysis.Count() == 0)
                return null;

            var fave = new FavoriteLiveSongList(SetSong.FromSong(song));

            //If there are 1 or more analysis then we need to find out which is the highest ranked
            foreach (var a in analysis)
            {
                rating = a.Average(x => x.Rating);
                var setSongId = a.First().SetSongId;

                if (rating.HasValue && rating.Value > highestRating)
                {
                    highestRating = rating.Value;
                    fave.HighestRatedShows = new List<Show>();

                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show = GetShowFromSetSong(setSongId);
                    fave.HighestRatedShows.Add(show);
                }
                else if (rating.HasValue && rating.Value == highestRating)
                {
                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show = GetShowFromSetSong(setSongId);

                    fave.HighestRatedShows.Add(show);
                }
            }

            fave.HighestRating = highestRating;

            return fave;
        }
        public void ajaxSongRating_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
        {
            ResetPanels();

            var setSongId = new Guid(e.Tag);
            var userId = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString());
            var rating = (int?)int.Parse(e.Value);

            var analysisService = new AnalysisService(Ioc.GetInstance<IAnalysisRepository>());

            var analysis = analysisService.GetAnalysisBySetSongAndUser(setSongId, userId).SingleOrDefault();

            if (analysis != null)
            {
                using (IUnitOfWork uow = UnitOfWork.Begin())
                {
                    analysis.Rating = rating;
                    uow.Commit();
                }
            }
            else
            {
                Guid? myShowId = null;

                if (!string.IsNullOrEmpty(hdnMyShowId.Value))
                {
                    myShowId = new Guid(hdnMyShowId.Value);
                }

                Analysis newAnalysis = new Analysis
                {
                    AnalysisId = Guid.NewGuid(),
                    CreatedDate = DateTime.Now,
                    MyShowId = myShowId,
                    Rating = rating,
                    SetSongId = setSongId,
                    UserId = userId
                };

                bool success = false;

                analysisService.SaveCommit(newAnalysis, out success);
            }
        }