public async Task <bool> ExistsCategory(Guid categoryId) { using (IBlogCategory blogcategorySvc = new BlogCategoryService()) { return(await blogcategorySvc.GetAll().AnyAsync(m => m.Id == categoryId)); } }
public async Task <int> RemoveCategory(Guid categoryId) //用户删除类别 { using (IBlogCategoryService blogCategoryService = new BlogCategoryService()) { var data = await blogCategoryService.GetAllAsync().FirstOrDefaultAsync(m => m.Id == categoryId); using (IArticleToCategoryService articleToCategorySvc = new ArticleToCategoryService()) { //var cate = await articleToCategorySvc.GetAllAsync() // .Include(m => m.BlogCategory) // .Where(m => m.BlogCategoryId == data.Id).ToListAsync(); //if (cate.Count==0) //如果文章类别没有相关的类别就执行删除,否则提示用户先删除文章对应的类别 //{ // await blogCategoryService.RemoveAsync(data); // return 1; //} //else //{ // return 0; //} await blogCategoryService.RemoveAsync(data); return(1); } } }
public async Task <BlogCategory> GetOneCategoryById(Guid categoryId) { using (IBlogCategory blogcategorySvc = new BlogCategoryService()) { return(await blogcategorySvc.GetOneByIdAsync(categoryId)); } }
public TrashController() { blogService = new BlogService(); postService = new BlogPostService(); categoryService = new BlogCategoryService(); friendService = new FriendService(); }
public async Task <int> GetCategoryDataCount(Guid id) { using (IBlogCategory blogCategorySvc = new BlogCategoryService()) { Guid allId = Guid.Parse("00000000-0000-0000-0000-000000000001"); return(await blogCategorySvc.GetAll().CountAsync(m => m.UserId == id || m.Id == allId)); } }
public PostController() { blogService = new BlogService(); postService = new BlogPostService(); categoryService = new BlogCategoryService(); friendService = new FriendService(); fileService = new UserFileService(); }
public MyListController() { blogService = new BlogService(); postService = new BlogPostService(); categoryService = new BlogCategoryService(); feedService = new FeedService(); friendService = new FriendService(); }
public LayoutController() { blogService = new BlogService(); postService = new BlogPostService(); categoryService = new BlogCategoryService(); rollService = new BlogrollService(); commentService = new CommentService <BlogPostComment>(); }
public async Task RemoveCategory(Guid categoryId) { using (IBlogCategory blogcategorySvc = new BlogCategoryService()) { BlogCategory blogcategory = await blogcategorySvc.GetOneByIdAsync(categoryId); await blogcategorySvc.DeleteAsync(blogcategory); } }
public async Task CreateCategory(string name, Guid userId) { using (IBlogCategory blogCategorySvc = new BlogCategoryService()) { await blogCategorySvc.CreatAsync(new BlogCategory() { UserId = userId, CategoryName = name }); } }
public async Task EditCategory(Guid categoryId, string newCategoryName) //修改类别 { using (IBlogCategoryService categorySvc = new BlogCategoryService()) { var cate = await categorySvc.GetAllAsync().FirstAsync(m => m.Id == categoryId); cate.CategoryName = newCategoryName; await categorySvc.EditAsync(cate); } }
public async Task CreateCategory(string name, Guid userID) { using (var categorySvc = new BlogCategoryService()) { await categorySvc.CreateAsync(new BlogCategory() { CategoryName = name, UserID = userID }); } }
public async Task <List <BlogCategoryDto> > GetAllCategories(Guid userID) { using (IDAL.IBlogCategoryService categoryService = new BlogCategoryService()) { return(await categoryService.GetAllAsync().Where(m => m.UserID == userID).Select(m => new Dto.BlogCategoryDto() { ID = m.ID, CategoryName = m.CategoryName }).ToListAsync()); } }
public async Task EditCategory(Guid categoryId, string newCategoryName) { using (IBlogCategory blogCategorySvc = new BlogCategoryService()) { //获取当前分类的实体,修改分类名字 var category = await blogCategorySvc.GetOneByIdAsync(categoryId); category.CategoryName = newCategoryName; await blogCategorySvc.EditAsync(category); } }
public async Task CreateCategory(string name, Guid UserId) //用户新增类别标签 { using (var categorySvc = new BlogCategoryService()) { await categorySvc.CreateAsync(new BlogCategory() { CategoryName = name, UserId = UserId }); } }
public async Task <List <BlogCategoryDto> > GetAllBlogcategory() //统计随笔 { using (IBlogCategoryService blogCategoryService = new BlogCategoryService()) { return(await blogCategoryService.GetAllAsync().Where(m => m.IsRemoved == false).Select(m => new BlogCategoryDto() { Id = m.Id, CategoryName = m.CategoryName }).ToListAsync()); } }
public async Task <BlogCategoryDto> GetOneCategoryByUser(Guid categoryId) //查询某一类别 { using (IBlogCategoryService blogCategoryService = new BlogCategoryService()) { return(await blogCategoryService.GetAllAsync().Where(m => m.Id == categoryId).Select(m => new BlogCategoryDto() { Id = m.Id, CategoryName = m.CategoryName }).FirstOrDefaultAsync()); } }
public MainController() { postService = new BlogPostService(); userService = new UserService(); pickedService = new PickedService(); sysblogService = new SysBlogService(); categoryService = new BlogCategoryService(); blogcommentService = new BlogCommentService(); HideLayout(typeof(LayoutController)); }
public async Task <List <BlogCategoryDto> > GetAllCategories(Guid userId) //根据用户查询文章类型 { using (IBlogCategoryService categorySvc = new BlogCategoryService()) { return(await categorySvc.GetAllAsync().Where(m => m.UserId == userId).Where(m => m.IsRemoved == false).Select(m => new BlogCategoryDto() { Id = m.Id, CategoryName = m.CategoryName, CreateTime = m.CreateTime }).ToListAsync()); } }
public async Task <List <BlogCategoryDto> > GetCategoriesByCount(Guid userId, int count) { using (IBlogCategory blogCategorySvc = new BlogCategoryService()) { Guid allId = Guid.Parse("00000000-0000-0000-0000-000000000001"); return(await blogCategorySvc.GetAll().Where(m => m.UserId == userId || m.Id == allId).Select(m => new BlogCategoryDto() { Id = m.Id, BlogCategoryName = m.CategoryName }).Take(count).ToListAsync()); } }
public RegisterController() { userService = new UserService(); confirmService = new UserConfirmService(); confirmEmail = new ConfirmEmail(); inviteService = new InviteService(); loginService = new LoginService(); friendService = new FriendService(); categoryService = new BlogCategoryService(); appService = new UserAppService(); menuService = new UserMenuService(); HidePermission(typeof(SecurityController)); }
public async Task <List <BlogCategoryDto> > GetAllCategoriesByUserId(Guid userId, int pageIndex, int pageSize) { using (IBlogCategory blogCategorySvc = new BlogCategoryService()) { Guid allId = Guid.Parse("00000000-0000-0000-0000-000000000001"); var data = await blogCategorySvc.GetAllByPageOrder(pageSize, pageIndex, m => m.UserId == userId || m.Id == allId, false).Select(m => new BlogCategoryDto() { Id = m.Id, BlogCategoryName = m.CategoryName, CreateTime = m.CreatTime }).ToListAsync(); using (IArticleToCategory articleToCategorySvc = new ArticleToCategoryService()) { foreach (var item in data) { item.ArticleCount = await articleToCategorySvc.GetAll().Where(m => m.BlogCategoryId == item.Id).CountAsync(); } } return(data); } }
public void WhenGetAll_ReturnResult() { var responseMock = new List <BlogCategory>(); responseMock.Add(new BlogCategory { Name = "Category Alpha" }); responseMock.Add(new BlogCategory { Name = "Category Beta" }); responseMock.Add(new BlogCategory { Name = "Category Gamma" }); var persistenceMock = new Mock <IBlogCategoryRepository>(); persistenceMock.Setup(p => p.GetAll()).Returns(responseMock); var service = new BlogCategoryService(persistenceMock.Object); var categories = service.GetAll(); Assert.NotNull(categories); Assert.Equal(3, categories.ToList().Count); }
public CategoryController() { postService = new BlogPostService(); categoryService = new BlogCategoryService(); }