public async Task <BlogCategory> GetOneCategoryById(Guid categoryId) { using (IBlogCategory blogcategorySvc = new BlogCategoryService()) { return(await blogcategorySvc.GetOneByIdAsync(categoryId)); } }
public async Task RemoveCategory(Guid categoryId) { using (IBlogCategory blogcategorySvc = new BlogCategoryService()) { BlogCategory blogcategory = await blogcategorySvc.GetOneByIdAsync(categoryId); await blogcategorySvc.DeleteAsync(blogcategory); } }
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); } }