public ActionResult EditQuote(FavQuote myModel) { var obj = lstQuotes.FirstOrDefault(x => x.QuoteID == myModel.QuoteID); if (obj != null) { obj.Quote = myModel.Quote; obj.MovieTitle = myModel.MovieTitle; obj.CharacterName = myModel.CharacterName; } return(View("DisplayQuotes", lstQuotes)); }
[HttpPost] //this is the add quote post method which checks if the info is valid before adding public ActionResult AddQuote(FavQuote myQuote) { myQuote.QuoteID = lstQuotes.Count() + 1; //autogenerated ID count if (ModelState.IsValid) { lstQuotes.Add(myQuote); return(RedirectToAction("DisplayQuotes")); } else { return(View(myQuote)); } }
public ActionResult EditQuote(int iQuote) { FavQuote oQuote = lstQuotes.Find(x => x.QuoteID == iQuote); return(View(oQuote)); }