示例#1
0
文件: Category.cs 项目: LByron/BS
 public int AddCategory(CategoryEntity entity)
 {
     if (entity != null)
     {
         _categoriesTable.InsertOnSubmit(entity);
         context.SubmitChanges();
         return entity.CategoryID;
     }
     return -1;
 }
示例#2
0
文件: MockCategory.cs 项目: LByron/BS
        public List<CategoryEntity> GetCategoriesByPostID(int postID)
        {
            var categoriesEntities = new List<CategoryEntity>();
            var allCategories = GetCategories();
            var postCategoryMappings = _postCategoryMapping.Where(m => m.PostID == postID).ToList();

            postCategoryMappings.ForEach(mapping =>
            {
                var category = allCategories.Single(c => c.CategoryID == mapping.CategoryID);
                var categoryEntity = new CategoryEntity { CategoryID = mapping.CategoryID, CategoryName = category.CategoryName, CategorySlug = category.CategorySlug };
                categoriesEntities.Add(categoryEntity);
            });

            return categoriesEntities;
        }
 private CategoryEntity AddCategoryInternal(string categoryName)
 {
     var finalCategoryName = categoryName;
     if (finalCategoryName != null)
         finalCategoryName = finalCategoryName.Trim();
     var allCategories = _categoryRepository.GetCategories();
     if (!string.IsNullOrEmpty(finalCategoryName) && allCategories.SingleOrDefault(c => c.CategoryName.ToLower() == finalCategoryName.ToLower()) == null)
     {
         var categories = allCategories.Select(c => c.CategorySlug).ToList();
         var categorySlug = finalCategoryName.GetUniqueSlug(categories);
         var entity = new CategoryEntity {CategoryName = finalCategoryName, CategorySlug = categorySlug};
         entity.CategoryID = _categoryRepository.AddCategory(entity);
         return entity;
     }
     return null;
 }
示例#4
0
文件: MockCategory.cs 项目: LByron/BS
 public int AddCategory(CategoryEntity entity)
 {
     throw new NotImplementedException();
 }