Exemplo n.º 1
0
        public ActionResult Create(News news)
        {
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.CategoriesList = new SelectList(db.Categories, "id", "CategoryName");
            ViewBag.ImagesList = new SelectList(db.Images, "Id", "ImageUrl");

            return View(news);
        }
Exemplo n.º 2
0
 public ActionResult Edit(News news)
 {
     if (ModelState.IsValid)
     {
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(new News());
 }