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); }
public ActionResult Edit(News news) { if (ModelState.IsValid) { db.Entry(news).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(new News()); }