Пример #1
0
 public ICategoryDto Create(Domain.Category category)
 {
     Dbos.Category c = new Dbos.Category {
         Name        = category.Name,
         Description = category.Description,
         SortOrder   = category.SortOrder
     };
     return(this.datastore.CreateCategory(c).ToDto());
 }
Пример #2
0
        public IForumDto Create(Domain.Forum forum)
        {
            Dbos.Category cat = this.datastore.ReadCategoryById(ObjectId.Parse(forum.CategoryId));
            if (cat == null)
            {
                // TODO ??
                throw new ArgumentException("Parent category not found");
            }

            Dbos.Forum f = new Dbos.Forum {
                Name        = forum.Name,
                Description = forum.Description,
                SortOrder   = forum.SortOrder,
                Category    = new CategoryRef {
                    Id   = cat.Id,
                    Name = cat.Name
                },
                Path = new ObjectId[] { }
            };

            if (!String.IsNullOrWhiteSpace(forum.ParentForumId))
            {
                Dbos.Forum parentForum = this.datastore.ReadForumById(ObjectId.Parse(forum.ParentForumId));
                if (parentForum == null)
                {
                    // TODO ??
                    throw new ArgumentException("Parent forum not found");
                }

                f.ParentForum = new ForumRef {
                    Id   = parentForum.Id,
                    Name = parentForum.Name
                };
                f.Path = parentForum.Path.Union(new ObjectId[] { parentForum.Id }).ToArray();
            }

            return(this.datastore.CreateForum(f).ToDto());
        }
Пример #3
0
 public virtual Dbos.Category CreateCategory(Dbos.Category category)
 {
     this.categories.InsertOne(category);
     return(category);
 }