Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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);
        }