コード例 #1
0
        private ActionResult Edit(string hexId, bool isMd)
        {
            EditViewModel vm = new EditViewModel()
            {
                MarkDown = isMd?"Y":"N"
            };

            if (string.IsNullOrEmpty(hexId))
            {
                if (isMd)
                {
                    vm.Content = FileHelper.GetString(Server.MapPath("~/Plugins/editormd/template.md"));
                }
            }
            else
            {
                long blogId = Convert.ToInt64(Helper.FromHex(hexId));
                Blog blog   = this._blogService.GetEntityByID(blogId);
                if (blog == null)
                {
                    throw new NotFoundException("找不到当前文章!");
                }
                vm            = MapperManager.Map <EditViewModel>(blog);
                vm.PersonTags = blog.BlogTags;
                vm.HexId      = hexId;
                if (!string.IsNullOrEmpty(blog.BlogTags))
                {
                    Dictionary <long, string> tagDic = new Dictionary <long, string>();
                    string[] tagArr = blog.BlogTags.Split(',');
                    foreach (string tagId in tagArr)
                    {
                        BlogTag blogTag = _tagService.GetEntityByID(Convert.ToInt32(tagId));
                        if (blogTag != null)
                        {
                            tagDic.Add(blogTag.Id, blogTag.Name);
                        }
                    }
                    ViewBag.PersonTags = tagDic;
                }
            }
            if (string.IsNullOrEmpty(vm.PersonTags))
            {
                vm.PersonTags = "";
            }
            IBlogTypeService       typeService = ContainerManager.Resolve <IBlogTypeService>();
            ICategoryService       cateService = ContainerManager.Resolve <ICategoryService>();
            IEnumerable <Category> categories  = cateService.GetEntities(c => true).
                                                 OrderByDescending(c => c.Order);
            IEnumerable <BlogType> types = typeService.GetEntities(t => true).
                                           OrderByDescending(t => t.Order);
            IEnumerable <BlogTag> tags = _tagService.GetEntities(t => t.UserId == UserContext.LoginUser.Id);

            ViewBag.Categories = categories;
            ViewBag.Types      = types;
            ViewBag.Tags       = tags;
            return(View(vm));
        }
コード例 #2
0
 public BlogTypeController(
     IBlogTypeService _BlogTypeService
     )
 {
     this.BlogTypeService = _BlogTypeService;
 }