1
0
mirror of https://github.com/bitwarden/server synced 2025-12-11 22:03:38 +00:00
Files
server/src/Infrastructure.EntityFramework/AdminConsole/Repositories/Queries/OrganizationUserReadCountByFreeOrganizationAdminUserQuery.cs
Thomas Rittson 09d07d864e [AC-1751] AC Team code ownership moves: OrganizationUser (part 1) (#3487)
* Move OrganizationUser domain to AC Team ownership

* Namespaces will be updated in a separate commit
2023-11-30 07:04:56 +10:00

29 lines
996 B
C#

using Bit.Core.Enums;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class OrganizationUserReadCountByFreeOrganizationAdminUserQuery : IQuery<OrganizationUser>
{
private readonly Guid _userId;
public OrganizationUserReadCountByFreeOrganizationAdminUserQuery(Guid userId)
{
_userId = userId;
}
public IQueryable<OrganizationUser> Run(DatabaseContext dbContext)
{
var query = from ou in dbContext.OrganizationUsers
join o in dbContext.Organizations
on ou.OrganizationId equals o.Id
where ou.UserId == _userId &&
(ou.Type == OrganizationUserType.Owner || ou.Type == OrganizationUserType.Admin) &&
o.PlanType == PlanType.Free &&
ou.Status == OrganizationUserStatusType.Confirmed
select ou;
return query;
}
}