Browse Source
* Made changes to organization details endpoint * Fixed formatting * Added script to utils directorypull/2041/head
9 changed files with 123 additions and 7 deletions
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using Core.Models.Data; |
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries |
||||
{ |
||||
public class CipherOrganizationDetailsReadByOrgizationIdQuery : IQuery<CipherOrganizationDetails> |
||||
{ |
||||
private readonly Guid _organizationId; |
||||
|
||||
public CipherOrganizationDetailsReadByOrgizationIdQuery(Guid organizationId) |
||||
{ |
||||
_organizationId = organizationId; |
||||
} |
||||
public virtual IQueryable<CipherOrganizationDetails> Run(DatabaseContext dbContext) |
||||
{ |
||||
var query = from c in dbContext.Ciphers |
||||
join o in dbContext.Organizations |
||||
on c.OrganizationId equals o.Id into o_g |
||||
from o in o_g.DefaultIfEmpty() |
||||
where c.OrganizationId == _organizationId |
||||
select new CipherOrganizationDetails |
||||
{ |
||||
Id = c.Id, |
||||
UserId = c.UserId, |
||||
OrganizationId = c.OrganizationId, |
||||
Type = c.Type, |
||||
Data = c.Data, |
||||
Favorites = c.Favorites, |
||||
Folders = c.Folders, |
||||
Attachments = c.Attachments, |
||||
CreationDate = c.CreationDate, |
||||
RevisionDate = c.RevisionDate, |
||||
DeletedDate = c.DeletedDate, |
||||
OrganizationUseTotp = o.UseTotp, |
||||
}; |
||||
return query; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadByOrganizationId] |
||||
@OrganizationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
C.*, |
||||
CASE |
||||
WHEN O.[UseTotp] = 1 THEN 1 |
||||
ELSE 0 |
||||
END [OrganizationUseTotp] |
||||
FROM |
||||
[dbo].[CipherView] C |
||||
LEFT JOIN |
||||
[dbo].[OrganizationView] O ON O.[Id] = C.[OrganizationId] |
||||
WHERE |
||||
C.[OrganizationId] = @OrganizationId |
||||
END |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
--CipherOrganizationDetails_ReadByOrganizationId |
||||
IF OBJECT_ID('[dbo].[CipherOrganizationDetails_ReadByOrganizationId]') IS NOT NULL |
||||
BEGIN |
||||
DROP PROCEDURE [dbo].[CipherOrganizationDetails_ReadByOrganizationId] |
||||
END |
||||
GO |
||||
|
||||
CREATE PROCEDURE [dbo].[CipherOrganizationDetails_ReadByOrganizationId] |
||||
@OrganizationId UNIQUEIDENTIFIER |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
SELECT |
||||
C.*, |
||||
CASE |
||||
WHEN O.[UseTotp] = 1 THEN 1 |
||||
ELSE 0 |
||||
END [OrganizationUseTotp] |
||||
FROM |
||||
[dbo].[CipherView] C |
||||
LEFT JOIN |
||||
[dbo].[OrganizationView] O ON O.[Id] = C.[OrganizationId] |
||||
WHERE |
||||
C.[OrganizationId] = @OrganizationId |
||||
END |
||||
GO |
||||
Loading…
Reference in new issue