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(); } }
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(); } }
private FavoriteLiveSongList GetAnalysisPart(SetSong setSong) { var songService = new SongService(Ioc.GetInstance<ISongRepository>()); return GetAnalysisPart((Song)songService.GetSong(setSong.SongId.Value)); }
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(); }