Esempio n. 1
0
 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));
 }
Esempio n. 2
0
        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));
        }