GroupCategoryService.cs 1.2 KB

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Repository.Interface.Group;
  4. using GxPress.Result.Web;
  5. using GxPress.Service.Interface.GroupCategory;
  6. namespace GxPress.Service.Implement.GroupCategory
  7. {
  8. public class GroupCategoryService : IGroupCategoryService
  9. {
  10. private readonly IGroupCategoryRepository GroupCategoryRepository;
  11. private readonly IUserGroupCategoryRepository userGroupCategoryRepository;
  12. public GroupCategoryService(IGroupCategoryRepository GroupCategoryRepository, IUserGroupCategoryRepository userGroupCategoryRepository)
  13. {
  14. this.GroupCategoryRepository = GroupCategoryRepository;
  15. this.userGroupCategoryRepository = userGroupCategoryRepository;
  16. }
  17. public async Task<IEnumerable<GroupCategoryResult>> GetGroupCategoryAsync(int parentId, int userId)
  18. {
  19. if (userId > 0)
  20. {
  21. if (await userGroupCategoryRepository.IsExistsAsync(userId))
  22. {
  23. return await GroupCategoryRepository.GetUsergroupCategoryResult(userId);
  24. }
  25. }
  26. return await GroupCategoryRepository.GetAllAsync(parentId);
  27. }
  28. }
  29. }