Beispiel #1
0
        public IActionResult Delete(int QId)
        {
            //find where the id == the quote id you want to delete
            QuoteByPeople quote = _context.Quotes.Where(q => q.QId == QId).FirstOrDefault();

            //delete quote and save the changes
            _context.Remove(quote);
            _context.SaveChanges();

            return(Redirect("/Home/Index"));
        }
Beispiel #2
0
        public IActionResult SaveChanges(int QId, string QuotesNote, string AuthorFirst, string Citation, string Subject, DateTime Date, string AuthorLast)
        {
            //find which quote to change
            QuoteByPeople saying = _context.Quotes.Where(q => q.QId == QId).FirstOrDefault();

            //save changes
            saying.QuotesNote  = QuotesNote;
            saying.AuthorFirst = AuthorFirst;
            saying.AuthorLast  = AuthorLast;

            saying.QuotesNote = QuotesNote;
            saying.Citation   = Citation;
            saying.Subject    = Subject;
            saying.Date       = Date;


            _context.SaveChanges();

            return(Redirect("/Home/Index"));
        }
Beispiel #3
0
        public IActionResult AddQuote(QuoteByPeople quotes)
        {
            if (ModelState.IsValid)
            {
                // save movie to database


                _context.Quotes.Add(quotes);
                _context.SaveChanges();

                // go to Index page and save the new quote to the database
                return(View("Index", new QuoteList {
                    Quotes = _context.Quotes
                }));
            }
            //if the data isnt valid stay on the same page
            else
            {
                return(View("AddQuote", quotes));
            }
        }