Files
server/src/Infrastructure.EntityFramework/Repositories/Queries/ProviderOrganizationOrganizationDetailsReadByProviderIdQuery.cs
Rui Tomé 9e7741d58b [EC-1014] Create Organization Status (Pending/Created) (#2610)
* [EC-427] Add columns 'Type' and 'BillingPhone' to Provider table

* [EC-427] Provider table Type and BillingPhone MySql migrations

* [EC-427] Provider table Type and BillingPhone Postgres migrations

* [EC-427] Add mysql migration script

* [EC-427] Add mysql migration script

* [EC-427] Updated Provider sql script to include default column value

* [EC-427] Removed default value from Provider.Type column

* [EC-427] Changed migration script to include a default value constraint instead of updating the null type

* [EC-427] Updated Sql project Provider table script

* [EC-427] Changed migration script to use 'Create OR Alter' for views and sprocs

* [EC-427] Added default values for 'BillingPhone' and 'Type' fields on sprocs [dbo].[Provider_Create] and [dbo].[Provider_Update]

* [EC-427] Adjusting metadata in migration script

* [EC-427] Updated Provider sprocs SQL script files

* [EC-427] Fixed migration script

* [EC-427] Added sqlite migration

* [EC-427] Add missing Provider_Update sproc default value

* [EC-427] Added missing GO action to migration script

* [EC-428] Redirect to Edit after creating Provider

* Revert "[EC-428] Redirect to Edit after creating Provider"

This reverts commit 6347bca1ed.

* [EC-1014] Create OrganizationStatusType and add Status column to Organizations table

* [EC-1014] Added EF migrations

* [EC-1014] dotnet format

* [EC-1014] Changed Organization.Status from SMALLINT to TINYINT

* [EC-1014] Set Organization.Status default value = 1

* [EC-1014] Setting Organization.Status default value as 1
2023-02-01 10:45:40 +00:00

39 lines
1.5 KiB
C#

using Bit.Core.Models.Data;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class ProviderOrganizationOrganizationDetailsReadByProviderIdQuery : IQuery<ProviderOrganizationOrganizationDetails>
{
private readonly Guid _providerId;
public ProviderOrganizationOrganizationDetailsReadByProviderIdQuery(Guid providerId)
{
_providerId = providerId;
}
public IQueryable<ProviderOrganizationOrganizationDetails> Run(DatabaseContext dbContext)
{
var query = from po in dbContext.ProviderOrganizations
join o in dbContext.Organizations
on po.OrganizationId equals o.Id
join ou in dbContext.OrganizationUsers
on po.OrganizationId equals ou.OrganizationId
where po.ProviderId == _providerId
select new { po, o };
return query.Select(x => new ProviderOrganizationOrganizationDetails()
{
Id = x.po.Id,
ProviderId = x.po.ProviderId,
OrganizationId = x.po.OrganizationId,
OrganizationName = x.o.Name,
Key = x.po.Key,
Settings = x.po.Settings,
CreationDate = x.po.CreationDate,
RevisionDate = x.po.RevisionDate,
UserCount = x.o.OrganizationUsers.Count(ou => ou.Status == Core.Enums.OrganizationUserStatusType.Confirmed),
Seats = x.o.Seats,
Plan = x.o.Plan,
Status = x.o.Status
});
}
}