public void SongListView_InsertItem() { var item = new Song(); if (TryUpdateModel(item)) { try { item.AlbumID = int.Parse(AlbumID); if (ArtistID != null) { item.ArtistID = int.Parse(ArtistID); } Service.SaveSong(item); Response.RedirectToRoute("AlbumDetails", new {id = item.AlbumID}); Context.ApplicationInstance.CompleteRequest(); } catch { Page.ModelState.AddModelError(String.Empty, "Error while adding the album to the database"); } } }
/// <summary> /// Save the song /// </summary> public static void SaveSong(Song song) { if (!song.Validate()) { throw new ValidationException(); } if (song.SongID == 0) { SongDAL.InsertSong(song); } else { SongDAL.UpdateSong(song); } }