public ActionResult Slogans() { var slogans = _context.Slogans.ToList(); var viewmodel = new SlogansViewModel { Slogans = slogans }; return(View(viewmodel)); }
public ActionResult AddSlogan(Slogan slogan) { if (!ModelState.IsValid) { var viewmodel = new SlogansViewModel { Slogan = slogan, Slogans = _context.Slogans.ToList() }; return(View("Slogans", viewmodel)); } _context.Slogans.Add(slogan); _context.SaveChanges(); return(RedirectToAction("Slogans", "Home")); }