1
0
mirror of https://github.com/bitwarden/server synced 2025-12-17 16:53:23 +00:00

Turn on file scoped namespaces (#2225)

This commit is contained in:
Justin Baur
2022-08-29 14:53:16 -04:00
committed by GitHub
parent 7c4521e0b4
commit 34fb4cca2a
1206 changed files with 73816 additions and 75022 deletions

View File

@@ -1,69 +1,68 @@
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class GroupUserUpdateGroupsQuery
{
public class GroupUserUpdateGroupsQuery
public readonly GroupUserUpdateGroupsInsertQuery Insert;
public readonly GroupUserUpdateGroupsDeleteQuery Delete;
public GroupUserUpdateGroupsQuery(Guid organizationUserId, IEnumerable<Guid> groupIds)
{
public readonly GroupUserUpdateGroupsInsertQuery Insert;
public readonly GroupUserUpdateGroupsDeleteQuery Delete;
public GroupUserUpdateGroupsQuery(Guid organizationUserId, IEnumerable<Guid> groupIds)
{
Insert = new GroupUserUpdateGroupsInsertQuery(organizationUserId, groupIds);
Delete = new GroupUserUpdateGroupsDeleteQuery(organizationUserId, groupIds);
}
}
public class GroupUserUpdateGroupsInsertQuery : IQuery<GroupUser>
{
private readonly Guid _organizationUserId;
private readonly IEnumerable<Guid> _groupIds;
public GroupUserUpdateGroupsInsertQuery(Guid organizationUserId, IEnumerable<Guid> collections)
{
_organizationUserId = organizationUserId;
_groupIds = collections;
}
public IQueryable<GroupUser> Run(DatabaseContext dbContext)
{
var orgUser = from ou in dbContext.OrganizationUsers
where ou.Id == _organizationUserId
select ou;
var groupIdEntities = dbContext.Groups.Where(x => _groupIds.Contains(x.Id));
var query = from g in dbContext.Groups
join ou in orgUser
on g.OrganizationId equals ou.OrganizationId
join gie in groupIdEntities
on g.Id equals gie.Id
where !dbContext.GroupUsers.Any(gu => _groupIds.Contains(gu.GroupId) && gu.OrganizationUserId == _organizationUserId)
select g;
return query.Select(x => new GroupUser
{
GroupId = x.Id,
OrganizationUserId = _organizationUserId,
});
}
}
public class GroupUserUpdateGroupsDeleteQuery : IQuery<GroupUser>
{
private readonly Guid _organizationUserId;
private readonly IEnumerable<Guid> _groupIds;
public GroupUserUpdateGroupsDeleteQuery(Guid organizationUserId, IEnumerable<Guid> groupIds)
{
_organizationUserId = organizationUserId;
_groupIds = groupIds;
}
public IQueryable<GroupUser> Run(DatabaseContext dbContext)
{
var deleteQuery = from gu in dbContext.GroupUsers
where gu.OrganizationUserId == _organizationUserId &&
!_groupIds.Any(x => gu.GroupId == x)
select gu;
return deleteQuery;
}
Insert = new GroupUserUpdateGroupsInsertQuery(organizationUserId, groupIds);
Delete = new GroupUserUpdateGroupsDeleteQuery(organizationUserId, groupIds);
}
}
public class GroupUserUpdateGroupsInsertQuery : IQuery<GroupUser>
{
private readonly Guid _organizationUserId;
private readonly IEnumerable<Guid> _groupIds;
public GroupUserUpdateGroupsInsertQuery(Guid organizationUserId, IEnumerable<Guid> collections)
{
_organizationUserId = organizationUserId;
_groupIds = collections;
}
public IQueryable<GroupUser> Run(DatabaseContext dbContext)
{
var orgUser = from ou in dbContext.OrganizationUsers
where ou.Id == _organizationUserId
select ou;
var groupIdEntities = dbContext.Groups.Where(x => _groupIds.Contains(x.Id));
var query = from g in dbContext.Groups
join ou in orgUser
on g.OrganizationId equals ou.OrganizationId
join gie in groupIdEntities
on g.Id equals gie.Id
where !dbContext.GroupUsers.Any(gu => _groupIds.Contains(gu.GroupId) && gu.OrganizationUserId == _organizationUserId)
select g;
return query.Select(x => new GroupUser
{
GroupId = x.Id,
OrganizationUserId = _organizationUserId,
});
}
}
public class GroupUserUpdateGroupsDeleteQuery : IQuery<GroupUser>
{
private readonly Guid _organizationUserId;
private readonly IEnumerable<Guid> _groupIds;
public GroupUserUpdateGroupsDeleteQuery(Guid organizationUserId, IEnumerable<Guid> groupIds)
{
_organizationUserId = organizationUserId;
_groupIds = groupIds;
}
public IQueryable<GroupUser> Run(DatabaseContext dbContext)
{
var deleteQuery = from gu in dbContext.GroupUsers
where gu.OrganizationUserId == _organizationUserId &&
!_groupIds.Any(x => gu.GroupId == x)
select gu;
return deleteQuery;
}
}