public ActionResult Create(ArtistAdd newItem) { try { if (!ModelState.IsValid) { return(View(newItem)); } var addedItem = m.ArtistAdd(newItem); if (addedItem == null) { return(HttpNotFound()); } else { return(RedirectToAction("details", new { id = addedItem.Id })); } } catch { return(View()); } }
public ArtistWithDetail ArtistAdd(ArtistAdd newItem) { var a = ds.Albums.Find(newItem.AlbumIds); var addedItem = ds.Artists.Add(mapper.Map <ArtistAdd, Artist>(newItem)); if (a != null) { addedItem.Albums.Add(a); } ds.SaveChanges(); return((addedItem == null) ? null : mapper.Map <Artist, ArtistWithDetail>(addedItem)); }