Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,Name,Controller,Action,CreateTime,IsRemove")] SideBars sideBars)
        {
            if (ModelState.IsValid)
            {
                sideBars.Id = Guid.NewGuid();
                db.sideBars.Add(sideBars);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sideBars));
        }
Ejemplo n.º 2
0
 public void SaveCategories(BlogContent blog)
 {
     if (blog.Category.ToList().Count == 0)
     {
         List <Category> categories = new List <Category>
         {
             new Category {
                 Name = "Terror"
             },
             new Category {
                 Name = "Romance"
             },
             new Category {
                 Name = "Accion"
             },
             new Category {
                 Name = "Comedia"
             },
             new Category {
                 Name = "Misterio"
             },
         };
         blog.Category.AddRange(categories);
         blog.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public ActionResult Delete(Post post)
 {
     using (var blog = new BlogContent())
     {
         Post pos = blog.Post.Find(post.Id);
         blog.Post.Remove(pos);
         blog.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Ejemplo n.º 4
0
 public ActionResult Detail(DetailVM detail)
 {
     using (var blog = new BlogContent())
     {
         detail.comment.Date   = DateTime.Now;
         detail.comment.IdPost = detail.post.Id;
         blog.Comment.Add(detail.comment);
         blog.SaveChanges();
     }
     return(Detail(detail.post.Id));
 }
Ejemplo n.º 5
0
 public ActionResult ManagePost(Post post)
 {
     if (ModelState.IsValid)
     {
     }
     using (var blog = new BlogContent())
     {
         if (post.Id == 0)
         {
             post.Date = DateTime.Now;
             blog.Post.Add(post);
         }
         else
         {
             Post _post = blog.Post.Find(post.Id);
             _post.Title      = post.Title;
             _post.IdCategory = post.IdCategory;
             _post.Content    = post.Content;
         }
         blog.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }