public async Task <GetOrganizationMembersResponse> Get(GetOrganizationMembers request) { if (request.Id <= 0) { throw new ArgumentNullException(nameof(request.Id)); } PostServicesBase.AssertCanViewOrganization(Db, request.Id, SessionAs <AuthUserSession>(), out _, out _); return(new GetOrganizationMembersResponse { OrganizationId = request.Id, Results = await Db.SelectAsync <OrganizationMember>(x => x.OrganizationId == request.Id), }); }
private async Task <GetOrganizationResponse> GetOrganization(Organization organization) { PostServicesBase.AssertCanViewOrganization(Db, organization, SessionAs <AuthUserSession>(), out _); var members = await Db.SelectAsync <OrganizationMember>(x => x.OrganizationId == organization.Id && (x.IsOwner || x.IsModerator)); return(new GetOrganizationResponse { Cache = Stopwatch.GetTimestamp(), Id = organization.Id, Slug = organization.Slug, Organization = organization, Labels = await Db.SelectAsync <OrganizationLabel>(x => x.OrganizationId == organization.Id), Categories = (await Db.SelectAsync <Category>(x => x.OrganizationId == organization.Id && x.Deleted == null)).OrderBy(x => x.Name).ToList(), Owners = members.Where(x => x.IsOwner).ToList(), Moderators = members.Where(x => x.IsModerator).ToList(), MembersCount = PostServicesBase.GetOrganizationMembersCount(organization.Id), //display only, can be stale }); }