public void InsertArtist() { var item = new Artist(); if (TryUpdateModel(item)) { try { Service.SaveArtist(item); try { var picUpload = FormView.FindControl("PicUpload") as FileUpload; Service.SaveArtistArt(picUpload.FileContent, item.ArtistID); this.SetTempData("SuccessMessage", "The artist was created."); Response.RedirectToRoute("ArtistDetails", new {id = item.ArtistID}); Context.ApplicationInstance.CompleteRequest(); } catch { ModelState.AddModelError(String.Empty, "Error while saving the artist picture"); } } catch { ModelState.AddModelError(String.Empty, "Error while adding the artist to the database"); } } }
/// <summary> /// Save the artist /// </summary> public static void SaveArtist(Artist artist) { if (!artist.Validate()) { throw new ValidationException(); } if (artist.ArtistID == 0) { ArtistDAL.InsertArtist(artist); } else { ArtistDAL.UpdateArtist(artist); } }