public ActionResult SaveAlbum(Album dtoAlbum) { if (dtoAlbum == null) throw new CallbackException("No album provided for saving.", 500); if (!ModelState.IsValid) throw new CallbackException("Model binding failed.", 500); var id = dtoAlbum.Id; var albumBus = new AlbumBusiness(); if (!albumBus.Validate(dtoAlbum)) throw new CallbackException("Album didn't validate: " + albumBus.ErrorMessage); if (!albumBus.SaveAlbum(dtoAlbum)) throw new CallbackException("Album save failed: " + albumBus.ErrorMessage); return new JsonNetResult(albumBus.Entity); }
public ActionResult TagHelpers(Album album = null) { if (album == null || (string.IsNullOrEmpty(album.Description) && string.IsNullOrEmpty(album.Title))) { album = new Album() { Id = 1, Title = "Highway to Hell", Description = "AC/DC's best" }; } else { if (ModelState.IsValid) { ModelState.Remove("Title"); album.Title = album.Title + " updated."; } } return View(album); }