From e742dc2f764974e191c06e347d2bab3a412ea3c0 Mon Sep 17 00:00:00 2001 From: gagan.deep Date: Wed, 17 Jan 2018 14:04:52 +0530 Subject: [PATCH] store Procedure --- 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountNumber.sql | 33 +++++++++++++++++++++++++++++++++ 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetProductEditionByLicense.sql | 34 ++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj | 10 +++++++++- 400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs | 14 ++++++++++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx | 40 ++++++++++++++++++++++++++++++++++++++-- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetAccountNumber_Result.cs | 19 +++++++++++++++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetProductEditionByLicense_Result.cs | 21 +++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/Web.config | 17 ++++++++++++++++- 400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------- 10 files changed, 349 insertions(+), 126 deletions(-) create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountNumber.sql create mode 100644 150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetProductEditionByLicense.sql create mode 100644 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetAccountNumber_Result.cs create mode 100644 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetProductEditionByLicense_Result.cs diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountNumber.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountNumber.sql new file mode 100644 index 0000000..d99b494 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetAccountNumber.sql @@ -0,0 +1,33 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetAccountNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetAccountNumber] +GO + +-- ==================================================== +-- Author: Magic Software +-- Create date: 23-Dec-2009 +-- Description: To get the details of all discounts +-- ==================================================== +CREATE PROCEDURE [dbo].[usp_GetAccountNumber] + -- Add the parameters for the stored procedure here + +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + SELECT License.Id,License.AccountNumber FROM License +INNER JOIN LicenseType ON LicenseType.Id = License.LicenseTypeId +WHERE License.IsActive = 1 +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetProductEditionByLicense.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetProductEditionByLicense.sql new file mode 100644 index 0000000..9459877 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_GetProductEditionByLicense.sql @@ -0,0 +1,34 @@ +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetProductEdition]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetProductEdition] +GO + +-- ==================================================== +-- Author: Magic Software +-- Create date: 23-Dec-2009 +-- Description: To get the details of all discounts +-- ==================================================== +CREATE PROCEDURE [dbo].[usp_GetProductEdition] + -- Add the parameters for the stored procedure here + @iLicenseId int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + SELECT Edition.Id, Edition.Title, Edition.IsActive, Edition.Priority + FROM Edition + INNER JOIN LicenseToEdition ON Edition.Id = LicenseToEdition.EditionId + WHERE LicenseToEdition.LicenseId =@iLicenseId +END + +GO +SET QUOTED_IDENTIFIER OFF +GO +SET ANSI_NULLS ON +GO + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj index b95b54a..8ed5690 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj @@ -709,9 +709,15 @@ AIADBEntity.tt + + AIADBEntity.tt + AIADBEntity.tt + + AIADBEntity.tt + AIADBEntity.tt @@ -796,7 +802,9 @@ - + + Designer + Web.config diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index 787c1d6..6d44961 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -16,13 +16,17 @@ using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { - [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + // [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("User")] public class UserController : ApiController { AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); - [Route("Api/GetUserProfile/{userId}")] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + [Route("GetUserProfile/{userId}")] [HttpGet] public IHttpActionResult GetUserProfile(int userId) { @@ -38,7 +42,7 @@ namespace AIAHTML5.ADMIN.API.Controllers //return ToJson(dbContext.AIAUsers.Where(u => u.Id == userId).AsEnumerable()); } - [Route("Api/UpdateProfile")] + [Route("UpdateProfile")] [HttpPost] public HttpResponseMessage UpdateUserProfile(UserModel userInfo) { @@ -61,7 +65,7 @@ namespace AIAHTML5.ADMIN.API.Controllers return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } } - [Route("Api/ChangeUserPassword")] + [Route("ChangeUserPassword")] [HttpPost] public HttpResponseMessage UpdateUserPassword(JObject jsonData) { @@ -86,7 +90,7 @@ namespace AIAHTML5.ADMIN.API.Controllers return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } } - [Route("Api/UpdateUserId")] + [Route("UpdateUserId")] [HttpPost] public HttpResponseMessage UpdateUserId(UserModel userInfo) { @@ -114,8 +118,8 @@ namespace AIAHTML5.ADMIN.API.Controllers } } - #region USERS - [Route("Api/GetUserType/{UserTypeId}")] + #region USERS List + [Route("GetUserType/{UserTypeId}")] [HttpGet] public IHttpActionResult GetUserType(int UserTypeId) { @@ -127,7 +131,7 @@ namespace AIAHTML5.ADMIN.API.Controllers return Ok(userTypelist); } - [Route("Api/GetAccountType/{AccountTypeId}")] + [Route("GetAccountType/{AccountTypeId}")] [HttpGet] public IHttpActionResult GetAccountType(int AccountTypeId) { @@ -135,7 +139,7 @@ namespace AIAHTML5.ADMIN.API.Controllers return Ok(AccountTypeModel.GetAccountTypeList(dbContext, AccountTypeId)); } - [Route("Api/Users")] + [Route("Users")] [HttpGet] public IHttpActionResult UserList(string firstname, string lastname, string emailid, string accountnumber, string usertypeid, string accounttypeid) { @@ -145,7 +149,46 @@ namespace AIAHTML5.ADMIN.API.Controllers List Users = dbContext.GetSearchUserList(firstname, lastname, emailid, accountnumber, UserTypeId, AccountTypeId, 1).ToList(); return Ok(Users); } + #endregion + #region Add User + [Route("GetUserTypebyLicenseId")] + [HttpGet] + public IHttpActionResult GetUserTypebyLicenseId(short UserTypeId, int LicenseId) + { + dbContext.Configuration.ProxyCreationEnabled = false; + List userTypelist = new List(); + var userTypeEntity = dbContext.GetUserTyeByAccountNumber((byte)UserTypeId, LicenseId).ToList(); + userTypelist = userTypeEntity.Select(l => new GetUserTyeByAccountNumber_Result() { Id = l.Id, Title = l.Title }).ToList(); + //userTypelist.Insert(0, new UserType { Id = 0, Title = "All" }); + return Ok(userTypelist); + } + + [Route("GetAccountNumber")] + [HttpGet] + public IHttpActionResult GetAccountNumber() + { + dbContext.Configuration.ProxyCreationEnabled = false; + List AccountNumberList = new List(); + var AccountNumberEntity = dbContext.usp_GetAccountNumber().ToList(); + AccountNumberList = AccountNumberEntity.Select(l => new usp_GetAccountNumber_Result() { Id = l.Id, AccountNumber = l.AccountNumber }).ToList(); + //userTypelist.Insert(0, new UserType { Id = 0, Title = "All" }); + return Ok(AccountNumberList); + } + + [Route("GetAccountNumber")] + [HttpGet] + public IHttpActionResult GetProductEditionByLicense(int LicenseId) + { + dbContext.Configuration.ProxyCreationEnabled = false; + List ProductEditionList = new List(); + var ProductEditionListEntity = dbContext.usp_GetProductEditionByLicense(LicenseId).ToList(); + ProductEditionList = ProductEditionListEntity.Select(l => new usp_GetProductEditionByLicense_Result() { Id = l.Id, Title = l.Title }).ToList(); + //userTypelist.Insert(0, new UserType { Id = 0, Title = "All" }); + return Ok(ProductEditionList); + } + #endregion + protected HttpResponseMessage ToJson(dynamic obj) { var response = Request.CreateResponse(HttpStatusCode.OK); diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs index 51c237c..6cbdeac 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs @@ -2922,5 +2922,19 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateUserId", idParameter, userIdParameter, olduserIdParameter, status); } + + public virtual ObjectResult usp_GetAccountNumber() + { + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetAccountNumber"); + } + + public virtual ObjectResult usp_GetProductEditionByLicense(Nullable iLicenseId) + { + var iLicenseIdParameter = iLicenseId.HasValue ? + new ObjectParameter("iLicenseId", iLicenseId) : + new ObjectParameter("iLicenseId", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetProductEditionByLicense", iLicenseIdParameter); + } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index 1593a5d..c3dee0b 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -2615,9 +2615,13 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does + + + + @@ -6052,10 +6056,10 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - + - + @@ -6063,6 +6067,10 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + @@ -6870,6 +6878,16 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + @@ -9176,6 +9194,24 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetAccountNumber_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetAccountNumber_Result.cs new file mode 100644 index 0000000..de02002 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetAccountNumber_Result.cs @@ -0,0 +1,19 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetAccountNumber_Result + { + public int Id { get; set; } + public string AccountNumber { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetProductEditionByLicense_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetProductEditionByLicense_Result.cs new file mode 100644 index 0000000..fedd99a --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetProductEditionByLicense_Result.cs @@ -0,0 +1,21 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AIAHTML5.ADMIN.API.Entity +{ + using System; + + public partial class usp_GetProductEditionByLicense_Result + { + public byte Id { get; set; } + public string Title { get; set; } + public bool IsActive { get; set; } + public byte Priority { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Web.config b/400-SOURCECODE/AIAHTML5.ADMIN.API/Web.config index 12d077d..5308430 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Web.config +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Web.config @@ -53,11 +53,26 @@ - + + + + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index ab82845..b8d269d 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -1,114 +1,114 @@ -AIA.factory('AuthenticationService', function ($http, $q, $rootScope, LoginConstants) { - return { - authenticateUser: function (userInfo) { - var deferred = $q.defer(); - - $http.post('/API/api/Authenticate', JSON.stringify(userInfo), { - headers: { - 'Content-Type': 'application/json' - } - }) - .success(function (data, status, headers, config) { - console.log('success') - deferred.resolve(data); - }).error(function (data, status, headers, config) { - console.log('error') - deferred.reject(data); - $rootScope.isVisibleLogin = true; - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); - - }); - return deferred.promise; - }, - - SendMailToUser: function (userInfo, havePassword) { - var deferred = $q.defer(); - - $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail) - headers: { - 'Content-Type': 'application/json' - } - }) - .success(function (data, status, headers, config) { - console.log('success'); - deferred.resolve(data); - }).error(function (data, status, headers, config) { - console.log('error') - deferred.reject(data); - - $rootScope.isVisibleLogin = true; - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); - }); - return deferred.promise; - }, - - ResetUserPassword: function (userInfo) { - var deferred = $q.defer(); - - $http.post('/API/api/ResetPassword', JSON.stringify(userInfo), { - headers: { - 'Content-Type': 'application/json' - } - }) - .success(function (data, status, headers, config) { - console.log('success') - deferred.resolve(data); - }).error(function (data, status, headers, config) { - console.log('error') - deferred.reject(data); - - $rootScope.isVisibleLogin = true; - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); - }); - return deferred.promise; - }, - - UpdateLicenseTerm: function (licenseeAccountNumber) { - var deferred = $q.defer(); - - $http.post('/API/api/LicenseTermCondition', JSON.stringify(licenseeAccountNumber), { - headers: { - 'Content-Type': 'application/json' - } - }) - .success(function (data, status, headers, config) { - console.log('success') - deferred.resolve(data); - }).error(function (data, status, headers, config) { - console.log('error') - deferred.reject(data); - - $rootScope.isVisibleLogin = true; - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); - }); - return deferred.promise; - }, - - UnblockUser: function (userEmailId) { - var deferred = $q.defer(); - - $http.post('/API/api/UnblockUser', JSON.stringify(userEmailId), { - headers: { - 'Content-Type': 'application/json' - } - }) - .success(function (data, status, headers, config) { - console.log('success') - deferred.resolve(data); - }).error(function (data, status, headers, config) { - console.log('error') - deferred.reject(data); - - $rootScope.isVisibleLogin = true; - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); - }); - return deferred.promise; - } - - } +AIA.factory('AuthenticationService', function ($http, $q, $rootScope, LoginConstants) { + return { + authenticateUser: function (userInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/Authenticate', JSON.stringify(userInfo), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, + + SendMailToUser: function (userInfo, havePassword) { + var deferred = $q.defer(); + + $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail) + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success'); + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + }); + return deferred.promise; + }, + + ResetUserPassword: function (userInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/ResetPassword', JSON.stringify(userInfo), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + }); + return deferred.promise; + }, + + UpdateLicenseTerm: function (licenseeAccountNumber) { + var deferred = $q.defer(); + + $http.post('/API/api/LicenseTermCondition', JSON.stringify(licenseeAccountNumber), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + }); + return deferred.promise; + }, + + UnblockUser: function (userEmailId) { + var deferred = $q.defer(); + + $http.post('/API/api/UnblockUser', JSON.stringify(userEmailId), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + }); + return deferred.promise; + } + + } }); \ No newline at end of file -- libgit2 0.21.4