Example #1
0
        public ActionResult AddQuote()
        {
            var viewModel = new QuoteFormViewModel
            {
                AuthorsListable = _context.AuthorsTBLs.ToList()
            };

            ViewBag.ListToScreen = viewModel.AuthorsListable;

            return(View());
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }