コード例 #1
0
        public ActionResult AddBlog(AddBlogViewModel addBlogViewModel)
        {
            Response response = new Response()
            {
                Code = 0
            };
            Blog blog;

            if (ModelState.IsValid)
            {
                var category = categoryManager.Find(addBlogViewModel.CategoryId);
                if (category == null || category.Type != CategoryType.General)
                {
                    response.Message = "栏目不匹配或者未找到!";
                    return(Json(response));
                }
                if (blogManager.Find(b => b.Title == addBlogViewModel.Title) != null)
                {
                    response.Message = "标题重复了!";
                    return(Json(response));
                }
                blog          = Mapper.Map <Blog>(addBlogViewModel);
                blog.Category = category;
                response      = blogManager.AddBlog(blog);
            }
            else
            {
                response.Message = "输入不合法!";
            }
            return(Json(response));
        }
コード例 #2
0
        public void Start()
        {
            modelBuilderManager.AddBlog("http://test.com");

            var blogs = modelBuilderManager.GetBlogs();

            Console.WriteLine(blogs.Count.ToString());
        }
コード例 #3
0
 public void Start()
 {
     modelBuilderManager.AddBlog("http://test.com");
 }