public ActionResult DeleteConfirmed(int id) { FavoriteBandList favoriteBandList = db.FavoriteBandLists.Find(id); db.FavoriteBandLists.Remove(favoriteBandList); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: FavoriteBandList/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FavoriteBandList favoriteBandList = db.FavoriteBandLists.Find(id); if (favoriteBandList == null) { return(HttpNotFound()); } return(View(favoriteBandList)); }
public ActionResult Create([Bind(Include = "Id,UserId,BandId")] FavoriteBandList favoriteBandList) { if (ModelState.IsValid) { if (!db.FavoriteBandLists.Any(row => row.UserId == favoriteBandList.UserId && row.BandId == favoriteBandList.BandId)) { db.FavoriteBandLists.Add(favoriteBandList); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.AspNetUsers.Where(x => x.Email == User.Identity.Name), "Id", "Email", favoriteBandList.UserId); ViewBag.BandId = new SelectList(db.Bands, "Id", "BandName", favoriteBandList.BandId); return(View(favoriteBandList)); }