public ActionResult Edit(NewsModel model) { if (ModelState.IsValid) { var information = _db.Informations.Find(model.Id); model.ApplyChange(information); _db.Entry(information).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", new { id = information.Id })); } ViewBag.ActionName = "Edit"; ViewBag.Title = "Изменение yjdjcnb"; return(View("Create", model)); }
public ActionResult Create(NewsModel model) { if (ModelState.IsValid) { var information = new Information { InformationTypeId = (int)InformationTypes.News, CreatedTime = DateTime.Now, Counter = 0 }; model.ApplyChange(information); _db.Informations.Add(information); _db.SaveChanges(); return(RedirectToAction("Details", new { id = information.Id })); } ViewBag.ActionName = "Create"; ViewBag.Title = "Создание новости"; return(View("Create", model)); }