public ActionResult Edit(ArticleModel 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 = "Изменение статьи"; return(View("Create", model)); }
public ActionResult Create(ArticleModel model) { if (ModelState.IsValid) { var information = new Information { InformationTypeId = (int)InformationTypes.Article, 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)); }