Пример #1
0
        public ActionResult CreateBlog(BlogEntry model)
        {
            model.DatePosted = DateTime.Now;
            model.LastEdited = DateTime.Now;
            model.Author = Session["name"].ToString();//Db.CurrentBlogger.FirstName + " " + Db.CurrentBlogger.LastName;
            model.AuthorId = Session["userid"].ToString();
            Db.BlogEntries.Add(model);

            Db.SaveChanges();
            return RedirectToAction("BlogIndex", new { id = model.Id });
        }
Пример #2
0
        public ActionResult EditBlog(BlogEntry model)
        {
            BlogEntry entry = Db.BlogEntries.Where(b => b.Id == model.Id).FirstOrDefault();

            if (entry != null)
            {
                entry.LastEdited = DateTime.Now;

                entry.Title = model.Title;
                entry.Content = model.Content;
                entry.isAcceptingComments = model.isAcceptingComments;
                entry.isVisible = model.isVisible;

                Db.Entry(entry).State = System.Data.Entity.EntityState.Modified;
                Db.SaveChanges();
            }
            return RedirectToAction("BlogIndex", new { id = model.Id });
        }