public AlbumBase AlbumAdd(AlbumAdd newItem) { // Attempt to add the new item var addedItem = ds.Albums.Add(Mapper.Map <AlbumAdd, Album>(newItem)); var addGenre = ds.Genres.Find(newItem.GenreId); // Set the associated item property addedItem.Genre = addGenre.Name; ds.SaveChanges(); return((addedItem == null) ? null : Mapper.Map <Album, AlbumBase>(addedItem)); }
public ActionResult addAlbum(AlbumAdd newItem) { newItem.Coordinator = HttpContext.User.Identity.Name; // Validate the input if (!ModelState.IsValid) { return(View(newItem)); } // Process the input var addedItem = m.AlbumAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("../album/details", new { id = addedItem.Id })); } }