public virtual void Add(T entity) { DetachEntities(); _dbSet.Add(entity); // eq Db.Set<T>().Attach(entity); _dataContext.Entry(entity).State = EntityState.Added; _dataContext.SaveChanges(); }
public ActionResult Edit([Bind(Include = "ArtistID,ArtistName,Photo")] Artist artist) { if (ModelState.IsValid) { db.Entry(artist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(artist)); }
public ActionResult Edit([Bind(Include = "AlbumID,Photo,ReleaseYear,WonAward,BiggestHit,TrackList,ArtistID")] Album album) { if (ModelState.IsValid) { db.Entry(album).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArtistID = new SelectList(db.Artists, "ArtistID", "ArtistName", album.ArtistID); return(View(album)); }
public ActionResult Edit([Bind(Include = "AlbumID,Title,Genre,YearReleased,WonGrammy,AlbumPhoto,ArtistID")] Album album) { if (ModelState.IsValid) { db.Entry(album).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArtistID = new SelectList(db.Artists, "ArtistID", "Name", album.ArtistID); return(View(album)); }
public ActionResult Edit([Bind(Include = "AlbumID,AlbumName,Description,ReleaseDate,Photo,TrackList,Grammy,ArtistID")] Album album) { if (ModelState.IsValid) { db.Entry(album).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ArtistID = new SelectList(db.Artists, "ArtistID", "ArtistName", album.ArtistID); return(View(album)); }
public ActionResult Edit(Models.Music musicToEdit) { var originalMusic = (from m in _db.Musics where m.Id == musicToEdit.Id select m).First(); if (!ModelState.IsValid) { return(View(originalMusic)); } _db.Entry(originalMusic).CurrentValues.SetValues(musicToEdit); _db.SaveChanges(); return(RedirectToAction("Index")); }