示例#1
0
        public async Task <CommunityViewModel> GetCommunityByNameAsync(string communityName)
        {
            var community = await _communityRepository.GetByConditionAsync <CommunityViewModel>(
                x => x.Name == communityName,
                CommunityHelpers.GetCommunityMapperConfiguration());

            Guard.Against.NullItem(community, nameof(community));

            return(community);
        }
示例#2
0
        public async Task <IEnumerable <CommunityViewModel> > GetCommunitiesAsync(CommunitySearchParams searchParams)
        {
            User user = await _userManager.FindByIdAsync(searchParams.UserId);

            Guard.Against.NullItem(user, nameof(user));

            var specification = new CommunityFilterSpecification(searchParams);

            return(await _communityRepository.ListAsync <CommunityViewModel>(specification,
                                                                             CommunityHelpers.GetCommunityMapperConfiguration()));
        }