public ActionResult Create(TrackAdd newItem) { try { if (!ModelState.IsValid) { return(View(newItem)); } // TODO: Add insert logic here var addedItem = m.TrackAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("details", new { id = addedItem.Id })); } } catch { return(View()); } }
public TrackWithDetail TrackAdd(TrackAdd newItem) { var a = ds.Albums.Find(newItem.AlbumIds); if (a == null) { return(null); } else { var addedItem = ds.Tracks.Add(mapper.Map <TrackAdd, Track>(newItem)); addedItem.Albums.Add(a); ds.SaveChanges(); return((addedItem == null) ? null : mapper.Map <Track, TrackWithDetail>(addedItem)); } }
public ActionResult AddTrack(TrackAdd newItem) { //Validate if (!ModelState.IsValid) { return(View(newItem)); } // Process var addedItem = m.TrackAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("details", "track", new { id = addedItem.Id })); } }