public ActionResult DeleteConfirmed(int id) { QuotesTBL selectedQuote = _context.QuotesTBLs.Find(id); _context.QuotesTBLs.Remove(selectedQuote); _context.SaveChanges(); return(RedirectToAction("QuotesList")); }
// GET: Quotes/Delete public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuotesTBL selectedQuote = _context.QuotesTBLs.Find(id); if (selectedQuote == null) { return(HttpNotFound()); } return(View(selectedQuote)); }
public ActionResult EditQuote([Bind(Include = "QuoteID, Quote, AuthorsTBLAuthID")] QuotesTBL selectedQuote) { var viewModelobj = new QuoteFormViewModel { AuthorsListable = _context.AuthorsTBLs.ToList() }; ViewBag.ListToScreen = viewModelobj.AuthorsListable; if (ModelState.IsValid) { _context.Entry(selectedQuote).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("QuotesList", "Quotes")); } return(View(selectedQuote)); }
public ActionResult AddQuote([Bind(Include = "Quote, AuthorsTBLAuthID")] QuotesTBL newQuote) //public ActionResult AddQuote(QuotesTBL newQuote) { var viewModelobj = new QuoteFormViewModel { AuthorsListable = _context.AuthorsTBLs.ToList() }; ViewBag.ListToScreen = viewModelobj.AuthorsListable; //Remember this is what shows the list of AuthorNames if (ModelState.IsValid) { _context.QuotesTBLs.Add(newQuote); _context.SaveChanges(); return(RedirectToAction("QuotesList", "Quotes")); } return(View(newQuote)); }
public ActionResult EditQuote(int?QuoteID) { //--------------------Can I get this to show up?------------- var viewModel = new QuoteFormViewModel { AuthorsListable = _context.AuthorsTBLs.ToList() }; ViewBag.ListToScreen = viewModel.AuthorsListable; //Remember this is what shows the list of AuthorNames if (QuoteID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuotesTBL selectedQuote = _context.QuotesTBLs.Find(QuoteID); if (selectedQuote == null) { return(HttpNotFound()); } //ViewBag.AuthorID = new SelectList(_context.AuthorTBLs, "AuthID", "AuthorName", selectedQuote.AuthorID); Magic loosely typed DropDown return(View(selectedQuote)); }