public Forum CreateForum(String categoryId, String forumId, String name, Int32 sortOrder, String description) { Guid id; if (!Guid.TryParse(categoryId, out id)) { throw new ArgumentException(nameof(categoryId)); } if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } Dbos.Forum parentForum = null; if (!String.IsNullOrWhiteSpace(forumId)) { Guid parentForumId; if (!Guid.TryParse(forumId, out parentForumId)) { throw new ArgumentException(nameof(forumId)); } parentForum = this.forumRepository.FindById(parentForumId); } Dbos.Category parent = this.categoryRepository.FindById(id); if (parent == null) { throw new ArgumentException(nameof(categoryId)); } return(this.CreateForum(parent, parentForum, name, sortOrder, description)); }
public static Category ToModel(this Dbos.Category category) { return(new Category { Id = category.Id.ToString(), Name = category.Name, Description = category.Description, SortOrder = category.SortOrder, CustomData = category.CustomData }); }
public Category FindCategoryById(String categoryId) { Guid id; if (!Guid.TryParse(categoryId, out id)) { throw new ArgumentException(nameof(categoryId)); } Dbos.Category category = this.categoryRepository.FindById(id); return(category.ToModel()); }
public Category CreateCategory(String name, Int32 sortOrder, String description) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } Dbos.Category model = this.categoryRepository.Create(new Dbos.Category { Name = name, SortOrder = sortOrder, Description = description }); return(model.ToModel()); }
private static void PopulatedLevel0(Dbos.Category c, Category cat) { List <Forum> forums = new List <Forum>(); c.Forums.Where(f => f.Level == 0).ToList().ForEach(f => { Forum forum = f.ToModel(); forum.Category = cat; PopulateLevel1(cat, f, forum); forums.Add(forum); }); cat.Forums = forums; }
public Category UpdateCategory(String categoryId, String name, Int32 sortOrder, String description) { Guid id; if (!Guid.TryParse(categoryId, out id)) { throw new ArgumentException(nameof(categoryId)); } Dbos.Category category = this.categoryRepository.FindById(id); category.Name = name; category.SortOrder = sortOrder; category.Description = description; category = this.categoryRepository.Update(category); return(category.ToModel()); }
private Forum CreateForum(Dbos.Category category, Dbos.Forum parentForum, String name, Int32 sortOrder, String description) { Dbos.Forum newForum = new Dbos.Forum { CategoryId = category.Id, Name = name, SortOrder = sortOrder, Description = description, Level = 0 }; if (parentForum != null) { newForum.ParentForumId = parentForum.Id; newForum.Level = parentForum.Level + 1; } Dbos.Forum model = this.forumRepository.Create(newForum); return(model.ToModel()); }
public Category FindCategoryPlus2Levels(String categoryId) { Guid id; if (!Guid.TryParse(categoryId, out id)) { throw new ArgumentException(nameof(categoryId)); } Dbos.Category category = this.categoryRepository.FindAll() .Include(c => c.Forums) .SingleOrDefault(c => c.Id == id); Category output = category.ToModel(); PopulatedLevel0(category, output); return(output); }