From a83adff43bf4a153f7d4fa9788925ed4d7bd030a Mon Sep 17 00:00:00 2001 From: Birendra Date: Tue, 26 May 2020 13:20:25 +0530 Subject: [PATCH] fixed deativation datein admin section --- 400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs | 7 +++++++ 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs | 8 ++++++-- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Designer.cs | 2 +- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx | 4 +++- 400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs | 2 +- 400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts | 2 +- 400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html | 4 ++-- 400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts | 18 ++++++++++++++---- 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index af55c23..e9aa11c 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -205,6 +205,13 @@ namespace AIAHTML5.ADMIN.API.Controllers UserEntity.Password = jsonUserData["Password"].Value(); UserEntity.IsActive = jsonUserData["IsActive"].Value(); UserEntity.CreatorId = jsonUserData["Modifiedby"].Value(); + + JToken typeToken= jsonUserData["DeactivationDate"]; + if (typeToken.Type != JTokenType.Null) + { + UserEntity.DeactivationDate = typeToken.Value(); + } + try { Status = UserModel.UpdateUser(dbContext, UserEntity); diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs index c0e7d47..614ea78 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs @@ -3425,7 +3425,7 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_SaveLabExerciseAttempts", userIdParameter, labExerciseIdentifierParameter, lastQuestionParameter, totalQuestionsParameter); } - public virtual int usp_UpdateAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, string sEmailId, Nullable id, Nullable iCreatorId, Nullable isActive, ObjectParameter status) + public virtual int usp_UpdateAIAUser(string sLoginId, string sPassword, string sFirstname, string sLastname, string sEmailId, Nullable id, Nullable iCreatorId, Nullable isActive, Nullable deactivateDate, ObjectParameter status) { var sLoginIdParameter = sLoginId != null ? new ObjectParameter("sLoginId", sLoginId) : @@ -3459,7 +3459,11 @@ namespace AIAHTML5.ADMIN.API.Entity 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); + var deactivateDateParameter = deactivateDate.HasValue ? + new ObjectParameter("deactivateDate", deactivateDate) : + new ObjectParameter("deactivateDate", typeof(System.DateTime)); + + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_UpdateAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, sEmailIdParameter, idParameter, iCreatorIdParameter, isActiveParameter, deactivateDateParameter, status); } public virtual int usp_UpdateblockedUser(Nullable id, ObjectParameter status) diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Designer.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Designer.cs index 9a0f321..660d3a3 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Designer.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'F:\CB_Develop\400-SOURCECODE\AIAHTML5.ADMIN.API\Entity\AIADBEntity.edmx'. +// T4 code generation is enabled for model 'E:\AIAProject\400-SOURCECODE\AIAHTML5.ADMIN.API\Entity\AIADBEntity.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index f7ad830..f74da8e 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -4,7 +4,7 @@ - + @@ -1421,6 +1421,7 @@ + @@ -2539,6 +2540,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs index a60fded..14b140c 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs @@ -114,7 +114,7 @@ namespace AIAHTML5.ADMIN.API.Models 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); + dbContext.usp_UpdateAIAUser(UserEntity.LoginId, UserEntity.Password, UserEntity.FirstName, UserEntity.LastName,UserEntity.EmailId,UserEntity.Id,UserEntity.CreatorId,(UserEntity.IsActive ? (byte)1 :(byte)0),UserEntity.DeactivationDate,spStatus); return spStatus.Value.ToString(); } catch (Exception ex) 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 a835dd6..7cfd01e 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts @@ -97,7 +97,7 @@ export class UserService { 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}; + 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,'DeactivationDate': obj.DeactivationDate}; console.log(obj); var headers = new Headers({ 'Content-Type': 'application/json' 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 0ba5096..af9de32 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html @@ -301,8 +301,8 @@
- - + +
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 b83958a..4951ad3 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts @@ -53,6 +53,7 @@ export class UsersList implements OnInit, AfterViewChecked { selectedId: number = 0; divClass: string; isActive: boolean; + deaDateblank:boolean; NoRecord: string; checkedRecords: Array; UncheckedRecords: Array; @@ -101,7 +102,7 @@ export class UsersList implements OnInit, AfterViewChecked { ModifiedDate: [''], Createdby: [''], Modifiedby: [''], - DeactivationDate: [''], + DeactivationDate: ['',this.noWhitespaceValidator], isActive: [false], UserStatusActive: ['false'], UserStatusInActive:[''] @@ -400,12 +401,21 @@ export class UsersList implements OnInit, AfterViewChecked { if (this.adduserFrm.value.FirstName == '') { this.alerts += '
First Name is required.'; } - if (this.adduserFrm.value.LastName == '') { - this.alerts += '
Last Name is required.'; + this.deaDateblank=false; + if (this.adduserFrm.value.DeactivationDate == '' ||this.adduserFrm.value.DeactivationDate == null) { + this.deaDateblank=true; + //set date to pass from validation and later remove + this.adduserFrm.controls['DeactivationDate'].setValue('01/01/2020'); } + if (this.adduserFrm.valid && this.alerts == '') { - this.adduserFrm.controls['isActive'].setValue(this.adduserFrm.value.UserStatusActive) + this.adduserFrm.controls['isActive'].setValue(this.adduserFrm.value.UserStatusActive) ; + + if(this.deaDateblank) + { + this.adduserFrm.controls['DeactivationDate'].setValue(null); + } var Userobj = this.adduserFrm.value; -- libgit2 0.21.4