Beispiel #1
0
        public ContentViewModel Create(ContentRequest request)
        {
            Authorized();

            var content = new Content();

            content.Title    = request.Title;
            content.Body     = request.Body;
            content.HtmlBody = Markdown.Encode(content.Body);
            content.UserId   = user.Id;
            content.Type     = request.Type;
            var id = ContentApi.Insert(content);

            TagManager.SetTagsForContent(id, request.Tags);

            if (request.ParentId != null)
            {
                ContentApi.Relate(request.ParentId.Value, id);
            }

            return(ContentApi.Select(id).AsViewModel()
                   .WithChildren()
                   .WithChildrenCount()
                   .WithTags());
        }
Beispiel #2
0
        public ContentViewModel Create(ContentRequest request)
        {
            Authorized();

            var content = new Content();

            content.Title    = request.Title;
            content.Body     = request.Body;
            content.HtmlBody = Markdown.Encode(content.Body);
            content.UserId   = user.Id;
            content.Type     = request.Type;
            var id = ContentApi.Insert(content);

            TagManager.SetTagsForContent(id, request.Tags);

            if (request.ParentId != null)
            {
                ContentApi.Relate(request.ParentId.Value, id);
            }

            var item = ContentApi.Select(id).AsViewModel()
                       .WithChildren()
                       .WithChildrenCount()
                       .WithUser()
                       .WithTags();

            Searcher.Instance.Index(new Searchable()
            {
                Id = id, Type = item.Type, Title = item.Title, Body = item.Body, Username = item.User.DisplayName
            });
            ContentApi.MarkAsIndexed(id);
            return(item);
        }
Beispiel #3
0
 private void AddRelation(int parentId, int childId)
 {
     ContentApi.Relate(parentId, childId);
 }