Пример #1
0
 public ActionResult Edit(int id)
 {
     using (var ctx = new Context())
     {
         var c = ctx.Contents.FirstOrDefault(x => x.Id == id);
         var model = new ContentCreateModel
         {
             Id = c.Id,
             Name = c.Name,
             Text = c.Text
         };
         return View(model);
     }
 }
Пример #2
0
        public ActionResult Edit(ContentCreateModel post)
        {
            if (this.ModelState.IsValid)
            {
                using (var ctx = new Context())
                {
                    var c = ctx.Contents.FirstOrDefault(x => x.Id == post.Id);

                    c.Text = post.Text;
                    c.Name = post.Name;
                }
                return RedirectToAction("Index");
            }
            return View();
        }