Commit a3a3d504de15d615bbc30d6068e79f88c97ef5d5
1 parent
e3e725ed
merge harpreet code
Showing
5 changed files
with
215 additions
and
17 deletions
400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserGroupController.cs
... | ... | @@ -24,13 +24,14 @@ namespace AIAHTML5.ADMIN.API.Controllers |
24 | 24 | |
25 | 25 | [Route("LicenseUserGroups")] |
26 | 26 | [HttpGet] |
27 | - public HttpResponseMessage GetLicenseUserGroups(int LicenseId) | |
27 | + public HttpResponseMessage GetLicenseUserGroups(int LicenseId, int pageNo, int pageLength) | |
28 | 28 | { |
29 | 29 | List<UserGroupModel> UserGroupList = new List<UserGroupModel>(); |
30 | + int recordCount = 0; | |
30 | 31 | try |
31 | 32 | { |
32 | - UserGroupList = UserGroupModel.GetLicenseUserGroups(dbContext, LicenseId); | |
33 | - return Request.CreateResponse(HttpStatusCode.OK, UserGroupList); | |
33 | + UserGroupList = UserGroupModel.GetLicenseUserGroups(dbContext, LicenseId, pageNo, pageLength, out recordCount); | |
34 | + return Request.CreateResponse(HttpStatusCode.OK, new { UserGroupList = UserGroupList, RecordCount = recordCount }); | |
34 | 35 | } |
35 | 36 | catch (Exception ex) |
36 | 37 | { |
... | ... | @@ -41,13 +42,14 @@ namespace AIAHTML5.ADMIN.API.Controllers |
41 | 42 | |
42 | 43 | [Route("LicenseUserGroupUsers")] |
43 | 44 | [HttpGet] |
44 | - public HttpResponseMessage GetLicenseUserGroupUsers(int LicenseId, int UserGroupId) | |
45 | + public HttpResponseMessage GetLicenseUserGroupUsers(int LicenseId, int UserGroupId, bool AllUsers, int pageNo, int pageLength) | |
45 | 46 | { |
46 | 47 | List<UserModel> UserList = new List<UserModel>(); |
48 | + int recordCount = 0; | |
47 | 49 | try |
48 | 50 | { |
49 | - UserList = UserGroupModel.GetLicenseUserGroupUsers(dbContext, LicenseId, UserGroupId); | |
50 | - return Request.CreateResponse(HttpStatusCode.OK, UserList); | |
51 | + UserList = UserGroupModel.GetLicenseUserGroupUsers(dbContext, LicenseId, UserGroupId, AllUsers, pageNo, pageLength, out recordCount); | |
52 | + return Request.CreateResponse(HttpStatusCode.OK, new { UserList = UserList, RecordCount = recordCount }); | |
51 | 53 | } |
52 | 54 | catch (Exception ex) |
53 | 55 | { |
... | ... | @@ -67,7 +69,7 @@ namespace AIAHTML5.ADMIN.API.Controllers |
67 | 69 | UserGroupEntity.Title = jsonData["title"].Value<string>(); |
68 | 70 | UserGroupEntity.IsActive = jsonData["isActive"].Value<bool>(); |
69 | 71 | UserGroupEntity.CreationDate = jsonData["creationDate"].Value<DateTime>(); |
70 | - UserGroupEntity.ModifiedDate = jsonData["modifiedDate"].Value<DateTime>(); | |
72 | + UserGroupEntity.ModifiedDate = jsonData["modifiedDate"].Value<DateTime>(); | |
71 | 73 | try |
72 | 74 | { |
73 | 75 | Status = UserGroupModel.InsertUpdateLicenseUserGroup(dbContext, UserGroupEntity); | ... | ... |
400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs
... | ... | @@ -3479,13 +3479,21 @@ namespace AIAHTML5.ADMIN.API.Entity |
3479 | 3479 | return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_DeleteLicenseUserGroup", userGroupIdParameter, status); |
3480 | 3480 | } |
3481 | 3481 | |
3482 | - public virtual ObjectResult<usp_GetLicenseUserGroups_Result> usp_GetLicenseUserGroups(Nullable<int> licenseId) | |
3482 | + public virtual ObjectResult<usp_GetLicenseUserGroups_Result> usp_GetLicenseUserGroups(Nullable<int> licenseId, Nullable<int> pageNo, Nullable<int> pageLength, ObjectParameter recordCount) | |
3483 | 3483 | { |
3484 | 3484 | var licenseIdParameter = licenseId.HasValue ? |
3485 | 3485 | new ObjectParameter("LicenseId", licenseId) : |
3486 | 3486 | new ObjectParameter("LicenseId", typeof(int)); |
3487 | 3487 | |
3488 | - return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<usp_GetLicenseUserGroups_Result>("usp_GetLicenseUserGroups", licenseIdParameter); | |
3488 | + var pageNoParameter = pageNo.HasValue ? | |
3489 | + new ObjectParameter("pageNo", pageNo) : | |
3490 | + new ObjectParameter("pageNo", typeof(int)); | |
3491 | + | |
3492 | + var pageLengthParameter = pageLength.HasValue ? | |
3493 | + new ObjectParameter("pageLength", pageLength) : | |
3494 | + new ObjectParameter("pageLength", typeof(int)); | |
3495 | + | |
3496 | + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<usp_GetLicenseUserGroups_Result>("usp_GetLicenseUserGroups", licenseIdParameter, pageNoParameter, pageLengthParameter, recordCount); | |
3489 | 3497 | } |
3490 | 3498 | |
3491 | 3499 | public virtual int usp_InsertUpdateLicenseUserGroup(Nullable<int> id, Nullable<int> licenseId, string title, Nullable<System.DateTime> creationDate, Nullable<System.DateTime> modifiedDate, Nullable<bool> isActive, ObjectParameter status) |
... | ... | @@ -3734,5 +3742,30 @@ namespace AIAHTML5.ADMIN.API.Entity |
3734 | 3742 | |
3735 | 3743 | return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_CheckAccountNoExists", accountNoParameter, status); |
3736 | 3744 | } |
3745 | + | |
3746 | + public virtual ObjectResult<usp_GetLicenseUserGroupUsers_Result> usp_GetLicenseUserGroupUsers(Nullable<int> licenseId, Nullable<int> groupId, Nullable<bool> allUsers, Nullable<int> pageNo, Nullable<int> pageLength, ObjectParameter recordCount) | |
3747 | + { | |
3748 | + var licenseIdParameter = licenseId.HasValue ? | |
3749 | + new ObjectParameter("licenseId", licenseId) : | |
3750 | + new ObjectParameter("licenseId", typeof(int)); | |
3751 | + | |
3752 | + var groupIdParameter = groupId.HasValue ? | |
3753 | + new ObjectParameter("groupId", groupId) : | |
3754 | + new ObjectParameter("groupId", typeof(int)); | |
3755 | + | |
3756 | + var allUsersParameter = allUsers.HasValue ? | |
3757 | + new ObjectParameter("allUsers", allUsers) : | |
3758 | + new ObjectParameter("allUsers", typeof(bool)); | |
3759 | + | |
3760 | + var pageNoParameter = pageNo.HasValue ? | |
3761 | + new ObjectParameter("pageNo", pageNo) : | |
3762 | + new ObjectParameter("pageNo", typeof(int)); | |
3763 | + | |
3764 | + var pageLengthParameter = pageLength.HasValue ? | |
3765 | + new ObjectParameter("pageLength", pageLength) : | |
3766 | + new ObjectParameter("pageLength", typeof(int)); | |
3767 | + | |
3768 | + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<usp_GetLicenseUserGroupUsers_Result>("usp_GetLicenseUserGroupUsers", licenseIdParameter, groupIdParameter, allUsersParameter, pageNoParameter, pageLengthParameter, recordCount); | |
3769 | + } | |
3737 | 3770 | } |
3738 | 3771 | } | ... | ... |
400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx
... | ... | @@ -2694,6 +2694,17 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does |
2694 | 2694 | <Function Name="usp_GetLicenseTypes" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" /> |
2695 | 2695 | <Function Name="usp_GetLicenseUserGroups" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo"> |
2696 | 2696 | <Parameter Name="LicenseId" Type="int" Mode="In" /> |
2697 | + <Parameter Name="pageNo" Type="int" Mode="In" /> | |
2698 | + <Parameter Name="pageLength" Type="int" Mode="In" /> | |
2699 | + <Parameter Name="recordCount" Type="int" Mode="InOut" /> | |
2700 | + </Function> | |
2701 | + <Function Name="usp_GetLicenseUserGroupUsers" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo"> | |
2702 | + <Parameter Name="licenseId" Type="int" Mode="In" /> | |
2703 | + <Parameter Name="groupId" Type="int" Mode="In" /> | |
2704 | + <Parameter Name="allUsers" Type="bit" Mode="In" /> | |
2705 | + <Parameter Name="pageNo" Type="int" Mode="In" /> | |
2706 | + <Parameter Name="pageLength" Type="int" Mode="In" /> | |
2707 | + <Parameter Name="recordCount" Type="int" Mode="InOut" /> | |
2697 | 2708 | </Function> |
2698 | 2709 | <Function Name="usp_GetManageRights" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo"> |
2699 | 2710 | <Parameter Name="UserId" Type="int" Mode="In" /> |
... | ... | @@ -6451,7 +6462,10 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap]</Definin |
6451 | 6462 | <Parameter Name="Status" Mode="InOut" Type="Boolean" /> |
6452 | 6463 | </FunctionImport> |
6453 | 6464 | <FunctionImport Name="usp_GetLicenseUserGroups" ReturnType="Collection(AIADatabaseV5Model.usp_GetLicenseUserGroups_Result)"> |
6454 | - <Parameter Name="LicenseId" Mode="In" Type="Int32" /> | |
6465 | + <Parameter Name="LicenseId" Mode="In" Type="Int32" /> | |
6466 | + <Parameter Name="pageNo" Mode="In" Type="Int32" /> | |
6467 | + <Parameter Name="pageLength" Mode="In" Type="Int32" /> | |
6468 | + <Parameter Name="recordCount" Mode="InOut" Type="Int32" /> | |
6455 | 6469 | </FunctionImport> |
6456 | 6470 | <FunctionImport Name="usp_InsertUpdateLicenseUserGroup"> |
6457 | 6471 | <Parameter Name="Id" Mode="In" Type="Int32" /> |
... | ... | @@ -6527,6 +6541,14 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap]</Definin |
6527 | 6541 | <Parameter Name="AccountNo" Mode="In" Type="String" /> |
6528 | 6542 | <Parameter Name="Status" Mode="InOut" Type="Boolean" /> |
6529 | 6543 | </FunctionImport> |
6544 | + <FunctionImport Name="usp_GetLicenseUserGroupUsers" ReturnType="Collection(AIADatabaseV5Model.usp_GetLicenseUserGroupUsers_Result)"> | |
6545 | + <Parameter Name="licenseId" Mode="In" Type="Int32" /> | |
6546 | + <Parameter Name="groupId" Mode="In" Type="Int32" /> | |
6547 | + <Parameter Name="allUsers" Mode="In" Type="Boolean" /> | |
6548 | + <Parameter Name="pageNo" Mode="In" Type="Int32" /> | |
6549 | + <Parameter Name="pageLength" Mode="In" Type="Int32" /> | |
6550 | + <Parameter Name="recordCount" Mode="InOut" Type="Int32" /> | |
6551 | + </FunctionImport> | |
6530 | 6552 | </EntityContainer> |
6531 | 6553 | <ComplexType Name="DA_GetBaseLayer_Result"> |
6532 | 6554 | <Property Type="Int32" Name="Id" Nullable="false" /> |
... | ... | @@ -7530,6 +7552,16 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap]</Definin |
7530 | 7552 | <Property Type="Int32" Name="UserTypeId" Nullable="true" /> |
7531 | 7553 | <Property Type="Int32" Name="EditionTypeId" Nullable="true" /> |
7532 | 7554 | </ComplexType> |
7555 | + <ComplexType Name="usp_GetLicenseUserGroupUsers_Result"> | |
7556 | + <Property Type="Int64" Name="RowNo" Nullable="true" /> | |
7557 | + <Property Type="Int32" Name="Id" Nullable="false" /> | |
7558 | + <Property Type="String" Name="FirstName" Nullable="true" MaxLength="100" /> | |
7559 | + <Property Type="String" Name="LastName" Nullable="true" MaxLength="100" /> | |
7560 | + <Property Type="String" Name="LoginId" Nullable="false" MaxLength="50" /> | |
7561 | + <Property Type="String" Name="EmailId" Nullable="true" MaxLength="50" /> | |
7562 | + <Property Type="String" Name="Title" Nullable="false" MaxLength="50" /> | |
7563 | + <Property Type="Int32" Name="InGroup" Nullable="false" /> | |
7564 | + </ComplexType> | |
7533 | 7565 | </Schema> |
7534 | 7566 | </edmx:ConceptualModels> |
7535 | 7567 | <!-- C-S mapping content --> |
... | ... | @@ -10057,6 +10089,20 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap]</Definin |
10057 | 10089 | </ResultMapping> |
10058 | 10090 | </FunctionImportMapping> |
10059 | 10091 | <FunctionImportMapping FunctionImportName="usp_CheckAccountNoExists" FunctionName="AIADatabaseV5Model.Store.usp_CheckAccountNoExists" /> |
10092 | + <FunctionImportMapping FunctionImportName="usp_GetLicenseUserGroupUsers" FunctionName="AIADatabaseV5Model.Store.usp_GetLicenseUserGroupUsers"> | |
10093 | + <ResultMapping> | |
10094 | + <ComplexTypeMapping TypeName="AIADatabaseV5Model.usp_GetLicenseUserGroupUsers_Result"> | |
10095 | + <ScalarProperty Name="RowNo" ColumnName="RowNo" /> | |
10096 | + <ScalarProperty Name="Id" ColumnName="Id" /> | |
10097 | + <ScalarProperty Name="FirstName" ColumnName="FirstName" /> | |
10098 | + <ScalarProperty Name="LastName" ColumnName="LastName" /> | |
10099 | + <ScalarProperty Name="LoginId" ColumnName="LoginId" /> | |
10100 | + <ScalarProperty Name="EmailId" ColumnName="EmailId" /> | |
10101 | + <ScalarProperty Name="Title" ColumnName="Title" /> | |
10102 | + <ScalarProperty Name="InGroup" ColumnName="InGroup" /> | |
10103 | + </ComplexTypeMapping> | |
10104 | + </ResultMapping> | |
10105 | + </FunctionImportMapping> | |
10060 | 10106 | </EntityContainerMapping> |
10061 | 10107 | </Mapping> |
10062 | 10108 | </edmx:Mappings> | ... | ... |
500-DBDump/AIA-StoredProcedures/usp_GetLicenseUserGroupUsers.sql
0 โ 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetLicenseUserGroupUsers]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_GetLicenseUserGroupUsers] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 20-Mar-2018 | |
13 | +-- Description: To get all user group users with all users of a license | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_GetLicenseUserGroupUsers] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @licenseId int, @groupId int, @allUsers bit, @pageNo int, @pageLength int, @recordCount int out | |
18 | +AS | |
19 | +BEGIN | |
20 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
21 | + -- interfering with SELECT statements. | |
22 | + SET NOCOUNT ON; | |
23 | + | |
24 | + if (@AllUsers = 1) | |
25 | + begin | |
26 | + --Get the records on the basis of parameters page length and page number rows | |
27 | + select * from | |
28 | + (SELECT row_number() OVER (order by AIAUser.Id) AS RowNo, AIAUser.Id, AIAUser.FirstName, AIAUser.LastName, AIAUser.LoginId, | |
29 | + AIAUser.EmailId, Edition.Title, | |
30 | + (CASE WHEN UserGroupToAIAUser.UserId IS NULL THEN 0 ELSE 1 END) AS InGroup | |
31 | + FROM | |
32 | + AIAUser | |
33 | + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId | |
34 | + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id | |
35 | + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId | |
36 | + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id AND License.IsActive = 1 | |
37 | + LEFT JOIN UserGroupToAIAUser ON UserGroupToAIAUser.UserId = AIAUser.Id | |
38 | + AND UserGroupToAIAUser.UserGroupId = @groupId | |
39 | + WHERE License.Id = @licenseId AND AIAUser.UserTypeId = 6 | |
40 | + ) TB | |
41 | + WHERE RowNo > @pageLength * (@pageNo - 1) and RowNo <= @pageLength * @pageNo; | |
42 | + | |
43 | + --Calculate total number of records | |
44 | + select @recordCount = count(ResultTable.Id) from ( | |
45 | + SELECT AIAUser.Id, AIAUser.FirstName, AIAUser.LastName, AIAUser.LoginId, | |
46 | + AIAUser.EmailId, Edition.Title, | |
47 | + (CASE WHEN UserGroupToAIAUser.UserId IS NULL THEN 0 ELSE 1 END) AS InGroup | |
48 | + FROM | |
49 | + AIAUser | |
50 | + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId | |
51 | + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id | |
52 | + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId | |
53 | + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id AND License.IsActive = 1 | |
54 | + LEFT JOIN UserGroupToAIAUser ON UserGroupToAIAUser.UserId = AIAUser.Id | |
55 | + AND UserGroupToAIAUser.UserGroupId = @groupId | |
56 | + WHERE License.Id = @licenseId AND AIAUser.UserTypeId = 6) as ResultTable; | |
57 | + end | |
58 | + else | |
59 | + begin | |
60 | + --Get the records on the basis of parameters page length and page number rows | |
61 | + select * from | |
62 | + (SELECT row_number() OVER (order by AIAUser.Id) AS RowNo, AIAUser.Id, AIAUser.FirstName, AIAUser.LastName, AIAUser.LoginId, | |
63 | + AIAUser.EmailId, Edition.Title, | |
64 | + (CASE WHEN UserGroupToAIAUser.UserId IS NULL THEN 0 ELSE 1 END) AS InGroup | |
65 | + FROM | |
66 | + AIAUser | |
67 | + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId | |
68 | + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id | |
69 | + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId | |
70 | + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id AND License.IsActive = 1 | |
71 | + LEFT JOIN UserGroupToAIAUser ON UserGroupToAIAUser.UserId = AIAUser.Id | |
72 | + AND UserGroupToAIAUser.UserGroupId = @groupId | |
73 | + WHERE License.Id = @licenseId AND AIAUser.UserTypeId = 6 and UserGroupToAIAUser.UserId > 0 | |
74 | + ) TB | |
75 | + WHERE RowNo > @pageLength * (@pageNo - 1) and RowNo <= @pageLength * @pageNo; | |
76 | + | |
77 | + --Calculate total number of records | |
78 | + select @recordCount = count(ResultTable.Id) from ( | |
79 | + SELECT AIAUser.Id, AIAUser.FirstName, AIAUser.LastName, AIAUser.LoginId, | |
80 | + AIAUser.EmailId, Edition.Title, | |
81 | + (CASE WHEN UserGroupToAIAUser.UserId IS NULL THEN 0 ELSE 1 END) AS InGroup | |
82 | + FROM | |
83 | + AIAUser | |
84 | + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId | |
85 | + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id | |
86 | + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId | |
87 | + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id AND License.IsActive = 1 | |
88 | + LEFT JOIN UserGroupToAIAUser ON UserGroupToAIAUser.UserId = AIAUser.Id | |
89 | + AND UserGroupToAIAUser.UserGroupId = @groupId | |
90 | + WHERE License.Id = @licenseId AND AIAUser.UserTypeId = 6 and UserGroupToAIAUser.UserId > 0) as ResultTable; | |
91 | + end | |
92 | + | |
93 | +END | |
94 | + | |
95 | +GO | |
96 | +SET QUOTED_IDENTIFIER OFF | |
97 | +GO | |
98 | +SET ANSI_NULLS ON | |
99 | +GO | |
100 | + | |
101 | + | |
102 | + | |
103 | + | ... | ... |
500-DBDump/AIA-StoredProcedures/usp_UpdateLicenseUserGroupUsers.sql
... | ... | @@ -21,7 +21,7 @@ SET NOCOUNT ON; |
21 | 21 | |
22 | 22 | DECLARE @pos INT, @tempUserId int; |
23 | 23 | DECLARE @len INT; |
24 | -DECLARE @value varchar(10); | |
24 | +DECLARE @value varchar(10), @value1 varchar(10); | |
25 | 25 | |
26 | 26 | if(@UserIds != '') |
27 | 27 | begin |
... | ... | @@ -32,17 +32,31 @@ end |
32 | 32 | BEGIN TRY |
33 | 33 | BEGIN TRANSACTION |
34 | 34 | |
35 | - delete UGU from UserGroupToAIAUser UGU where UserGroupId = @UserGroupId; | |
36 | 35 | |
37 | - set @pos = 0 | |
36 | + set @pos = 1 | |
38 | 37 | set @len = 0 |
39 | 38 | |
40 | - WHILE CHARINDEX(',', @UserIds, @pos+1)>0 | |
39 | + WHILE CHARINDEX(',', @UserIds, @pos)>0 | |
41 | 40 | BEGIN |
42 | - set @len = CHARINDEX(',', @UserIds, @pos+1) - @pos; | |
43 | - set @value = SUBSTRING(@UserIds, @pos, @len); | |
41 | + set @len = CHARINDEX(',', @UserIds, @pos) - @pos; | |
42 | + set @value = SUBSTRING(@UserIds, @pos, CHARINDEX('-', @UserIds, @pos) - @pos); | |
43 | + set @value1 = SUBSTRING(@UserIds, CHARINDEX('-', @UserIds, @pos) + 1, @len - len(@value) - 1); | |
44 | + select @pos, @len, @value, @value1; | |
44 | 45 | set @tempUserId = convert(int, @value); |
45 | - insert into UserGroupToAIAUser(UserGroupId, UserId) values(@UserGroupId, @tempUserId); | |
46 | + if(exists(select * from UserGroupToAIAUser where UserGroupId = @UserGroupId and UserId = @tempUserId)) | |
47 | + begin | |
48 | + if(@value1 = '0') | |
49 | + begin | |
50 | + delete from UserGroupToAIAUser where UserGroupId = @UserGroupId and UserId = @tempUserId; | |
51 | + end | |
52 | + end | |
53 | + else | |
54 | + begin | |
55 | + if(@value1 = '1') | |
56 | + begin | |
57 | + insert into UserGroupToAIAUser(UserGroupId, UserId) values(@UserGroupId, @tempUserId); | |
58 | + end | |
59 | + end | |
46 | 60 | set @pos = CHARINDEX(',', @UserIds, @pos+@len) + 1; |
47 | 61 | END |
48 | 62 | ... | ... |