diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetBlockedUserByAccNoAndType.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetBlockedUserByAccNoAndType.sql new file mode 100644 index 0000000..a76c582 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetBlockedUserByAccNoAndType.sql @@ -0,0 +1,39 @@ + +-- ============================================= +-- Author: Magic Software +-- Create date: 12-May-2009 +-- Description: To get the list of blocked user who have attempt 5 times wrong login +-- ============================================= +CREATE PROCEDURE [dbo].[GetBlockedUserByAccNoAndType] + -- Add the parameters for the stored procedure here + @iUserTypeId tinyint, @iLicenseId int +AS +BEGIN + -- returns the metadata + IF 1=0 BEGIN + SET FMTONLY OFF + END + SELECT DISTINCT + AIAUser.Id, + AIAUser.FirstName, + AIAUser.LastName, + AIAUser.LoginId, + AIAUser.Password, + AIAUser.EmailId, + ISNULL(License.AccountNumber,'') AccountNumber, + IncorrectLoginAttempts.LoginTime + FROM + IncorrectLoginAttempts + INNER JOIN AIAUser ON IncorrectLoginAttempts.UserId = AIAUser.Id + INNER JOIN UserType ON AIAUser.UserTypeId = UserType.Id + LEFT JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId + LEFT JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id + LEFT JOIN License ON LicenseToEdition.LicenseId = License.Id + WHERE + IncorrectLoginAttempts.CntIncorrectLogins >= 5 + AND UserType.Priority >= (SELECT UserType.Priority FROM UserType WHERE UserType.Id=@iUserTypeId) + AND ((@iLicenseId =0) OR (License.Id = @iLicenseId)) + AND License.IsActive = 1 +END + + diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql index 0a8fc0a..c1acfbd 100644 --- a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.GetSearchUserList.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_InsertAIAUser.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_InsertAIAUser.sql new file mode 100644 index 0000000..f06166c --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_InsertAIAUser.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateAIAUser.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateAIAUser.sql new file mode 100644 index 0000000..52c1b70 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateAIAUser.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateblockedUser.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateblockedUser.sql new file mode 100644 index 0000000..2edab9f --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/dbo.usp_UpdateblockedUser.sql @@ -0,0 +1,53 @@ + +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_NULLS ON +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateblockedUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_UpdateblockedUser] +GO + + +-- ============================================= +-- Author: +-- Create date: <3-Jan-2018> +-- Description: +-- ============================================= +CREATE PROCEDURE [dbo].[usp_UpdateblockedUser]--6,'aiaonline1','aiaonline',0 + -- Add the parameters for the stored procedure here + @Id int, + @Status int out +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + BEGIN TRY + + + + BEGIN TRANSACTION + DELETE from IncorrectLoginAttempts where UserId =@Id + set @Status = 1; + COMMIT TRANSACTION + --select '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/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj index 2fb41ca..59285cf 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/AIAHTML5.ADMIN.API.csproj @@ -719,6 +719,9 @@ AIADBEntity.tt + + AIADBEntity.tt + AIADBEntity.tt diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index d35ac87..ae24dcf 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -16,7 +16,7 @@ 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 { @@ -146,10 +146,51 @@ namespace AIAHTML5.ADMIN.API.Controllers int UserTypeId = (!string.IsNullOrEmpty(usertypeid) ? Convert.ToInt32(usertypeid) : 0); int AccountTypeId = (!string.IsNullOrEmpty(accounttypeid) ? Convert.ToInt32(accounttypeid) : 0); dbContext.Configuration.ProxyCreationEnabled = false; - List Users = dbContext.GetSearchUserList(firstname, lastname, emailid, accountnumber, UserTypeId, AccountTypeId, 1).ToList(); + List Users = dbContext.usp_GetSearchUserList(firstname, lastname, emailid, accountnumber, UserTypeId, AccountTypeId, 1).ToList(); return Ok(Users); } + [Route("UpdateUser")] + [HttpPost] + public HttpResponseMessage UpdateUser(JObject jsonUserData) + { + string Status = string.Empty; + UserModel UserEntity = new UserModel(); + UserEntity.Id = jsonUserData["id"].Value(); + UserEntity.FirstName = jsonUserData["FirstName"].Value(); + UserEntity.LastName = jsonUserData["LastName"].Value(); + UserEntity.EmailId = jsonUserData["EmailId"].Value(); + UserEntity.LoginId = jsonUserData["UserName"].Value(); + UserEntity.Password = jsonUserData["Password"].Value(); + UserEntity.IsActive = jsonUserData["IsActive"].Value(); + UserEntity.CreatorId = jsonUserData["Modifiedby"].Value(); + try + { + Status = UserModel.UpdateUser(dbContext, UserEntity); + if (Status.Equals("1")) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, "User Name already exist"); + } + else if (Status.Equals("2")) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, "Email Id already exist"); + } + else if (Status.Equals("3")) + { + return Request.CreateResponse(HttpStatusCode.OK, "User updated successfully"); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We have encountered a technical error and same has been notified to our technical team."); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We have encountered a technical error and same has been notified to our technical team."); + } + } + #endregion #region Add User [Route("GetUserTypebyLicenseId")] @@ -161,6 +202,10 @@ namespace AIAHTML5.ADMIN.API.Controllers List userTypelist = new List(); var userTypeEntity = dbContext.GetUserTyeByAccountNumber((byte)UserType, LicenseId).ToList(); userTypelist = userTypeEntity.Select(l => new GetUserTyeByAccountNumber_Result() { Id = l.Id, Title = l.Title }).ToList(); + if (userTypelist != null && userTypelist.Count==0) + { + userTypelist.Insert(0, new GetUserTyeByAccountNumber_Result { Id = 2, Title = "General Admin" }); + } //userTypelist.Insert(0, new UserType { Id = 0, Title = "All" }); return Ok(userTypelist); } @@ -188,8 +233,88 @@ namespace AIAHTML5.ADMIN.API.Controllers //userTypelist.Insert(0, new UserType { Id = 0, Title = "All" }); return Ok(ProductEditionList); } + + [Route("NewUser")] + [HttpPost] + public HttpResponseMessage InsertUser(JObject jsonUserData) + { + string Status = string.Empty; + UserModel UserEntity = new UserModel(); + UserEntity.Id = jsonUserData["id"].Value(); + UserEntity.FirstName = jsonUserData["FirstName"].Value(); + UserEntity.LastName = jsonUserData["LastName"].Value(); + UserEntity.EmailId = jsonUserData["EmailId"].Value(); + UserEntity.LoginId = jsonUserData["UserName"].Value(); + UserEntity.Password = jsonUserData["Password"].Value(); + UserEntity.LicenseId = jsonUserData["AccountNumberId"].Value(); + UserEntity.iUserTypeId = jsonUserData["UserTypeId"].Value(); + UserEntity.EditionId = jsonUserData["ProductEditionId"].Value(); + + try + { + Status = UserModel.InsertUser(dbContext, UserEntity); + if (Status.Equals("1")) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, "User Name already exist"); + } + else if (Status.Equals("2")) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, "Email Id already exist"); + } + else if (Status.Equals("3")) + { + return Request.CreateResponse(HttpStatusCode.OK, "User added successfully"); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We have encountered a technical error and same has been notified to our technical team."); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "We have encountered a technical error and same has been notified to our technical team."); + } + } + #endregion + + #region UnBlock Users + [Route("BlockedUser")] + [HttpGet] + public IHttpActionResult GetBlockedUserByAccNoAndType(int UserTypeId, int LicenseId) + { + dbContext.Configuration.ProxyCreationEnabled = false; + List Users = dbContext.GetBlockedUserByAccNoAndType((byte)UserTypeId, LicenseId).ToList(); + return Ok(Users); + } + [Route("UnblockedUser")] + [HttpPost] + public HttpResponseMessage UnblockedUser(List UserIds) + { + bool Status = false; + try + { + Status = UserModel.UpdateUnblockedUser(dbContext, UserIds); + Status = true; + if (Status) + { + return Request.CreateResponse(HttpStatusCode.OK, Status.ToString()); + } + else + { + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Status.ToString()); + } + } + catch (Exception ex) + { + // Log exception code goes here + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); + } + } + #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 856bb93..eea7734 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs @@ -1794,7 +1794,7 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction>("IncorrectLoginAttempt", iUserIdParameter); } - public virtual ObjectResult InsertAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, Nullable iUserTypeId, string sEmailId, Nullable iSecurityQuesId, string sSecurityAnswer, Nullable iCreatorId, Nullable iLicenseId, Nullable iEditionId) + public virtual ObjectResult InsertAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, Nullable iUserTypeId, string sEmailId, Nullable iSecurityQuesId, string sSecurityAnswer, Nullable iCreatorId, Nullable iLicenseId, Nullable iEditionId, ObjectParameter status) { var sLoginIdParameter = sLoginId != null ? new ObjectParameter("sLoginId", sLoginId) : @@ -1840,7 +1840,7 @@ namespace AIAHTML5.ADMIN.API.Entity new ObjectParameter("iEditionId", iEditionId) : new ObjectParameter("iEditionId", typeof(byte)); - return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("InsertAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, iUserTypeIdParameter, sEmailIdParameter, iSecurityQuesIdParameter, sSecurityAnswerParameter, iCreatorIdParameter, iLicenseIdParameter, iEditionIdParameter); + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("InsertAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, iUserTypeIdParameter, sEmailIdParameter, iSecurityQuesIdParameter, sSecurityAnswerParameter, iCreatorIdParameter, iLicenseIdParameter, iEditionIdParameter, status); } public virtual int InsertDemoLicenseAccount() @@ -3012,5 +3012,133 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateSubscriptionPlan", idParameter, titleParameter, priceParameter, durationParameter, editionIdParameter, isActiveParameter, status); } + + public virtual int usp_InsertAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, Nullable iUserTypeId, string sEmailId, Nullable iSecurityQuesId, string sSecurityAnswer, Nullable iCreatorId, Nullable iLicenseId, Nullable iEditionId, ObjectParameter status) + { + var sLoginIdParameter = sLoginId != null ? + new ObjectParameter("sLoginId", sLoginId) : + new ObjectParameter("sLoginId", typeof(string)); + + var sPasswordParameter = sPassword != null ? + new ObjectParameter("sPassword", sPassword) : + new ObjectParameter("sPassword", typeof(string)); + + var sFirstnameParameter = sFirstname != null ? + new ObjectParameter("sFirstname", sFirstname) : + new ObjectParameter("sFirstname", typeof(string)); + + var sLastnameParameter = sLastname != null ? + new ObjectParameter("sLastname", sLastname) : + new ObjectParameter("sLastname", typeof(string)); + + var iUserTypeIdParameter = iUserTypeId.HasValue ? + new ObjectParameter("iUserTypeId", iUserTypeId) : + new ObjectParameter("iUserTypeId", typeof(byte)); + + var sEmailIdParameter = sEmailId != null ? + new ObjectParameter("sEmailId", sEmailId) : + new ObjectParameter("sEmailId", typeof(string)); + + var iSecurityQuesIdParameter = iSecurityQuesId.HasValue ? + new ObjectParameter("iSecurityQuesId", iSecurityQuesId) : + new ObjectParameter("iSecurityQuesId", typeof(byte)); + + var sSecurityAnswerParameter = sSecurityAnswer != null ? + new ObjectParameter("sSecurityAnswer", sSecurityAnswer) : + new ObjectParameter("sSecurityAnswer", typeof(string)); + + var iCreatorIdParameter = iCreatorId.HasValue ? + new ObjectParameter("iCreatorId", iCreatorId) : + new ObjectParameter("iCreatorId", typeof(int)); + + var iLicenseIdParameter = iLicenseId.HasValue ? + new ObjectParameter("iLicenseId", iLicenseId) : + new ObjectParameter("iLicenseId", typeof(int)); + + var iEditionIdParameter = iEditionId.HasValue ? + new ObjectParameter("iEditionId", iEditionId) : + new ObjectParameter("iEditionId", typeof(byte)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_InsertAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, iUserTypeIdParameter, sEmailIdParameter, iSecurityQuesIdParameter, sSecurityAnswerParameter, iCreatorIdParameter, iLicenseIdParameter, iEditionIdParameter, status); + } + + public virtual int usp_UpdateblockedUser(Nullable id, ObjectParameter status) + { + var idParameter = id.HasValue ? + new ObjectParameter("Id", id) : + new ObjectParameter("Id", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateblockedUser", idParameter, status); + } + + public virtual ObjectResult usp_GetSearchUserList(string sFirstName, string sLastName, string sEmailId, string sAccoutNumber, Nullable iUserTypeId, Nullable iAccountTypeId, Nullable iLoginUserType) + { + var sFirstNameParameter = sFirstName != null ? + new ObjectParameter("sFirstName", sFirstName) : + new ObjectParameter("sFirstName", typeof(string)); + + var sLastNameParameter = sLastName != null ? + new ObjectParameter("sLastName", sLastName) : + new ObjectParameter("sLastName", typeof(string)); + + var sEmailIdParameter = sEmailId != null ? + new ObjectParameter("sEmailId", sEmailId) : + new ObjectParameter("sEmailId", typeof(string)); + + var sAccoutNumberParameter = sAccoutNumber != null ? + new ObjectParameter("sAccoutNumber", sAccoutNumber) : + new ObjectParameter("sAccoutNumber", typeof(string)); + + var iUserTypeIdParameter = iUserTypeId.HasValue ? + new ObjectParameter("iUserTypeId", iUserTypeId) : + new ObjectParameter("iUserTypeId", typeof(int)); + + var iAccountTypeIdParameter = iAccountTypeId.HasValue ? + new ObjectParameter("iAccountTypeId", iAccountTypeId) : + new ObjectParameter("iAccountTypeId", typeof(int)); + + var iLoginUserTypeParameter = iLoginUserType.HasValue ? + new ObjectParameter("iLoginUserType", iLoginUserType) : + new ObjectParameter("iLoginUserType", typeof(int)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_GetSearchUserList", sFirstNameParameter, sLastNameParameter, sEmailIdParameter, sAccoutNumberParameter, iUserTypeIdParameter, iAccountTypeIdParameter, iLoginUserTypeParameter); + } + + public virtual int usp_UpdateAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, string sEmailId, Nullable id, Nullable iCreatorId, Nullable isActive, ObjectParameter status) + { + var sLoginIdParameter = sLoginId != null ? + new ObjectParameter("sLoginId", sLoginId) : + new ObjectParameter("sLoginId", typeof(string)); + + var sPasswordParameter = sPassword != null ? + new ObjectParameter("sPassword", sPassword) : + new ObjectParameter("sPassword", typeof(string)); + + var sFirstnameParameter = sFirstname != null ? + new ObjectParameter("sFirstname", sFirstname) : + new ObjectParameter("sFirstname", typeof(string)); + + var sLastnameParameter = sLastname != null ? + new ObjectParameter("sLastname", sLastname) : + new ObjectParameter("sLastname", typeof(string)); + + var sEmailIdParameter = sEmailId != null ? + new ObjectParameter("sEmailId", sEmailId) : + new ObjectParameter("sEmailId", typeof(string)); + + var idParameter = id.HasValue ? + new ObjectParameter("id", id) : + new ObjectParameter("id", typeof(int)); + + var iCreatorIdParameter = iCreatorId.HasValue ? + new ObjectParameter("iCreatorId", iCreatorId) : + new ObjectParameter("iCreatorId", typeof(int)); + + var isActiveParameter = isActive.HasValue ? + new ObjectParameter("isActive", isActive) : + new ObjectParameter("isActive", typeof(byte)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, sEmailIdParameter, idParameter, iCreatorIdParameter, isActiveParameter, status); + } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index e3c150c..378a5b6 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -2328,6 +2328,7 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does + @@ -2626,12 +2627,35 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does + + + + + + + + + + + + + + + + + + + + + + + @@ -2641,6 +2665,21 @@ warning 6002: The table/view 'AIADatabaseV5.dbo.VocabTermNumberToSystemMap' does + + + + + + + + + + + + + + + @@ -5793,6 +5832,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -6101,7 +6141,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - + @@ -6121,6 +6161,44 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6946,6 +7024,26 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + @@ -9285,6 +9383,33 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSearchUserList_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSearchUserList_Result.cs new file mode 100644 index 0000000..30b21ce --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSearchUserList_Result.cs @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// +// 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_GetSearchUserList_Result + { + public Nullable Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string LoginId { get; set; } + public string EmailId { get; set; } + public string UserTypeTitle { get; set; } + public string Password { get; set; } + public Nullable CreationDate { get; set; } + public Nullable ModifiedDate { get; set; } + public string AccountNumber { get; set; } + public string AccountTypeTitle { get; set; } + public string EditionType { get; set; } + public string UserStatus { get; set; } + public Nullable UserTypeId { get; set; } + public Nullable EditionTypeId { get; set; } + public string Createdby { get; set; } + public string Modifiedby { get; set; } + public Nullable DeactivationDate { get; set; } + } +} diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs index b753b45..f840952 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs @@ -24,6 +24,10 @@ namespace AIAHTML5.ADMIN.API.Models public DateTime ModifiedDate { get; set; } public int UserTypeId { get; set; } public bool IsActive { get; set; } + public int LicenseId { get; set; } + public int EditionId { get; set; } + public short iUserTypeId { get; set; } + public static bool UpdateUserProfile(AIADatabaseV5Entities dbContext, int intUserID, string strFirstName, string strLastName, string strEmailID) { @@ -84,5 +88,53 @@ namespace AIAHTML5.ADMIN.API.Models return ex.Message; } } + public static string InsertUser(AIADatabaseV5Entities dbContext,UserModel UserEntity) + { + var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); + short questionId = 0; + short EditionId=(short) UserEntity.EditionId; + try + { + dbContext.usp_InsertAIAUser(UserEntity.LoginId, UserEntity.Password, UserEntity.FirstName, UserEntity.LastName, (byte)UserEntity.iUserTypeId, UserEntity.EmailId, (byte)questionId, null, UserEntity.Id, UserEntity.LicenseId, (byte)EditionId, spStatus); + return spStatus.Value.ToString(); + } + catch(Exception ex) + { + return ex.Message; + } + } + public static string UpdateUser(AIADatabaseV5Entities dbContext, UserModel UserEntity) + { + var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); + short questionId = 0; + short EditionId = (short)UserEntity.EditionId; + try + { + dbContext.usp_UpdateAIAUser(UserEntity.LoginId, UserEntity.Password, UserEntity.FirstName, UserEntity.LastName,UserEntity.EmailId,UserEntity.Id,UserEntity.CreatorId,(UserEntity.IsActive ? (byte)1 :(byte)0),spStatus); + return spStatus.Value.ToString(); + } + catch (Exception ex) + { + return ex.Message; + } + } + + public static bool UpdateUnblockedUser(AIADatabaseV5Entities dbContext, List ids) + { + var spStatus = new System.Data.Objects.ObjectParameter("Status", 0); + try + { + foreach (var item in ids) + { + dbContext.usp_UpdateblockedUser(item, spStatus); + if (spStatus.Value.ToString()!="1") break; + } + return (spStatus.Value.ToString()=="1"?true:false); + } + catch (Exception ex) + { + return false; + } + } } } \ No newline at end of file diff --git a/400-SOURCECODE/Admin/src/app/app.component.html b/400-SOURCECODE/Admin/src/app/app.component.html index 17a5229..1664565 100644 --- a/400-SOURCECODE/Admin/src/app/app.component.html +++ b/400-SOURCECODE/Admin/src/app/app.component.html @@ -60,7 +60,7 @@ diff --git a/400-SOURCECODE/Admin/src/app/app.module.ts b/400-SOURCECODE/Admin/src/app/app.module.ts index bc079b8..7dcf747 100644 --- a/400-SOURCECODE/Admin/src/app/app.module.ts +++ b/400-SOURCECODE/Admin/src/app/app.module.ts @@ -15,6 +15,7 @@ import { ChangeUserPassword } from './components/UserEntity/changeuserpassword.c import { ChangeUserID } from './components/UserEntity/changeuserid.component'; import { UsersList } from './components/UserEntity/users.component'; import { AddUser } from './components/UserEntity/adduser.component'; +import { UnblockUser } from './components/UserEntity/unblockuser.component'; import { ManageDiscountCode } from './components/ManageDiscountCode/managediscountcode.component'; import { SubscriptionPrice } from './components/SubscriptionPrice/subscriptionprice.component'; import { AppComponent } from './app.component'; @@ -28,11 +29,12 @@ import { ConfirmComponent } from "./Shared/Confirm/confirm.component" import { BsDatepickerModule, ModalModule } from 'ngx-bootstrap'; import { BsModalService } from 'ngx-bootstrap/modal'; import { ContenteditableModelDirective } from './shared/contenteditabledirective'; +import { LoadingService } from './shared/loading.service'; @NgModule({ declarations: [ ChangeUserPassword, ChangeUserID, UpdateUserProfile, UsersList, - ManageDiscountCode, AddUser, + ManageDiscountCode, AddUser, UnblockUser, AppComponent, ConfirmComponent, SubscriptionPrice, ManageDiscountCode, ContenteditableModelDirective ], @@ -40,7 +42,7 @@ import { ContenteditableModelDirective } from './shared/contenteditabledirective BrowserModule, AppRoutingModule, HttpClientModule, FormsModule, ReactiveFormsModule, HttpModule, Ng2Bs3ModalModule, BsDatepickerModule.forRoot(), ModalModule.forRoot()//ModalModule.forRoot() ], - providers: [GlobalService, ConfirmService, BsModalService, + providers: [GlobalService, ConfirmService, BsModalService, LoadingService, //AuthService, //AuthGuard, //{ @@ -48,8 +50,8 @@ import { ContenteditableModelDirective } from './shared/contenteditabledirective // useClass: MyInterceptor, // multi: true //} - //{ provide: APP_BASE_HREF, useValue: '/Admin-UI' } - { provide: APP_BASE_HREF, useValue: '/' } + { provide: APP_BASE_HREF, useValue: '/Admin-UI' } + //{ provide: APP_BASE_HREF, useValue: '/' } ], bootstrap: [AppComponent] diff --git a/400-SOURCECODE/Admin/src/app/app.routing.module.ts b/400-SOURCECODE/Admin/src/app/app.routing.module.ts index 47cafb1..02aff2d 100644 --- a/400-SOURCECODE/Admin/src/app/app.routing.module.ts +++ b/400-SOURCECODE/Admin/src/app/app.routing.module.ts @@ -4,6 +4,7 @@ import { UpdateUserProfile } from './components/UserEntity/updateuserprofile.com import { ChangeUserPassword } from './components/UserEntity/changeuserpassword.component'; import { ChangeUserID } from './components/UserEntity/changeuserid.component'; import { UsersList } from './components/UserEntity/users.component'; +import { UnblockUser } from './components/UserEntity/unblockuser.component'; import { ManageDiscountCode } from './components/ManageDiscountCode/managediscountcode.component'; import { SubscriptionPrice } from './components/SubscriptionPrice/subscriptionprice.component'; import { AddUser } from './components/UserEntity/adduser.component'; @@ -16,6 +17,7 @@ const appRoutes: Routes = [ { path: 'managediscountcode', component: ManageDiscountCode }, { path: 'subscriptionprice', component: SubscriptionPrice }, { path: 'adduser', component: AddUser }, + { path: 'unblockuser', component: UnblockUser }, ]; @NgModule({ diff --git a/400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.service.ts b/400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.service.ts index 8c92b78..1ebf881 100644 --- a/400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.service.ts +++ b/400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.service.ts @@ -20,7 +20,7 @@ export class ManageDiscountCodeService { if(obj.endDate == ''){ obj.endDate = '1/1/9999'; } - return this.http.get(this.commonService.DiscountBaseUrl + "/GetDiscountCodes?discountCode=" + return this.http.get(this.commonService.resourceBaseUrl + "DiscountCode/GetDiscountCodes?discountCode=" + obj.discountCode + "&startDate=" + obj.startDate + "&endDate=" + obj.endDate) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -33,7 +33,7 @@ export class ManageDiscountCodeService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.DiscountBaseUrl + "/InsertDiscountCode", + return this.http.post(this.commonService.resourceBaseUrl + "DiscountCode/InsertDiscountCode", JSON.stringify(jsonData), {headers: headers}) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -46,7 +46,7 @@ export class ManageDiscountCodeService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.DiscountBaseUrl + "/UpdateDiscountCode", + return this.http.post(this.commonService.resourceBaseUrl + "DiscountCode/UpdateDiscountCode", JSON.stringify(jsonData), {headers: headers}) .map(this.extractData) .catch((res: Response) => this.handleError(res)); diff --git a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts index 1ec813e..f851e3f 100644 --- a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts +++ b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts @@ -15,7 +15,7 @@ export class SubscriptionPriceService { GetSubscriptionPrices(obj: any) { - return this.http.get(this.commonService.SubscriptionBaseUrl + "/GetSubscriptionPrices?editionId=" + return this.http.get(this.commonService.resourceBaseUrl + "SubscriptionPrice/GetSubscriptionPrices?editionId=" + obj.editionId) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -28,7 +28,7 @@ export class SubscriptionPriceService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.SubscriptionBaseUrl + "/InsertSubscriptionPrice", + return this.http.post(this.commonService.resourceBaseUrl + "SubscriptionPrice/InsertSubscriptionPrice", JSON.stringify(jsonData), {headers: headers}) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -41,7 +41,7 @@ export class SubscriptionPriceService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.SubscriptionBaseUrl + "/UpdateSubscriptionPrices", + return this.http.post(this.commonService.resourceBaseUrl + "SubscriptionPrice/UpdateSubscriptionPrices", JSON.stringify(jsonData), {headers: headers}) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -54,7 +54,7 @@ export class SubscriptionPriceService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.SubscriptionBaseUrl + "/DeleteSubscriptionPrices", + return this.http.post(this.commonService.resourceBaseUrl + "SubscriptionPrice/DeleteSubscriptionPrices", subscriptionPriceIds, {headers: headers}) .map(this.extractData) .catch((res: Response) => this.handleError(res)); diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html index e6d5cfe..c1652e5 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html @@ -11,17 +11,19 @@
-
+
+
- + +
User Name is required
@@ -29,37 +31,47 @@
(Minimum 8 characters) +
Password of minimum 8 characters is required
- + +
Confirm Password is required
- + +
Email Id is required
+ +
+ Please enter the correct email. +
- + +
First Name is required
- + +
Last Name is required
- + +
@@ -67,23 +79,24 @@
- +
-
- + +
- + - - + +
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts index 510ea88..0ae8f39 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts @@ -12,7 +12,7 @@ import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; - +import { LoadingService } from '../../shared/loading.service'; @Component({ templateUrl:'./adduser.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' @@ -34,18 +34,19 @@ export class AddUser implements OnInit { //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; - constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, private _confirmService: ConfirmService, private commonService: GlobalService ) { } ngOnInit(): void { + this.user = new User(); this.alerts = ''; //this.userservice.GetUserById(this.UserId); this.adduserFrm = this.fb.group({ id: [''], UserName: ['', Validators.required], - Password: ['', Validators.required], + Password: ['', [Validators.required, Validators.minLength(8)]], ConfirmPassword: ['', Validators.required], FirstName: ['', Validators.required], LastName: ['', Validators.required], @@ -54,8 +55,15 @@ export class AddUser implements OnInit { UserTypeId: ['', Validators.required], ProductEditionId: ['', Validators.required] }); - //this.GetAccountNumber(); + debugger + this._loadingService.ShowLoading("global-loading"); + this.bindUsers(); + this.GetAccountNumber(); this.GetUserTypeByLicenseId(); + this._loadingService.HideLoading("global-loading"); + } + redirect() { + this.router.navigate(['/']); } GetUserTypeByLicenseId() { debugger; @@ -66,7 +74,7 @@ export class AddUser implements OnInit { }).subscribe(x => { this.UserTypeList = x; }, error => this.error = error); } GetAccountNumber() { - + this.userservice.GetAccountNumber() .subscribe(x => { console.log(x); this.AccountNumberList=x }, error => this.error = error); } @@ -75,46 +83,98 @@ export class AddUser implements OnInit { AccountNumberId: this.adduserFrm.controls['AccountNumberId'].value}) .subscribe(x => { console.log(x); this.ProductEditionList=x }, error => this.error = error); } - UpdateUserProfile(this) { - // debugger; - this.user = this.adduserFrm.value; - //if(this.user.) - //console.log(this.user); - var obj = this.user - if (this.adduserFrm.valid) { - return this.userservice.UpdateUserProfileById(obj) + BindUserTypeAndProductEdition(deviceValue) { + + this.GetUserTypeByLicenseId(); + this.GetProductEdition(); + } + public AddUser(this) { + this.alerts = ''; + if (this.adduserFrm.value.UserName == '') { + this.alerts += 'User Name is required.'; + } + if (this.adduserFrm.value.Password == '') { + this.alerts += '
Password of minimum 8 characters is required.'; + } + if (this.adduserFrm.value.ConfirmPassword == '') { + this.alerts += '
Confirm Password is required.'; + } + if (this.adduserFrm.value.EmailId == '') { + this.alerts += '
Email Id is required.'; + } + if (this.adduserFrm.value.FirstName == '') { + this.alerts += '
First Name is required.'; + } + if (this.adduserFrm.value.LastName == '') { + this.alerts += '
Last Name is required.'; + } + if (this.adduserFrm.value.newPassword != this.adduserFrm.value.confirmPassword) { + this.alerts += '
Password and confirm password must be same'; + } + if (this.adduserFrm.value.AccountNumberId == '0') { + this.alerts += '
Please select account number'; + } + if (this.adduserFrm.value.UserTypeId == '0') { + this.alerts += '
Please select user type'; + } + if (this.adduserFrm.value.ProductEditionId == '0') { + this.alerts += '
Please select product edition'; + } + if (this.adduserFrm.valid && this.alerts == '') { + var AddUserEntity = this.adduserFrm.value; + return this.userservice.InsertUser(AddUserEntity) .subscribe( n => (this.AfterInsertData(n)), - error => this.error = error); + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); } + } AfterInsertData(data) { //debugger; - if (data.Status == "False") { - return false; - } else { - this.status = true; - this._confirmService.activate("User Profile Updated Successfully.", "alertMsg"); - } + if (data == "User added successfully") { + this.alerts = ''; + this._confirmService.activate("User added successfully.", "alertMsg"); + } } - bindUsers(data) { + ResetForm() { + this._buildForm(); + } + _buildForm() { + this.adduserFrm = this.fb.group({ + id: [''], + UserName: [""], + Password: [""], + ConfirmPassword: [""], + FirstName: [""], + LastName: [""], + EmailId: [""], + AccountNumberId: ["0"], + UserTypeId: ["0"], + ProductEditionId: ["0"] + + }); + } + bindUsers() { //console.log(data); //alert(JSON.stringify(data)); //this.user = data[0]; - this.adduserFrm.controls['id'].setValue(this.user.Id) - this.adduserFrm.controls['FirstName'].setValue(this.user.FirstName) - this.adduserFrm.controls['LastName'].setValue(this.user.LastName) - this.adduserFrm.controls['EmailId'].setValue(this.user.EmailId) - this.adduserFrm.controls['UserName'].setValue(this.user.LoginId) - this.adduserFrm.controls['Password'].setValue(this.user.Password) - this.adduserFrm.controls['ConfirmPassword'].setValue(this.user.ConfirmPassword) - this.adduserFrm.controls['AccountNumberId'].setValue(this.user.AccountNumberId) - this.adduserFrm.controls['UserTypeId'].setValue(this.user.UserTypeId) - this.adduserFrm.controls['ProductEditionId'].setValue(this.user.ProductEditionId) + this.adduserFrm.controls['id'].setValue(0) + this.adduserFrm.controls['FirstName'].setValue('') + this.adduserFrm.controls['LastName'].setValue('') + this.adduserFrm.controls['EmailId'].setValue('') + this.adduserFrm.controls['UserName'].setValue('') + this.adduserFrm.controls['Password'].setValue('') + this.adduserFrm.controls['ConfirmPassword'].setValue('') + this.adduserFrm.controls['AccountNumberId'].setValue(0) + this.adduserFrm.controls['UserTypeId'].setValue(0) + this.adduserFrm.controls['ProductEditionId'].setValue(0) } } diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserid.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserid.component.ts index 14fc296..8ce9e56 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserid.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserid.component.ts @@ -12,7 +12,7 @@ import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; - +import { LoadingService } from '../../shared/loading.service'; @Component({ templateUrl:'./changeuserid.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' @@ -32,7 +32,7 @@ export class ChangeUserID implements OnInit { //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; - constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, private _confirmService: ConfirmService ) { } @@ -50,7 +50,9 @@ export class ChangeUserID implements OnInit { // Email: [''] }); + this._loadingService.ShowLoading("global-loading"); this.GetUserById(); + this._loadingService.HideLoading("global-loading"); } redirect() { this.router.navigate(['/']); diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.html index 12e51e6..236c027 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.html @@ -11,7 +11,7 @@
-
**To change your profile fill all the text fields carefully.
+
**To change your password fill all the text fields carefully.
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.ts index d955689..2f3c962 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.ts @@ -13,7 +13,7 @@ import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; - +import { LoadingService } from '../../shared/loading.service'; @Component({ templateUrl: './changeuserpassword.component.html' }) @@ -25,7 +25,7 @@ changeUserPasswordFrm: FormGroup; error: any; alerts: string; -constructor(private changeUserPasswordService: UserService, private router: Router, private fb: FormBuilder, private _confirmService: ConfirmService) { } + constructor(private _loadingService: LoadingService,private changeUserPasswordService: UserService, private router: Router, private fb: FormBuilder, private _confirmService: ConfirmService) { } ngOnInit(): void { this.user = new User(); @@ -37,9 +37,11 @@ constructor(private changeUserPasswordService: UserService, private router: Rout newPassword: ['', [Validators.required, Validators.minLength(8)]], confirmPassword: ['', Validators.required] }); + this._loadingService.ShowLoading("global-loading"); this.GetUserById(); + this._loadingService.HideLoading("global-loading"); } - + GetUserById() { this.changeUserPasswordService.GetUserById() @@ -50,14 +52,26 @@ constructor(private changeUserPasswordService: UserService, private router: Rout } public onFormSubmit() { this.alerts = ''; - if (this.user.Password != this.changeUserPasswordFrm.value.oldPassword) { - this.alerts = 'Old password is invalid'; + if ((this.changeUserPasswordFrm.value.oldPassword)=='') + { + this.alerts = 'Old password is required.'; + } + if (this.user.Password != this.changeUserPasswordFrm.value.oldPassword && this.changeUserPasswordFrm.value.oldPassword!='') { + this.alerts += '
Old password is invalid.'; + } + if ((this.changeUserPasswordFrm.value.newPassword) == '') { + this.alerts += '
New password is required.'; } if (this.user.Password == this.changeUserPasswordFrm.value.newPassword) { - this.alerts += '
New password and old password must be different'; + this.alerts += '
New password and old password must be different.'; + } + if ((this.changeUserPasswordFrm.value.newPassword) == '') { + this.alerts += '
Confirm password is required.'; } + + if (this.changeUserPasswordFrm.value.newPassword != this.changeUserPasswordFrm.value.confirmPassword) { - this.alerts += '
New password and confirm password must be same'; + this.alerts += '
New password and confirm password must be same.'; } if (this.alerts == '') { var obj = this.changeUserPasswordFrm.value; diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts index efdb378..a29deab 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/datamodel.ts @@ -9,7 +9,17 @@ export class User { ConfirmPassword: string; AccountNumberId: number; UserTypeId: number; - ProductEditionId:number + UserId: number; + ProductEditionId: number; + AccountNumber: string; + UserTypeTitle: string; + AccountTypeTitle: string; + CreationDate: Date; + ModifiedDate: Date; + Createdby: string; + Modifiedby: string; + DeactivationDate: Date; + UserStatus:string } export class DiscountCode { Id: number; diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.html new file mode 100644 index 0000000..53fa73e --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.html @@ -0,0 +1,86 @@ +
+
+

Unblock User

+
+
+ + + + + +
+ + + + + +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SelectFirst NameLast NameUser IDPasswordEmail IDBlocked DateAccount Number
+ + {{UserEntity.FirstName}}{{UserEntity.LastName}}{{UserEntity.LoginId}}{{UserEntity.Password}}{{UserEntity.EmailId}}{{UserEntity.LoginTime| date: 'MM/dd/yyyy'}}{{UserEntity.AccountNumber}}
+
+ + + +
+
+ + +
+
+ +
+
+ +
+
+
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts new file mode 100644 index 0000000..082aa8b --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts @@ -0,0 +1,146 @@ +import { Component, OnInit, AfterViewInit, ViewChild, TemplateRef } from '@angular/core'; +import { UserService } from './user.service'; +import { Router } from '@angular/router'; +import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { User } from '../UserEntity/datamodel'; +import { Http, Response } from '@angular/http'; +import { GlobalService } from '../../Shared/global'; +//import { DBOperation } from 'S'; +import { Observable } from 'rxjs/Observable'; +import { ConfirmService } from '../../Shared/Confirm/confirm.service'; +import 'rxjs/Rx'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/filter'; +import { LoadingService } from '../../shared/loading.service'; +import { BsModalService } from 'ngx-bootstrap/modal'; +import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; + +@Component({ + templateUrl:'./unblockuser.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' +}) + +export class UnblockUser implements OnInit { + + modalTitle: string; + UnBlockedUserFrm: FormGroup; + alerts: string; + public UserTypeList: any; + public AccountTypeList: any; + public UserList: any; + error; + modalRef: BsModalRef; + checkedRecords: Array; + display = 'none'; + modalAlerts: string; + //@ViewChild("profileModal") + //profileModal: ModalComponent; + //errorMessage: any; + constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + private _confirmService: ConfirmService, private modalService: BsModalService, private commonService: GlobalService + ) { } + + ngOnInit(): void { + this.alerts = ''; + //this.userservice.GetUserById(this.UserId); + this.UnBlockedUserFrm = this.fb.group({ + //FirstName:[''], + //LastName: [''], + //EmailId: [''], + //AccountNumber: [''], + //UserTypeId: [''], + //AccountTypeId:[''] + // Gender: ['', Validators.required], + // Email: [''] + + }); this._loadingService.ShowLoading("global-loading"); + this.GetBlockUserList(); + //this.GetAccountType(); + this._loadingService.HideLoading("global-loading"); + + //this.GetUserList(); + } + redirect() { + this.router.navigate(['/']); + } + onChange(Idx: number, Id: number, isChecked: boolean) { + debugger; + if (isChecked) { + this.checkedRecords[Idx] = Id; + } + else { + this.checkedRecords[Idx] = 0; + } + } + openModal(template: TemplateRef) { + debugger; + this.display = 'block'; + if (this.checkedRecords.filter(C => C > 0).length == 0) return; + this.modalRef = this.modalService.show(template); + } + UpdateUnBlockedUsers(template: TemplateRef) { + this.modalRef.hide(); + console.log(this.checkedRecords); + this.alerts = ''; + if (this.alerts == '') { + var obj = this.checkedRecords.filter(C => C > 0); + return this.userservice.UpdateUnBlockedUser(obj) + .subscribe( + data => (this.AfterDeleteData(data, template)), + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); + } + } + AfterDeleteData(data, template) { + debugger; + if (data.Status == "false") { + this._confirmService.activate("We have encountered a technical error and same has been notified to our technical team.", "alertMsg"); + } else { + //this.modalAlerts = "

Selected users has been unblocked now

"; + //this.modalRef = this.modalService.show(template); + this.GetBlockUserList(); + } + } + + GetBlockUserList(this) + { + var UserFilterControl = this.UnBlockedUserFrm.value; + this.userservice.GetBlockUserList( + { + UserTypeId: this.commonService.UserType, + LicenseId: 0, + }) + + .subscribe(x => { this.UserList = x; this.checkedRecords = new Array(this.UserList.length);}, error => this.error = error); + + } + AfterInsertData(data) { + + if (data == "success") { + this._confirmService.activate("Userid Updated Successfully.", "alertMsg"); + + } else { + this.alerts += '' + data+''; + return false; + + + } + //if (this.closeflag) { + // this.close.emit(null); + //} + //else { + //} + } + + ResetFormFields() { + //this.ChangeUserIdFrm.reset() + //this.ChangeUserIdFrm.controls['id'].setValue(this.user.Id) + //this.ChangeUserIdFrm.controls['loginid'].setValue(this.user.LoginId) + //this.ChangeUserIdFrm.controls['newloginid'].setValue('') + //this.ChangeUserIdFrm.controls['confirmloginid'].setValue('') + this.alerts = ''; + } + +} diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html index cf6bad7..ca5a323 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.html @@ -24,14 +24,14 @@
-
First name is required
+
First Name is required
-
Last name is required
+
Last Name is required
@@ -39,7 +39,7 @@
-
Email id is required
+
Email Id is required
Please enter the correct email. diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts index b7bdd01..35339a0 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts @@ -12,7 +12,7 @@ import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; - +import { LoadingService } from '../../shared/loading.service'; @Component({ templateUrl:'./updateuserprofile.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' @@ -37,7 +37,7 @@ export class UpdateUserProfile implements OnInit { //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; - constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, private _confirmService: ConfirmService ) { } @@ -55,7 +55,9 @@ export class UpdateUserProfile implements OnInit { // Email: [''] }); + this._loadingService.ShowLoading("global-loading"); this.GetUserById(); + } redirect() { this.router.navigate(['/']); @@ -78,7 +80,8 @@ export class UpdateUserProfile implements OnInit { GetUserById() { this.userservice.GetUserById() - .subscribe(x => { console.log(x); this.bindUsers(x) }, error => this.error = error); + .subscribe(x => { console.log(x); this.bindUsers(x) }, error => this.error = error); + this._loadingService.HideLoading("global-loading"); } UpdateUserProfile(this) { // debugger; diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts index 46ae22d..7e71ba1 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts @@ -15,7 +15,7 @@ export class UserService { //////////Get User Detail/////////////// GetUserById() { debugger; - return this.http.get(this.commonService.resourceBaseUrl + "/GetUserProfile/"+this.commonService.UserId) + return this.http.get(this.commonService.resourceBaseUrl + "User/GetUserProfile/"+this.commonService.UserId) .map(this.extractData) .catch((res: Response) => this.handleError(res));; @@ -23,7 +23,7 @@ export class UserService { //////////Update User Detail/////////////// UpdateUserProfileById(obj: User) { //let options = new RequestOptions({ headers: this.headers }); - return this.http.post(this.commonService.resourceBaseUrl + "/UpdateProfile", obj) + return this.http.post(this.commonService.resourceBaseUrl + "User/UpdateProfile", obj) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } @@ -37,7 +37,7 @@ export class UserService { var headers = new Headers({ 'Content-Type': 'application/json' }); - return this.http.post(this.commonService.resourceBaseUrl + "/ChangeUserPassword", + return this.http.post(this.commonService.resourceBaseUrl + "User/ChangeUserPassword", JSON.stringify(jsonData), { headers: headers }) .map(this.extractData) .catch((res: Response) => this.handleError(res)); @@ -46,7 +46,7 @@ export class UserService { //////////Update User Userid/////////////// UpdateUserId(obj: User) { //let options = new RequestOptions({ headers: this.headers }); - return this.http.post(this.commonService.resourceBaseUrl + "/UpdateUserId", obj) + return this.http.post(this.commonService.resourceBaseUrl + "User/UpdateUserId", obj) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } @@ -55,17 +55,17 @@ export class UserService { /// Users List Form/////// GetUserType() { - return this.http.get(this.commonService.resourceBaseUrl + "/GetUserType/"+this.commonService.UserType) + return this.http.get(this.commonService.resourceBaseUrl + "User/GetUserType/"+this.commonService.UserType) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } GetAccountType() { - return this.http.get(this.commonService.resourceBaseUrl + "/GetAccountType/"+this.commonService.AccountType) + return this.http.get(this.commonService.resourceBaseUrl + "User/GetAccountType/"+this.commonService.AccountType) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } GetUserList(obj: any) { - return this.http.get(this.commonService.resourceBaseUrl + "/Users?firstname=" + obj.FirstName + + return this.http.get(this.commonService.resourceBaseUrl + "User/Users?firstname=" + obj.FirstName + "&lastname=" + obj.LastName + "&emailid=" + obj.EmailId + "&accountnumber=" + obj.AccountNumber + @@ -74,30 +74,81 @@ export class UserService { .map(this.extractData) .catch((res: Response) => this.handleError(res)); } + + UpdateUserEntity(obj: any) { + //let options = new RequestOptions({ headers: this.headers }); + var jsonData = { 'id': obj.id, 'FirstName': obj.FirstName, 'LastName': obj.LastName, 'EmailId': obj.EmailId, 'UserName': obj.UserName, 'Password': obj.Password, 'Modifiedby': this.commonService.UserId, 'IsActive': obj.isActive}; + console.log(obj); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.resourceBaseUrl + "User/UpdateUser", + JSON.stringify(jsonData), { headers: headers }) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } /// End Users ///// /// Add User Entity/// GetUserTypeByLicenseType(obj: any) { debugger; - return this.http.get(this.commonService.resourceBaseUrl + "/GetUserTypebyLicenseId?UserTypeId=" + this.commonService.UserType + "&LicenseId=" + obj.AccountNumberId) + return this.http.get(this.commonService.resourceBaseUrl + "User/GetUserTypebyLicenseId?UserTypeId=" + this.commonService.UserType + "&LicenseId=" + obj.AccountNumberId) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } GetAccountNumber() { - return this.http.get(this.commonService.resourceBaseUrl + "/GetAccountNumber"). + return this.http.get(this.commonService.resourceBaseUrl + "User/GetAccountNumber"). map(this.extractData) .catch((res: Response) => this.handleError(res)); } GetProductEdition(obj: any) { - return this.http.get(this.commonService.resourceBaseUrl + "/GetProductEdition?LicenseId=" + obj.AccountNumberId) + return this.http.get(this.commonService.resourceBaseUrl + "User/GetProductEdition?LicenseId=" + obj.AccountNumberId) .map(this.extractData) .catch((res: Response) => this.handleError(res)); } + InsertUser(obj: any) + { + //let options = new RequestOptions({ headers: this.headers }); + var jsonData = { 'id': this.commonService.UserId, 'FirstName': obj.FirstName, 'LastName': obj.LastName, 'EmailId': obj.EmailId, 'UserName': obj.UserName, 'Password': obj.Password, 'AccountNumberId': obj.AccountNumberId, 'UserTypeId': obj.UserTypeId, 'ProductEditionId':obj.ProductEditionId }; + console.log(obj); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.resourceBaseUrl + "User/NewUser", + JSON.stringify(jsonData), { headers: headers }) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } /// End ////// + //// UnBlocked User + + GetBlockUserList(obj: any) { + return this.http.get(this.commonService.resourceBaseUrl + "User/BlockedUser?UserTypeId=" + obj.UserTypeId + + "&LicenseId=" + obj.LicenseId) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + + UpdateUnBlockedUser(obj: any) { + //let options = new RequestOptions({ headers: this.headers }); + var UserIds = obj; + console.log(UserIds); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.resourceBaseUrl + "User/UnblockedUser", + UserIds, { headers: headers }) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + /// End/////// + + + extractData(res: Response) { debugger; @@ -109,7 +160,8 @@ export class UserService { // In a real world app, we might use a remote logging infrastructure // We'd also dig deeper into the error to get a better message let errMsg = (error.message) ? error.message : - error.status ? `${error.status} - ${error.statusText}` : 'Server error'; + //error.status ? `${error.status} - ${error.statusText}` : 'Server error'; + error.status ? `${error._body}` : 'Server error'; console.error(errMsg); // log to console instead return Observable.throw(errMsg); } diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html index de8bb1f..d0df242 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html @@ -3,156 +3,330 @@

List User

+
+
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
-
-
-
-
-
-
-
-
- -
- +
+
+ +
+ +
+
+
-
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
-
-
- -
- + +
+
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+
 
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First NameLast NameUser IDPasswordEmail IDUser TypeCreated DateLast Modified DateAccount NumberProduct EditionStatus
{{UserEntity.FirstName}}{{UserEntity.LastName}}{{UserEntity.LoginId}}{{UserEntity.Password}}{{UserEntity.EmailId}}{{UserEntity.UserTypeTitle}}{{UserEntity.CreationDate| date: 'MM/dd/yyyy'}}{{UserEntity.ModifiedDate | date: 'MM/dd/yyyy'}}{{UserEntity.AccountNumber}}{{UserEntity.EditionType}} + {{UserEntity.UserStatus}} +
+ +
+
+ + +
+
-
-
-
-
- +
+ + +
+
+
+
+ +
+
+
+
+
+ +
-
- +
+ +
+ +
User Name is required
+
-
+
+ +
+ + (Minimum 8 characters) +
Password of minimum 8 characters is required
+
+
+
+ +
+ +
Confirm Password is required
+
+
+
+ +
+ +
Email Id is required
+ +
+ Please enter the correct email. +
+
+
+
+ +
+ +
First Name is required
+
+
+
+ +
+ +
Last Name is required
+
+
+
+ +
-
-
- + + +
-
- +
+ +
+ + +
-
+
+ +
-
-
-
-
-
-
- -
- - +
-
+
+ +
+ +
+
+
+ +
+ -
-
- -
-
-
-
-
+
+ +
+ +
+
+
+ +
+ -
-
-
 
+
+
+
+ +
+ -
-
-
- -
-
-
-
-
+
+ +
+ -
+
+
+
+
+ + +
+ +
-
-
+
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts index 312c5f7..93b0b60 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts @@ -12,25 +12,39 @@ import { ConfirmService } from '../../Shared/Confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; - - +import { LoadingService } from '../../shared/loading.service'; +declare var $: any; +import { DatePipe } from '@angular/common'; @Component({ templateUrl:'./users.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' }) export class UsersList implements OnInit { - + + Mode: string = 'Manage'; modalTitle: string; Users: FormGroup; + adduserFrm: FormGroup; alerts: string; public UserTypeList: any; public AccountTypeList: any; public UserList: any; + emailPattern = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"; + public UserTypeListByLicense: any; + public AccountNumberList: any; + public ProductEditionList: any; + UserEntity: User; + topPos: string = '2000px'; + datePipe: DatePipe = new DatePipe('en-US'); error; + selectedRow: number = 0; + selectedId: number = 0; + divClass: string; + isActive: boolean; //@ViewChild("profileModal") //profileModal: ModalComponent; //errorMessage: any; - constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + constructor(private _loadingService: LoadingService,private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, private _confirmService: ConfirmService ) { } @@ -48,13 +62,89 @@ export class UsersList implements OnInit { // Email: [''] }); + this.adduserFrm = this.fb.group({ + id: [''], + UserName: ['', Validators.required], + Password: ['', [Validators.required, Validators.minLength(8)]], + ConfirmPassword: ['', Validators.required], + FirstName: ['', Validators.required], + LastName: ['', Validators.required], + EmailId: ['', Validators.required], + AccountNumber: [''], + UserType: [''], + AccountType: [''], + Createddate: [''], + LastModifiedDate: [''], + Createdby: [''], + Modifiedby: [''], + DeactivationDate: [''], + isActive: [false], + UserStatusActive: [''], + UserStatusInActive:[''] + }); + this._loadingService.ShowLoading("global-loading"); this.GetUserType(); this.GetAccountType(); + this._loadingService.HideLoading("global-loading"); + $('#fixed_hdr2').fxdHdrCol({ + fixedCols: 0, + width: "100%", + height: 300, + colModal: [ + { width: 180, align: 'center' }, + { width: 230, align: 'center' }, + { width: 150, align: 'Center' }, + { width: 150, align: 'Center' }, + { width: 350, align: 'Center' }, + { width: 500, align: 'Center' }, + { width: 130, align: 'Center' }, + { width: 120, align: 'center' }, + { width: 280, align: 'Center' }, + { width: 180, align: 'center' }, + { width: 200, align: 'center' }, + { width: 170, align: 'center' }, + { width: 80, align: 'center' }, + { width: 150, align: 'center' }, + { width: 150, align: 'center' }, + { width: 180, align: 'Center' }, + { width: 400, align: 'Center' }, + { width: 150, align: 'center' }, + { width: 110, align: 'center' }, + ], + sort: true + }); + document.getElementById("fixed_table_rc").remove(); + var testScript = document.createElement("script"); + testScript.setAttribute("id", "fixed_table_rc"); + testScript.setAttribute("src", "../assets/scripts/fixed_table_rc.js"); + testScript.setAttribute("type", "text/javascript"); + document.body.appendChild(testScript); + this._loadingService.ShowLoading("global-loading"); + //this.bindUsers(); + this._loadingService.HideLoading("global-loading"); + //this.GetUserList(); } + handleChange(evt) { + debugger; + var target = evt.target; + if (target.value == 'true') { + this.isActive = true; + } + else if (target.value == 'false') { + this.isActive = false; + } + } + + public SetClickedRow(i: number, item: any) { + this.selectedRow = i; + this.selectedId = item['Id']; + this.UserEntity = item; + } redirect() { this.router.navigate(['/']); } + GetUserType() { this.userservice.GetUserType().subscribe(x => { this.UserTypeList = x; }, error => this.error = error); } @@ -81,16 +171,78 @@ export class UsersList implements OnInit { .subscribe(x => { this.UserList = x; }, error => this.error = error); } + + EditUser() { + this.Mode = 'Edit'; + this.topPos = '100px'; + this.divClass = 'col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3'; + this.alerts = ''; + this.adduserFrm.controls['id'].setValue(this.UserEntity.Id) + this.adduserFrm.controls['FirstName'].setValue(this.UserEntity.FirstName) + this.adduserFrm.controls['LastName'].setValue(this.UserEntity.LastName) + this.adduserFrm.controls['EmailId'].setValue(this.UserEntity.EmailId) + this.adduserFrm.controls['UserName'].setValue(this.UserEntity.LoginId) + this.adduserFrm.controls['Password'].setValue(this.UserEntity.Password) + this.adduserFrm.controls['ConfirmPassword'].setValue(this.UserEntity.Password) + this.adduserFrm.controls['AccountNumber'].setValue(this.UserEntity.AccountNumber) + this.adduserFrm.controls['UserType'].setValue(this.UserEntity.UserTypeTitle) + this.adduserFrm.controls['AccountType'].setValue(this.UserEntity.AccountTypeTitle) + this.adduserFrm.controls['Createddate'].setValue(this.datePipe.transform(this.UserEntity.CreationDate, 'MM/dd/yyyy')) + this.adduserFrm.controls['LastModifiedDate'].setValue(this.datePipe.transform(this.UserEntity.ModifiedDate, 'MM/dd/yyyy')) + this.adduserFrm.controls['Createdby'].setValue(this.UserEntity.Createdby) + this.adduserFrm.controls['Modifiedby'].setValue(this.UserEntity.Modifiedby) + this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserEntity.DeactivationDate, 'MM/dd/yyyy')) + this.adduserFrm.controls['UserStatusActive'].setValue(true) + this.adduserFrm.controls['UserStatusInActive'].setValue(false) + this.isActive = (this.UserEntity.UserStatus=='Active'?true :false) + + } + + public UpdateUser(this) { + this.alerts = ''; + if (this.adduserFrm.value.UserName == '') { + this.alerts += 'User Name is required.'; + } + if (this.adduserFrm.value.Password == '') { + this.alerts += '
Password of minimum 8 characters is required.'; + } + if (this.adduserFrm.value.ConfirmPassword == '') { + this.alerts += '
Confirm Password is required.'; + } + if (this.adduserFrm.value.EmailId == '') { + this.alerts += '
Email Id is required.'; + } + if (this.adduserFrm.value.FirstName == '') { + this.alerts += '
First Name is required.'; + } + if (this.adduserFrm.value.LastName == '') { + this.alerts += '
Last Name is required.'; + } + if (this.adduserFrm.value.newPassword != this.adduserFrm.value.confirmPassword) { + this.alerts += '
Password and confirm password must be same'; + } + + if (this.adduserFrm.valid && this.alerts == '') { + this.adduserFrm.controls['isActive'].setValue(this.isActive) + + var UserEntity = this.adduserFrm.value; + + return this.userservice.UpdateUserEntity(UserEntity) + .subscribe( + n => (this.AfterInsertData(n)), + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); + } + + } + AfterInsertData(data) { - if (data == "success") { - this._confirmService.activate("Userid Updated Successfully.", "alertMsg"); - - } else { - this.alerts += '' + data+''; - return false; - - + if (data == "User updated successfully") { + this.alerts = ''; + this._confirmService.activate("User updated successfully.", "alertMsg"); } //if (this.closeflag) { // this.close.emit(null); diff --git a/400-SOURCECODE/Admin/src/app/shared/Confirm/confirm.component.html b/400-SOURCECODE/Admin/src/app/shared/Confirm/confirm.component.html index 7ac4b7e..16383f2 100644 --- a/400-SOURCECODE/Admin/src/app/shared/Confirm/confirm.component.html +++ b/400-SOURCECODE/Admin/src/app/shared/Confirm/confirm.component.html @@ -10,9 +10,10 @@
- - - + + + +

{{message}}

@@ -53,7 +54,7 @@ -
+