public ArtistWithDetails ArtistAdd(ArtistAdd newItem) { var addedItem = ds.Artists.Add(mapper.Map <ArtistAdd, Artist>(newItem)); // Configure the user name addedItem.Executive = User.Name; ds.SaveChanges(); return((addedItem == null) ? null : mapper.Map <Artist, ArtistWithDetails>(addedItem)); }
public ArtistBase ArtistAdd(ArtistAdd newItem) { var addGenre = ds.Genres.Find(newItem.GenreId); var addedItem = ds.Artists.Add(Mapper.Map <ArtistAdd, Artist>(newItem)); addedItem.Genre = addGenre.Name; ds.SaveChanges(); return((addedItem == null) ? null : Mapper.Map <Artist, ArtistBase>(addedItem)); }
//[Authorize(Roles = "Executive")] public ActionResult Create(ArtistAdd newItem) { // Validate the input if (!ModelState.IsValid) { return(View(newItem)); } // Process the input var addedItem = m.ArtistAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("Details", new { id = addedItem.Id })); } }
public ActionResult Create(ArtistAdd newItem) { newItem.Executive = HttpContext.User.Identity.Name; // Validate the input if (!ModelState.IsValid) { return(View(newItem)); } // Process the input var addedItem = m.ArtistAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("details", new { id = addedItem.Id })); } }