From 5d595d4cf908f95fb5633a4c77a67aa782b5522c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 12 May 2017 14:02:33 -0400 Subject: [PATCH] group external id --- src/Core/Models/Api/Request/GroupRequestModel.cs | 2 ++ src/Core/Models/Api/Response/GroupResponseModel.cs | 2 ++ src/Core/Models/Table/Group.cs | 1 + src/Sql/dbo/Stored Procedures/Group_Create.sql | 3 +++ src/Sql/dbo/Stored Procedures/Group_CreateWithCollections.sql | 3 ++- src/Sql/dbo/Stored Procedures/Group_Update.sql | 2 ++ src/Sql/dbo/Stored Procedures/Group_UpdateWithCollections.sql | 3 ++- src/Sql/dbo/Tables/Group.sql | 1 + 8 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Core/Models/Api/Request/GroupRequestModel.cs b/src/Core/Models/Api/Request/GroupRequestModel.cs index d5366f8d3e..9e1884cb84 100644 --- a/src/Core/Models/Api/Request/GroupRequestModel.cs +++ b/src/Core/Models/Api/Request/GroupRequestModel.cs @@ -13,6 +13,7 @@ namespace Bit.Core.Models.Api public string Name { get; set; } [Required] public bool? AccessAll { get; set; } + public string ExternalId { get; set; } public IEnumerable Collections { get; set; } public Group ToGroup(Guid orgId) @@ -27,6 +28,7 @@ namespace Bit.Core.Models.Api { existingGroup.Name = Name; existingGroup.AccessAll = AccessAll.Value; + existingGroup.ExternalId = ExternalId; return existingGroup; } } diff --git a/src/Core/Models/Api/Response/GroupResponseModel.cs b/src/Core/Models/Api/Response/GroupResponseModel.cs index 39d4dc8538..71f9b5b26c 100644 --- a/src/Core/Models/Api/Response/GroupResponseModel.cs +++ b/src/Core/Models/Api/Response/GroupResponseModel.cs @@ -20,12 +20,14 @@ namespace Bit.Core.Models.Api OrganizationId = group.OrganizationId.ToString(); Name = group.Name; AccessAll = group.AccessAll; + ExternalId = group.ExternalId; } public string Id { get; set; } public string OrganizationId { get; set; } public string Name { get; set; } public bool AccessAll { get; set; } + public string ExternalId { get; set; } } public class GroupDetailsResponseModel : GroupResponseModel diff --git a/src/Core/Models/Table/Group.cs b/src/Core/Models/Table/Group.cs index b8e8b5b2f8..e914fcd59a 100644 --- a/src/Core/Models/Table/Group.cs +++ b/src/Core/Models/Table/Group.cs @@ -9,6 +9,7 @@ namespace Bit.Core.Models.Table public Guid OrganizationId { get; set; } public string Name { get; set; } public bool AccessAll { get; set; } + public string ExternalId { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; diff --git a/src/Sql/dbo/Stored Procedures/Group_Create.sql b/src/Sql/dbo/Stored Procedures/Group_Create.sql index 1ae1ba3ddf..21ccd13869 100644 --- a/src/Sql/dbo/Stored Procedures/Group_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Group_Create.sql @@ -3,6 +3,7 @@ @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @AccessAll BIT, + @ExternalId NVARCHAR(50), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) AS @@ -15,6 +16,7 @@ BEGIN [OrganizationId], [Name], [AccessAll], + [ExternalId], [CreationDate], [RevisionDate] ) @@ -24,6 +26,7 @@ BEGIN @OrganizationId, @Name, @AccessAll, + @ExternalId, @CreationDate, @RevisionDate ) diff --git a/src/Sql/dbo/Stored Procedures/Group_CreateWithCollections.sql b/src/Sql/dbo/Stored Procedures/Group_CreateWithCollections.sql index be3787c75f..6fa8d1ed34 100644 --- a/src/Sql/dbo/Stored Procedures/Group_CreateWithCollections.sql +++ b/src/Sql/dbo/Stored Procedures/Group_CreateWithCollections.sql @@ -3,6 +3,7 @@ @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @AccessAll BIT, + @ExternalId NVARCHAR(50), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7), @Collections AS [dbo].[SelectionReadOnlyArray] READONLY @@ -10,7 +11,7 @@ AS BEGIN SET NOCOUNT ON - EXEC [dbo].[Group_Create] @Id, @OrganizationId, @Name, @AccessAll, @CreationDate, @RevisionDate + EXEC [dbo].[Group_Create] @Id, @OrganizationId, @Name, @AccessAll, @ExternalId, @CreationDate, @RevisionDate ;WITH [AvailableCollectionsCTE] AS( SELECT diff --git a/src/Sql/dbo/Stored Procedures/Group_Update.sql b/src/Sql/dbo/Stored Procedures/Group_Update.sql index 846d8a237f..b54d09c520 100644 --- a/src/Sql/dbo/Stored Procedures/Group_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Group_Update.sql @@ -3,6 +3,7 @@ @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @AccessAll BIT, + @ExternalId NVARCHAR(50), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) AS @@ -15,6 +16,7 @@ BEGIN [OrganizationId] = @OrganizationId, [Name] = @Name, [AccessAll] = @AccessAll, + [ExternalId] = @ExternalId, [CreationDate] = @CreationDate, [RevisionDate] = @RevisionDate WHERE diff --git a/src/Sql/dbo/Stored Procedures/Group_UpdateWithCollections.sql b/src/Sql/dbo/Stored Procedures/Group_UpdateWithCollections.sql index 549ae193ca..068c7a1223 100644 --- a/src/Sql/dbo/Stored Procedures/Group_UpdateWithCollections.sql +++ b/src/Sql/dbo/Stored Procedures/Group_UpdateWithCollections.sql @@ -3,6 +3,7 @@ @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @AccessAll BIT, + @ExternalId NVARCHAR(50), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7), @Collections AS [dbo].[SelectionReadOnlyArray] READONLY @@ -10,7 +11,7 @@ AS BEGIN SET NOCOUNT ON - EXEC [dbo].[Group_Update] @Id, @OrganizationId, @Name, @AccessAll, @CreationDate, @RevisionDate + EXEC [dbo].[Group_Update] @Id, @OrganizationId, @Name, @AccessAll, @ExternalId, @CreationDate, @RevisionDate ;WITH [AvailableCollectionsCTE] AS( SELECT diff --git a/src/Sql/dbo/Tables/Group.sql b/src/Sql/dbo/Tables/Group.sql index 5219fd2bf8..8912fbde38 100644 --- a/src/Sql/dbo/Tables/Group.sql +++ b/src/Sql/dbo/Tables/Group.sql @@ -3,6 +3,7 @@ [OrganizationId] UNIQUEIDENTIFIER NOT NULL, [Name] NVARCHAR (50) NOT NULL, [AccessAll] BIT NOT NULL, + [ExternalId] NVARCHAR (50) NULL, [CreationDate] DATETIME NOT NULL, [RevisionDate] DATETIME NOT NULL, CONSTRAINT [PK_Group] PRIMARY KEY CLUSTERED ([Id] ASC),