Example #1
0
        public ActionResult Save()
        {
            Blog blog;
            var  blogId = Request.Form["blogId"];

            if (blogId != "0")
            {
                blog = BlogModel.GetBlog(Convert.ToInt64(blogId));
            }
            else
            {
                blog = new Blog();
            }

            blog.Title = Request.Form["blogTitle"];
            List <int> sortInts = new List <int>();

            foreach (string key in Request.Form.AllKeys)
            {
                if (key.Contains("ck|") && Request.Form[key] == "true,false")
                {
                    int id = Convert.ToInt32(key.Split('|')[1]);
                    sortInts.Add(id);
                    BlogSort sort = BlogModel.GetBlogSort(id);
                    blog.Sorts.Add(sort);
                }
            }

            blog.Content    = Request.Unvalidated.Form["ckeditor"];
            blog.CreateTime = DateTime.Now;
            //TODO:标签与博客是多对多功能
            blog.UserId = 1;
            BlogModel.AddblBlog(blog);
            return(RedirectToAction("Post", "Home", new{ id = blog.BlogId }));
        }
Example #2
0
        public ActionResult Tag(int id)
        {
            List <Blog> blogs = BlogModel.GetBlogs(id);
            var         tag   = BlogModel.GetBlogSort(id);

            if (tag != null)
            {
                ViewData["tag"] = tag.SortName;
            }

            return(View("Index", blogs));
        }