public ActionResult SaveArtist(Artist postedArtist) { if (!ModelState.IsValid) { throw new CallbackException("Model binding failed.", 500); } var artistBus = new ArtistBusiness(); // attach to context var artist = artistBus.Attach(postedArtist); if (!artistBus.Validate()) { throw new CallbackException("Please correct the following: " + artistBus.ValidationErrors.ToString()); } if (!artistBus.Save()) { throw new CallbackException("Unable to save artist: " + artistBus.ErrorMessage); } var albumBus = new AlbumBusiness(); var albums = albumBus.GetAlbumsForArtist(artist.Id); return(new JsonNetResult(new ArtistResponse { Artist = artist, Albums = albums })); }
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 DeleteAlbum(int id) { var albumBus = new AlbumBusiness(); if (!albumBus.Delete(id, saveChanges: true, useTransaction: true)) throw new CallbackException("Couldn't delete album: " + albumBus.ErrorMessage); return Json(true, JsonRequestBehavior.AllowGet); }
public ActionResult Create() { AlbumBusiness albumBusiness = new AlbumBusiness(); int idAlbum = Convert.ToInt32(ConfigurationManager.AppSettings["AlbumUtilizado"].ToString()); Album album = albumBusiness.BuscarAlbum(idAlbum); ViewBag.Album = album; return(View()); }
public ActionResult DeleteAlbum(int id) { var albumBus = new AlbumBusiness(); if (!albumBus.Delete(id, saveChanges: true, useTransaction: true)) { throw new CallbackException("Couldn't delete album: " + albumBus.ErrorMessage); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public void GetAlbumsTest() { var albumBus = new AlbumBusiness(); var albums = albumBus.GetAllAlbums(); Assert.IsNotNull(albums, albumBus.ErrorMessage); var albumList = albums.ToList(); Console.WriteLine(albumList.Count); Assert.IsTrue(albumList.Count > 0, "List should return some data."); }
public ActionResult GetAlbum(int id = -1) { if (id < 1) throw new CallbackException("Invalid album id passed."); var albumBus = new AlbumBusiness(); var album = albumBus.Load(id); if (album == null) throw new CallbackException("Invalid album id passed."); return new JsonNetResult(album); }
public ActionResult Edit() { AlbumBusiness albumBusiness = new AlbumBusiness(); OfertasBusiness ofertasBusiness = new OfertasBusiness(); int idAlbum = Convert.ToInt32(ConfigurationManager.AppSettings["AlbumUtilizado"].ToString()); Album album = albumBusiness.BuscarAlbum(idAlbum); ViewBag.Album = album; Ofertas oferta = ofertasBusiness.BuscarOferta(int.Parse(this.RouteData.Values["id"].ToString())); return(View(oferta)); }
// // GET: /VisualizarAlbum/ public ActionResult Index() { AlbumBusiness AlbumBusiness = new AlbumBusiness(); try { int idAlbum = Convert.ToInt32(ConfigurationManager.AppSettings["AlbumUtilizado"].ToString()); Album album = AlbumBusiness.BuscarAlbum(idAlbum); return(View(album)); } catch (BusinessException ex) { ModelState.AddModelError("", ex.Message); return(View()); } }
public ActionResult GetAlbum(int id = -1) { if (id < 1) { throw new CallbackException("Invalid album id passed."); } var albumBus = new AlbumBusiness(); var album = albumBus.Load(id); if (album == null) { throw new CallbackException("Invalid album id passed."); } return(new JsonNetResult(album)); }
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 Get(int id = -1) { if (id < 1) { throw new CallbackException("Invalid id passed."); } var artistBus = new ArtistBusiness(); var artist = artistBus.Load(id); if (artist == null) { throw new CallbackException("Invalid id passed."); } var albumBus = new AlbumBusiness(); var albums = albumBus.GetAlbumsForArtist(artist.Id); return(new JsonNetResult(new ArtistResponse { Artist = artist, Albums = albums })); }
public ActionResult Index() { var albumBus = new AlbumBusiness(); return new JsonNetResult(albumBus.GetAllAlbums()); }
public ActionResult Index() { var albumBus = new AlbumBusiness(); return(new JsonNetResult(albumBus.GetAllAlbums())); }
public AlbumController(AlbumBusiness AlbumBusiness) { this._AlbumBusiness = AlbumBusiness; }