private void Bind() { if (string.IsNullOrEmpty(Request.QueryString["setSongId"])) { Response.Redirect(LinkBuilder.DashboardLink()); } var setSongId = new Guid(Request.QueryString["setSongId"]); var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); var setService = new SetService(Ioc.GetInstance <ISetRepository>()); var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var setSong = setSongService.GetSetSong(setSongId); var set = setService.GetSet(setSong.SetId.Value); var show = showService.GetShow(set.ShowId.Value); ShowName = show.GetShowName(); SongName = setSong.SongName; lnkReviewShow.NavigateUrl = LinkBuilder.AnalysisLink(show.ShowId); lnkNoReviews.NavigateUrl = LinkBuilder.AnalysisLink(show.ShowId); SetPageTitle("Review of " + SongName + " from " + ShowName); BindReviews(setSongId); }
private Show GetShowFromSetSong(Guid setSongId) { var setSong = (SetSong)setSongService.GetSetSong(setSongId); var set = setService.GetSet(setSong.SetId.Value); var show = showService.GetShow(set.ShowId.Value); return((Show)show); }
public IWholeShowScore GetScore(IGuessWholeShow master) { double correct = 100; double incorrect = -100; double correctSpot = 500; IWholeShowScore score = new WholeShowScore(); SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); var masterSet = (Set)setService.GetSet(master.SetId); foreach (var setSong in this.Set.SetSongs.OrderBy(x => x.Order)) { int count = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count(); //If they are just straight up wrong then add it to here if (count == 0) { score.AddIncorrectSong(setSong.Song, incorrect); } else { int masterCount = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count(); int correctCount = score.Correct.Where(x => x.Key.SongId == setSong.SongId).Count(); if (masterCount > correctCount) { if (masterSet.SetSongs.Count >= setSong.Order) { if (setSong.Order == masterSet.SetSongs.Where(x => x.Order == setSong.Order).Single().Order) { //GIVE LOTS OF EXTRA POINTS CUZ THEY GOT IT IN THE SAME SLOT score.AddCorrectSong(setSong.Song, correctSpot); } else { //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT score.AddCorrectSong(setSong.Song, correct); } } else { //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT score.AddCorrectSong(setSong.Song, correct); } } else { //If they guessed the song more times than is in the master setlist then they got it wrong score.AddIncorrectSong(setSong.Song, incorrect); } } } return(score); }
private void MoveSetUp(Set set, Show show, ref SetService setService) { if (set.SetNumber != 1) { var setBefore = (Set)setService.GetSet(show.Sets.Where(x => x.SetNumber == set.SetNumber - 1).First().SetId); set.SetNumber--; setBefore.SetNumber++; } }
private void MoveSetDown(Set set, Show show, ref SetService setService) { if (set.SetNumber != show.Sets.OrderBy(x => x.SetNumber).Last().SetNumber) { var songAfter = (Set)setService.GetSet(show.Sets.Where(x => x.SetNumber == set.SetNumber + 1).First().SetId); set.SetNumber++; songAfter.SetNumber--; } }
private void Bind() { if (!string.IsNullOrEmpty(Request.QueryString["gid"])) { phGuessWholeShowScore.Visible = true; Guid guessId = new Guid(Request.QueryString["gid"]); Guid userID = new Guid(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString()); GuessWholeShowService guessService = new GuessWholeShowService(Ioc.GetInstance <IGuessWholeShowRepository>()); TopicService topicService = new TopicService(Ioc.GetInstance <ITopicRepository>()); var guess = guessService.GetGuessWholeShow(guessId); TopicName = topicService.GetTopic(guess.TopicId).TopicName; if (guess.UserId == userID) { var officialGuess = guessService.GetOfficialGuessByTopic(guess.TopicId); if (officialGuess != null) { var score = guess.GetScore(officialGuess); if (score != null) { lblGuessWholeShowScore.Text = score.GetScore().ToString(); } } } else { //Go buck f*****g wild on them } //WHEN OTHER GUESSES GET INTEGRATED INTO THIS PAGE THIS FUNCTIONALITY WILL NEED // TO BE USED FOR EACH ONE SO WILL HAVE TO BE MOVED OUT SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); var set = (Set)setService.GetSet(guess.SetId); if (set != null) { rptSongList.DataSource = set.SetSongs.Where(x => x.Deleted == false).OrderBy(x => x.Order); rptSongList.DataBind(); } } }
private void BindSet(GuessWholeShow guess) { lnkGetScore.NavigateUrl = LinkBuilder.GetScoreLink(guess.GuessWholeShowId, Request.Url.ToString()); SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); var set = (Set)setService.GetSet(guess.SetId); if (set != null) { rptSongList.DataSource = set.SetSongs.Where(x => x.Deleted == false).OrderBy(x => x.Order); rptSongList.DataBind(); } lnkAddSongsToSet.NavigateUrl = LinkBuilder.AddSongsToSetControlLink(set.SetId, returnUrl); phAddSongs.Visible = true; }
private void BindSet() { if (!string.IsNullOrEmpty(hdnId.Value)) { SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); Guid g = new Guid(hdnId.Value); var set = (Set)setService.GetSet(g); if (set != null) { if (set.SetSongs.Count > 0) { FinalOrder = set.SetSongs.OrderBy(x => x.Order).Last().Order; rptSongList.DataSource = set.SetSongs.OrderBy(x => x.Order); rptSongList.DataBind(); } } } }
public void rptSets_ItemCommand(object source, RepeaterCommandEventArgs e) { ResetPanels(); bool success = true; bool needToCommit = false; SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); Guid showId = new Guid(hdnId.Value); var show = (Show)showService.GetShow(showId); using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin()) { Guid setId = new Guid(e.CommandArgument.ToString()); var set = (Set)setService.GetSet(setId); if (set != null) { if (e.CommandName.ToLower() == "remove") { needToCommit = true; RemoveSet(set, show, ref setService); } else if (e.CommandName.ToLower() == "up") { needToCommit = true; MoveSetUp(set, show, ref setService); } else if (e.CommandName.ToLower() == "down") { needToCommit = true; MoveSetDown(set, show, ref setService); } else if (e.CommandName.ToLower() == "change") { needToCommit = true; Response.Redirect(LinkBuilder.AddSongsToSetControlLink(set.SetId, string.Format("/Admin/AddSetsToShow.aspx?id={0}", showId))); } try { if (needToCommit) { uow.Commit(); success = true; } } catch (Exception ex) { success = false; } } } DetermineSuccess(success); Bind(); }
public void btnSubmit_Click(object sender, EventArgs e) { ResetPanels(); TopicService tourService = new TopicService(Ioc.GetInstance <ITopicRepository>()); SongService songService = new SongService(Ioc.GetInstance <ISongRepository>()); SetService setService = new SetService(Ioc.GetInstance <ISetRepository>()); SetSongService setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); bool success = false; bool compiledSuccess = true; if (string.IsNullOrEmpty(hdnId.Value)) { Bind(); return; } var set = (Set)setService.GetSet(new Guid(hdnId.Value)); if (set == null) { Bind(); return; } if (lstSongs.Items.Count <= 0) { Bind(); return; } using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin()) { foreach (ListItem item in lstSongs.Items) { if (!item.Selected) { continue; } var song = songService.GetSong(new Guid(item.Value)); if (song == null) { continue; } short?order = 1; if (set.SetSongs.Count > 0) { order = set.SetSongs.OrderBy(x => x.Order).Last().Order; order++; } SetSong setSong = new SetSong() { Album = song.Album, CreatedDate = DateTime.UtcNow, SetSongId = Guid.NewGuid(), SongId = song.SongId, SongName = song.SongName, Order = order, Set = set, SetId = set.SetId, Segue = chkSegue.Checked }; setSongService.Save(setSong, out success); compiledSuccess = compiledSuccess && success; } if (compiledSuccess) { uow.Commit(); phSuccess.Visible = true; phError.Visible = false; } else { phError.Visible = true; phSuccess.Visible = false; } } Bind(); }
public static List <FavoriteSetSong> GenerateFavoriteVersionListByAlbum(string album) { var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var favoriteVersionService = new FavoriteVersionService(Ioc.GetInstance <IFavoriteVersionRepository>()); var showService = new ShowService(Ioc.GetInstance <IShowRepository>()); var setService = new SetService(Ioc.GetInstance <ISetRepository>()); FavoriteVersionSongList songList = new FavoriteVersionSongList(); foreach (var song in songService.GetSongsByAlbum(album)) { var versions = favoriteVersionService.GetAllFavoriteVersions().Where(s => s.SongId == song.SongId).GroupBy(g => g.SetSongId).ToList(); if (versions == null || versions.Count() <= 0) { songList.AddFavoriteSongPair(null, SetSong.FromSong((Song)song), null); continue; } if (versions.Count() == 1) { var version = versions[0].First(); var setSong = setSongService.GetSetSong(version.SetSongId.Value); var set = setService.GetSet(setSong.SetId.Value); var show = showService.GetShow(set.ShowId.Value); songList.AddFavoriteSongPair((FavoriteVersion)version, (SetSong)setSong, (Show)show); } else { int count = 0; Guid? setSongId = null; FavoriteVersion fave = null; SetSong setSong = null; IShow show = null; foreach (var version in versions) { if (version.Count() > count) { fave = (FavoriteVersion)version.First(); setSongId = version.First().SetSongId; } } if (setSongId != null) { setSong = (SetSong)setSongService.GetSetSong(setSongId.Value); var set = setService.GetSet(setSong.SetId.Value); show = showService.GetShow(set.ShowId.Value); } songList.AddFavoriteSongPair(fave, setSong ?? SetSong.FromSong((Song)song), (Show)show); } } return(songList.SongList); }