void AccountSongsManage_Save(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); if (e.Mode == "edit") { Song song = null; try { song = new Song(core, core.Functions.FormLong("id", 0)); } catch (InvalidSongException) { core.Display.ShowMessage("Error", "Cannot edit the song"); return; } song.Title = core.Http.Form["title"]; song.Lyrics = core.Http.Form["lyrics"]; song.LicenseId = core.Functions.GetLicenseId(); try { song.Update(); } catch (UnauthorisedToUpdateItemException) { core.Display.ShowMessage("Unauthorised", "Unauthorised to update song"); return; } this.SetRedirectUri(BuildUri("songs")); core.Display.ShowMessage("Song Saved", "The song has been updated in the database."); } else { Song song = Song.Create(core, (Musician)Owner, core.Http.Form["title"], core.Http.Form["lyrics"], core.Functions.GetLicenseId()); this.SetRedirectUri(BuildUri("songs")); core.Display.ShowMessage("Song Saved", "The song has been saved in the database."); } }
void AccountSongsManage_Add(object sender, ModuleModeEventArgs e) { SetTemplate("account_song_edit"); if (e.Mode == "edit") { Song song = null; try { song = new Song(core, core.Functions.RequestLong("id", 0)); } catch (InvalidSongException) { core.Display.ShowMessage("Error", "Cannot edit the song"); return; } template.Parse("S_TITLE", song.Title); template.Parse("S_LYRICS", song.Lyrics); template.Parse("S_MODE", "edit"); template.Parse("S_ID", song.Id.ToString()); core.Display.ParseLicensingBox(template, "S_LICENSE", song.LicenseId); } else { template.Parse("S_MODE", "add"); core.Display.ParseLicensingBox(template, "S_LICENSE", 0); } SaveMode(AccountSongsManage_Save); }
public static void Show(object sender, ShowMPageEventArgs e) { e.Template.SetTemplate("Musician", "viewsong"); Song song = null; try { song = new Song(e.Core, e.ItemId); } catch { e.Core.Functions.Generate404(); return; } e.Template.Parse("TITLE", song.Title); e.Template.Parse("LYRICS", song.Lyrics); List<Recording> recordings = song.GetRecordings(); foreach (Recording recording in recordings) { VariableCollection recordingVariableCollection = e.Template.CreateChild("recording_list"); recordingVariableCollection.Parse("RECORDING_ID", recording.Id); recordingVariableCollection.Parse("RECORDING_LOCATION", recording.RecordingLocation); if (recording.MusicianId != song.Musician.Id) { recordingVariableCollection.Parse("IS_COVER", "TRUE"); recordingVariableCollection.Parse("RECORDING_MUSICIAN_NAME", recording.Musician.DisplayName); recordingVariableCollection.Parse("RECORDING_MUSICIAN_ID", recording.Musician.Id); recordingVariableCollection.Parse("RECORDING_MUSICIAN_URI", recording.Musician.Uri); } } if (e.Page.Musician.Access.Can("COMMENT_SONGS")) { e.Template.Parse("CAN_COMMENT", "TRUE"); } }