From 8d717a350e03213a8dd0851a1b5a69f0975618ea Mon Sep 17 00:00:00 2001 From: gagan.deep Date: Wed, 10 Jan 2018 16:58:42 +0530 Subject: [PATCH] Store Proc Added --- 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetDiscountCodes.sql | 42 ++++++++++++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.UpdateAiaUserPassword.sql | 43 +++++++++++++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountTypeList.sql | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetUserType.sql | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateUserId.sql | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs | 4 ++-- 500-DBDump/Admin/Store Procedure/GetDiscountCodes.sql | 26 -------------------------- 500-DBDump/Admin/Store Procedure/GetSearchUserList.sql | 183 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 500-DBDump/Admin/Store Procedure/UpdateAiaUserPassword.sql | 29 ----------------------------- 500-DBDump/Admin/Store Procedure/usp_GetAccountTypeList.sql | 34 ---------------------------------- 500-DBDump/Admin/Store Procedure/usp_GetUserType.sql | 32 -------------------------------- 500-DBDump/Admin/Store Procedure/usp_UpdateUserId.sql | 44 -------------------------------------------- 13 files changed, 446 insertions(+), 350 deletions(-) create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetDiscountCodes.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.UpdateAiaUserPassword.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountTypeList.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetUserType.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateUserId.sql delete mode 100644 500-DBDump/Admin/Store Procedure/GetDiscountCodes.sql delete mode 100644 500-DBDump/Admin/Store Procedure/GetSearchUserList.sql delete mode 100644 500-DBDump/Admin/Store Procedure/UpdateAiaUserPassword.sql delete mode 100644 500-DBDump/Admin/Store Procedure/usp_GetAccountTypeList.sql delete mode 100644 500-DBDump/Admin/Store Procedure/usp_GetUserType.sql delete mode 100644 500-DBDump/Admin/Store Procedure/usp_UpdateUserId.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetDiscountCodes.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetDiscountCodes.sql new file mode 100644 index 0000000..974b080 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetDiscountCodes.sql @@ -0,0 +1,42 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetDiscountCodes]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[GetDiscountCodes] +GO + +-- ==================================================== +-- Author: Magic Software +-- Create date: 23-Dec-2009 +-- Description: To get the details of all discounts +-- ==================================================== +CREATE PROCEDURE [dbo].[GetDiscountCodes] + -- Add the parameters for the stored procedure here + @sDiscountCode VARCHAR(255) = '', @sStartDate VARCHAR(20) = '', @sEndDate VARCHAR(20) = '' +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME + + -- convert the datatype of startdate & enddate parameter to datetime + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate) + SELECT @dtEndDate = CONVERT(DATETIME,@sEndDate) + + SELECT Id, DiscountCode, Percentage, CONVERT(VARCHAR(10),StartDate,101) as StartDate, CONVERT(VARCHAR(10),EndDate,101) as EndDate, + (CASE IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS Status + FROM Discount WHERE StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE StartDate END) + AND EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE EndDate END) + AND DiscountCode like (CASE WHEN LEN(@sDiscountCode) > 0 THEN '%' + @sDiscountCode + '%' ELSE DiscountCode END) + ORDER BY Status +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql new file mode 100644 index 0000000..0a8fc0a --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql @@ -0,0 +1,197 @@ + +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetSearchUserList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[GetSearchUserList] +GO + +Create PROCEDURE [dbo].[GetSearchUserList]--'','','','',1,1,1 + -- Add the parameters for the stored procedure here + @sFirstName varchar(100) = '', @sLastName varchar(100) = '', @sEmailId varchar(100) = '', + @sAccoutNumber varchar(100) ='', @iUserTypeId int, @iAccountTypeId int, @iLoginUserType int +AS +BEGIN + IF 1=0 BEGIN + SET FMTONLY OFF + END + + DECLARE @SQL NVARCHAR(MAX) + -- create a temporary table to store the desired results of user on the basis of parameter + CREATE TABLE #UserResult + ( + Id INT, + FirstName VARCHAR(100), + LastName VARCHAR(100), + LoginId VARCHAR(50), + EmailId VARCHAR(50), + UserTypeTitle VARCHAR(50), + Password VARCHAR(50), + CreationDate DATETIME, + ModifiedDate DATETIME, + AccountNumber VARCHAR(50) DEFAULT '', + AccountTypeTitle VARCHAR(50) DEFAULT '', + EditionType VARCHAR(50) DEFAULT '', + UserStatus VARCHAR(8), + UserTypeId INT, + EditionTypeId INT DEFAULT '' + ) + /*SET @sFirstName = REPLACE(@sFirstName,' ',' OR ') + SET @sLastName = REPLACE(@sLastName,' ',' OR ')*/ + SET @SQL = '' + IF LEN(@sAccoutNumber) > 0 OR @iAccountTypeId > 0 + BEGIN + -- fetch account number, state, zip, country of the license to which the user is belonged + + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId) + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,'''') as EmailId, + UserType.Title as UserTypeTitle, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,'''') as ModifiedDate, + ISNULL(License.AccountNumber,'''') as AccountNumber, ISNULL(AccountType.Title,'''') as AccountTypeTitle, + ISNULL(Edition.Title,'''') as EditionType, + (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END) as UserStatus, + UserType.Id as UserTypeId, ISNULL(Edition.Id,'''') as EditionTypeId + FROM AIAUser + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id + INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId + WHERE + License.IsActive = 1 + AND UserType.Priority >' +CONVERT(VARCHAR(20),@iLoginUserType) + + IF LEN(@sAccoutNumber)>0 + BEGIN + SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+'''' + END + IF @iAccountTypeId > 0 + BEGIN + SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+'''' + END + IF LEN(@sFirstName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')' --CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' + END + IF LEN(@sLastName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' + END + IF LEN(@sEmailId)>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' + END + IF @iUserTypeId>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' + END + Print @SQL + EXEC SP_EXECUTESQL @SQL + + END + ELSE + BEGIN + + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, + ModifiedDate, UserStatus, UserTypeId) + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), + AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''), UserType.Title, AIAUser.Password, AIAUser.CreationDate, + ISNULL(AIAUser.ModifiedDate,''''), (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END), + UserType.Id + FROM AIAUser + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId + WHERE UserType.Title in (''General Admin'')' + + IF LEN(@sFirstName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' + END + IF LEN(@sLastName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' + END + IF LEN(@sEmailId)>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' + END + IF @iUserTypeId>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' + END + -- Print @SQL + EXEC SP_EXECUTESQL @SQL + + -- fetch account number, state, zip, country of the license to which the user is belonged + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId) + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''), + UserType.Title, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,''''), + License.AccountNumber, AccountType.Title, Edition.Title, + (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END), UserType.Id, Edition.Id + FROM AIAUser + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id + INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId + WHERE + UserType.Title NOT IN (''Super Admin'',''General Admin'') + AND License.IsActive = 1' + + IF LEN(@sAccoutNumber)>0 + BEGIN + SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+'''' + END + IF @iAccountTypeId > 0 + BEGIN + SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+'''' + END + IF LEN(@sFirstName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' + END + IF LEN(@sLastName)>0 + BEGIN + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' + END + IF LEN(@sEmailId)>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' + END + IF @iUserTypeId>0 + BEGIN + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' + END + -- Print @SQL + EXEC SP_EXECUTESQL @SQL + + END + -- Selecting the desired result from temporary table + SELECT Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId FROM #UserResult + -- Dropping the temporary table + DROP TABLE #UserResult +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + + + + + + + + + + + + + \ No newline at end of file diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.UpdateAiaUserPassword.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.UpdateAiaUserPassword.sql new file mode 100644 index 0000000..54ecc51 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.UpdateAiaUserPassword.sql @@ -0,0 +1,43 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UpdateAiaUserPassword]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[UpdateAiaUserPassword] +GO +-- ============================================= +-- Author: +-- Create date: +-- Description: +-- ============================================= +Create PROCEDURE [dbo].[UpdateAiaUserPassword] + -- Add the parameters for the stored procedure here + @Id int, + @NewPassword VARCHAR(50), + @Status bit out +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + set @Status = 0; + BEGIN TRY + BEGIN TRANSACTION + UPDATE AIAUser SET Password= @NewPassword where Id = @Id; + COMMIT TRANSACTION + set @Status = 1; + END TRY + BEGIN CATCH + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + END CATCH + +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountTypeList.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountTypeList.sql new file mode 100644 index 0000000..b394714 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountTypeList.sql @@ -0,0 +1,51 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetAccountTypeList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetAccountTypeList] +GO + + + +-- ============================================= +-- Author: magic +-- Create date: 7/4/2009 +-- Description: Fetch AccountType List +-- ============================================= +CREATE PROCEDURE [dbo].[usp_GetAccountTypeList] + -- Add the parameters for the stored procedure here + @Id Int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- Insert statements for procedure here + if(@Id>0) + begin + select Id,Title + from AccountType where IsActive=1 and Id=@Id + end + else + begin + select Id,Title + from AccountType where IsActive=1 + end + + +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + + + + + + \ No newline at end of file diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetUserType.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetUserType.sql new file mode 100644 index 0000000..50044ee --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetUserType.sql @@ -0,0 +1,48 @@ + +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetUserType]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetUserType] +GO + + +-- ============================================= +-- Author: magic +-- Create date: 7/4/2009 +-- Description: Fetch AccountType List +-- ============================================= +CREATE PROCEDURE [dbo].[usp_GetUserType] + -- Add the parameters for the stored procedure here + @id int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + if(@id>0) + begin + -- Insert statements for procedure here + select Id,Title + from UserType where IsActive=1 and Id=@id + end + else + begin + select Id,Title + from UserType where IsActive=1 + end + +END + + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + + + + \ No newline at end of file diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateUserId.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateUserId.sql new file mode 100644 index 0000000..6a78fa3 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateUserId.sql @@ -0,0 +1,63 @@ + +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateUserId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_UpdateUserId] +GO + + +-- ============================================= +-- Author: +-- Create date: <3-Jan-2018> +-- Description: +-- ============================================= +CREATE PROCEDURE [dbo].[usp_UpdateUserId]--6,'aiaonline1','aiaonline',0 + -- Add the parameters for the stored procedure here + @Id int, + @UserId VARCHAR(50), + @olduserId varchar(50), + @Status int out +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + set @Status = 0; + BEGIN TRY + + + if ((Select count(*) from AIAUser Where LoginId=@UserId)=1) + begin + -- Already exists + set @Status = 2; + --select '2' + end + else + begin + BEGIN TRANSACTION + UPDATE AIAUser SET LoginId= @UserId where Id = @Id and LoginId=@olduserId; + set @Status = 1; + COMMIT TRANSACTION + --select '1' + end + + + END TRY + BEGIN CATCH + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + END CATCH + +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index 08a4113..787c1d6 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -10,13 +10,13 @@ using AIAHTML5.ADMIN.API.Models; using System.Web.Http.Cors; using System.Web.Cors; using AIAHTML5.Server.Constants; -using log4net; +using log4net; using System.Text; using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { - + [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("User")] public class UserController : ApiController { diff --git a/500-DBDump/Admin/Store Procedure/GetDiscountCodes.sql b/500-DBDump/Admin/Store Procedure/GetDiscountCodes.sql deleted file mode 100644 index 0ed7543..0000000 --- a/500-DBDump/Admin/Store Procedure/GetDiscountCodes.sql +++ /dev/null @@ -1,26 +0,0 @@ --- ==================================================== --- Author: Magic Software --- Create date: 23-Dec-2009 --- Description: To get the details of all discounts --- ==================================================== -CREATE PROCEDURE [dbo].[GetDiscountCodes] - -- Add the parameters for the stored procedure here - @sDiscountCode VARCHAR(255) = '', @sStartDate VARCHAR(20) = '', @sEndDate VARCHAR(20) = '' -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME - - -- convert the datatype of startdate & enddate parameter to datetime - SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate) - SELECT @dtEndDate = CONVERT(DATETIME,@sEndDate) - - SELECT Id, DiscountCode, Percentage, CONVERT(VARCHAR(10),StartDate,101) as StartDate, CONVERT(VARCHAR(10),EndDate,101) as EndDate, - (CASE IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS Status - FROM Discount WHERE StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE StartDate END) - AND EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE EndDate END) - AND DiscountCode like (CASE WHEN LEN(@sDiscountCode) > 0 THEN '%' + @sDiscountCode + '%' ELSE DiscountCode END) - ORDER BY Status -END \ No newline at end of file diff --git a/500-DBDump/Admin/Store Procedure/GetSearchUserList.sql b/500-DBDump/Admin/Store Procedure/GetSearchUserList.sql deleted file mode 100644 index 79882db..0000000 --- a/500-DBDump/Admin/Store Procedure/GetSearchUserList.sql +++ /dev/null @@ -1,183 +0,0 @@ - -Create PROCEDURE [dbo].[GetSearchUserList]--'','','','',1,1,1 - -- Add the parameters for the stored procedure here - @sFirstName varchar(100) = '', @sLastName varchar(100) = '', @sEmailId varchar(100) = '', - @sAccoutNumber varchar(100) ='', @iUserTypeId int, @iAccountTypeId int, @iLoginUserType int -AS -BEGIN - IF 1=0 BEGIN - SET FMTONLY OFF - END - - DECLARE @SQL NVARCHAR(MAX) - -- create a temporary table to store the desired results of user on the basis of parameter - CREATE TABLE #UserResult - ( - Id INT, - FirstName VARCHAR(100), - LastName VARCHAR(100), - LoginId VARCHAR(50), - EmailId VARCHAR(50), - UserTypeTitle VARCHAR(50), - Password VARCHAR(50), - CreationDate DATETIME, - ModifiedDate DATETIME, - AccountNumber VARCHAR(50) DEFAULT '', - AccountTypeTitle VARCHAR(50) DEFAULT '', - EditionType VARCHAR(50) DEFAULT '', - UserStatus VARCHAR(8), - UserTypeId INT, - EditionTypeId INT DEFAULT '' - ) - /*SET @sFirstName = REPLACE(@sFirstName,' ',' OR ') - SET @sLastName = REPLACE(@sLastName,' ',' OR ')*/ - SET @SQL = '' - IF LEN(@sAccoutNumber) > 0 OR @iAccountTypeId > 0 - BEGIN - -- fetch account number, state, zip, country of the license to which the user is belonged - - SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, - ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId) - SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,'''') as EmailId, - UserType.Title as UserTypeTitle, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,'''') as ModifiedDate, - ISNULL(License.AccountNumber,'''') as AccountNumber, ISNULL(AccountType.Title,'''') as AccountTypeTitle, - ISNULL(Edition.Title,'''') as EditionType, - (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END) as UserStatus, - UserType.Id as UserTypeId, ISNULL(Edition.Id,'''') as EditionTypeId - FROM AIAUser - INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId - INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId - INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id - INNER JOIN License ON LicenseToEdition.LicenseId = License.Id - INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId - INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId - WHERE - License.IsActive = 1 - AND UserType.Priority >' +CONVERT(VARCHAR(20),@iLoginUserType) - - IF LEN(@sAccoutNumber)>0 - BEGIN - SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+'''' - END - IF @iAccountTypeId > 0 - BEGIN - SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+'''' - END - IF LEN(@sFirstName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')' --CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' - END - IF LEN(@sLastName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' - END - IF LEN(@sEmailId)>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' - END - IF @iUserTypeId>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' - END - Print @SQL - EXEC SP_EXECUTESQL @SQL - - END - ELSE - BEGIN - - SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, - ModifiedDate, UserStatus, UserTypeId) - SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), - AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''), UserType.Title, AIAUser.Password, AIAUser.CreationDate, - ISNULL(AIAUser.ModifiedDate,''''), (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END), - UserType.Id - FROM AIAUser - INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId - WHERE UserType.Title in (''General Admin'')' - - IF LEN(@sFirstName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' - END - IF LEN(@sLastName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' - END - IF LEN(@sEmailId)>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' - END - IF @iUserTypeId>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' - END - -- Print @SQL - EXEC SP_EXECUTESQL @SQL - - -- fetch account number, state, zip, country of the license to which the user is belonged - SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, - ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId) - SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''), - UserType.Title, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,''''), - License.AccountNumber, AccountType.Title, Edition.Title, - (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END), UserType.Id, Edition.Id - FROM AIAUser - INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId - INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId - INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id - INNER JOIN License ON LicenseToEdition.LicenseId = License.Id - INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId - INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId - WHERE - UserType.Title NOT IN (''Super Admin'',''General Admin'') - AND License.IsActive = 1' - - IF LEN(@sAccoutNumber)>0 - BEGIN - SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+'''' - END - IF @iAccountTypeId > 0 - BEGIN - SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+'''' - END - IF LEN(@sFirstName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')' - END - IF LEN(@sLastName)>0 - BEGIN - SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')' - END - IF LEN(@sEmailId)>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+'''' - END - IF @iUserTypeId>0 - BEGIN - SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+'''' - END - -- Print @SQL - EXEC SP_EXECUTESQL @SQL - - END - -- Selecting the desired result from temporary table - SELECT Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate, - ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId FROM #UserResult - -- Dropping the temporary table - DROP TABLE #UserResult -END - - - - - - - - - - - - - - \ No newline at end of file diff --git a/500-DBDump/Admin/Store Procedure/UpdateAiaUserPassword.sql b/500-DBDump/Admin/Store Procedure/UpdateAiaUserPassword.sql deleted file mode 100644 index 9cfe2d1..0000000 --- a/500-DBDump/Admin/Store Procedure/UpdateAiaUserPassword.sql +++ /dev/null @@ -1,29 +0,0 @@ --- ============================================= --- Author: --- Create date: --- Description: --- ============================================= -Create PROCEDURE [dbo].[UpdateAiaUserPassword] - -- Add the parameters for the stored procedure here - @Id int, - @NewPassword VARCHAR(50), - @Status bit out -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - - set @Status = 0; - BEGIN TRY - BEGIN TRANSACTION - UPDATE AIAUser SET Password= @NewPassword where Id = @Id; - COMMIT TRANSACTION - set @Status = 1; - END TRY - BEGIN CATCH - IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION - END CATCH - -END \ No newline at end of file diff --git a/500-DBDump/Admin/Store Procedure/usp_GetAccountTypeList.sql b/500-DBDump/Admin/Store Procedure/usp_GetAccountTypeList.sql deleted file mode 100644 index 971984f..0000000 --- a/500-DBDump/Admin/Store Procedure/usp_GetAccountTypeList.sql +++ /dev/null @@ -1,34 +0,0 @@ --- ============================================= --- Author: magic --- Create date: 7/4/2009 --- Description: Fetch AccountType List --- ============================================= -CREATE PROCEDURE [dbo].[usp_GetAccountTypeList] - -- Add the parameters for the stored procedure here - @Id Int -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - - -- Insert statements for procedure here - if(@Id>0) - begin - select Id,Title - from AccountType where IsActive=1 and Id=@Id - end - else - begin - select Id,Title - from AccountType where IsActive=1 - end - - -END - - - - - - \ No newline at end of file diff --git a/500-DBDump/Admin/Store Procedure/usp_GetUserType.sql b/500-DBDump/Admin/Store Procedure/usp_GetUserType.sql deleted file mode 100644 index ee27b3b..0000000 --- a/500-DBDump/Admin/Store Procedure/usp_GetUserType.sql +++ /dev/null @@ -1,32 +0,0 @@ --- ============================================= --- Author: magic --- Create date: 7/4/2009 --- Description: Fetch AccountType List --- ============================================= -CREATE PROCEDURE [dbo].[usp_GetUserType] - -- Add the parameters for the stored procedure here - @id int -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - if(@id>0) - begin - -- Insert statements for procedure here - select Id,Title - from UserType where IsActive=1 and Id=@id - end - else - begin - select Id,Title - from UserType where IsActive=1 - end - -END - - - - - - \ No newline at end of file diff --git a/500-DBDump/Admin/Store Procedure/usp_UpdateUserId.sql b/500-DBDump/Admin/Store Procedure/usp_UpdateUserId.sql deleted file mode 100644 index fddc741..0000000 --- a/500-DBDump/Admin/Store Procedure/usp_UpdateUserId.sql +++ /dev/null @@ -1,44 +0,0 @@ --- ============================================= --- Author: --- Create date: <3-Jan-2018> --- Description: --- ============================================= -CREATE PROCEDURE [dbo].[usp_UpdateUserId]--6,'aiaonline1','aiaonline',0 - -- Add the parameters for the stored procedure here - @Id int, - @UserId VARCHAR(50), - @olduserId varchar(50), - @Status int out -AS -BEGIN - -- SET NOCOUNT ON added to prevent extra result sets from - -- interfering with SELECT statements. - SET NOCOUNT ON; - - set @Status = 0; - BEGIN TRY - - - if ((Select count(*) from AIAUser Where LoginId=@UserId)=1) - begin - -- Already exists - set @Status = 2; - --select '2' - end - else - begin - BEGIN TRANSACTION - UPDATE AIAUser SET LoginId= @UserId where Id = @Id and LoginId=@olduserId; - set @Status = 1; - COMMIT TRANSACTION - --select '1' - end - - - END TRY - BEGIN CATCH - IF @@TRANCOUNT > 0 - ROLLBACK TRANSACTION - END CATCH - -END \ No newline at end of file -- libgit2 0.21.4