public void rptSongList_ItemCommand(object source, RepeaterCommandEventArgs e) { ResetPanels(); bool success = true; bool needToCommit = false; using (IUnitOfWork uow = TheCore.Infrastructure.UnitOfWork.Begin()) { Guid g = new Guid(e.CommandArgument.ToString()); var song = (SetSong)setSongService.GetSetSong(g); var set = song.Set; if (song != null) { if (e.CommandName.ToLower() == "remove") { needToCommit = true; RemoveSong(g, song, set); } else if (e.CommandName.ToLower() == "up") { needToCommit = true; MoveSongUp(g, song, set); } else if (e.CommandName.ToLower() == "down") { needToCommit = true; MoveSongDown(g, song, set); } try { if (needToCommit) { uow.Commit(); success = true; } } catch (Exception ex) { success = false; } } } DetermineSuccess(success); Bind(); }
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 rptSongs_ItemCommand(object source, RepeaterCommandEventArgs e) { var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var setSong = setSongService.GetSetSong(new Guid(e.CommandArgument.ToString())); if (e.CommandName.ToLower() == "fix") { txtSongName.Text = setSong.SongName; hdnSetSongIdToFix.Value = setSong.SetSongId.ToString(); } else if (e.CommandName.ToLower() == "delete") { ///TEST THIS SECTION var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var song = songService.GetSong(setSong.SongId.Value); using (IUnitOfWork uow = UnitOfWork.Begin()) { setSongService.Delete(setSong); if (song != null) { songService.Delete(song); } uow.Commit(); } var setsongs = setSongService.GetAllSetSongs().Where(x => x.SongName.Contains(txtSearchSongName.Text)); rptSongs.DataSource = setsongs; rptSongs.DataBind(); } }
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); }
public void btnFixSetSong_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSongName.Text)) { return; } if (string.IsNullOrEmpty(hdnSetSongIdToFix.Value)) { return; } var changeSongNameToo = false; if (chkSongToo.Checked) { changeSongNameToo = true; } var newSongName = txtSongName.Text.Trim(); var setSongId = new Guid(hdnSetSongIdToFix.Value); using (IUnitOfWork uow = UnitOfWork.Begin()) { var setSongService = new SetSongService(Ioc.GetInstance <ISetSongRepository>()); var setSong = setSongService.GetSetSong(setSongId); setSong.SongName = newSongName; var setsongs = setSongService.GetAllSetSongs().Where(x => x.SongName.Contains(txtSearchSongName.Text)); if (changeSongNameToo) { var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var song = songService.GetSong(setSong.SongId.Value); song.SongName = newSongName; } uow.Commit(); rptSongs.DataSource = setsongs; rptSongs.DataBind(); } }
public List <FavoriteLiveSongList> GenerateFavoriteLiveSongList(IQueryable <ISong> songs) { var songService = new SongService(Ioc.GetInstance <ISongRepository>()); var favoriteVersionService = new FavoriteVersionService(Ioc.GetInstance <IFavoriteVersionRepository>()); List <FavoriteLiveSongList> songLists = new List <FavoriteLiveSongList>(); foreach (var song in songs) { var versions = favoriteVersionService.GetAllFavoriteVersions().Where(s => s.SongId == song.SongId).GroupBy(g => g.SetSongId).ToList(); //If there aren't any favorites chosen for that song then just add the song to be displayed and continue if (versions == null || versions.Count() <= 0) { var fave = GetAnalysisPart((Song)song); if (fave != null) { songLists.Add(fave); } else { songLists.Add(new FavoriteLiveSongList(SetSong.FromSong((Song)song))); } continue; } //If there is only 1 favorite version then just use the first one in the collection if (versions.Count() == 1) { var version = versions[0].First(); var setSongId = version.SetSongId.Value; var setSong = (SetSong)setSongService.GetSetSong(setSongId); var show = GetShowFromSetSong(setSongId); var fave = GetAnalysisPart(setSong); if (fave != null) { fave.FavoriteLiveShows.Add(show); } else { fave = new FavoriteLiveSongList(setSong, show); } songLists.Add(fave); } //There is a lot to check else { int count = 0; Guid?setSongId = null; FavoriteLiveSongList songList = new FavoriteLiveSongList(); foreach (var version in versions) { //If this version has more votes then it needs to be added if (version.Count() >= count) { if (version.Count() > count && count > 0) { //If its not the first time in the loop and this version is the most voted on then clear whatever is in there songList.ClearShows(); } //Change the count so that next time it will be right count = version.Count(); setSongId = version.First().SetSongId; var setSong = (SetSong)setSongService.GetSetSong(setSongId.Value); var show = GetShowFromSetSong(setSongId.Value); songList.AddFavorite(setSong, show); } } var fave = GetAnalysisPart(setSongId); if (fave != null) { songList.HighestRating = fave.HighestRating; songList.HighestRatedShows = fave.HighestRatedShows; } songLists.Add(songList); } } return(songLists); }
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); }