Commit b39d17b9adbfd8f4be1bc3dc42749d5144b9cea0
1 parent
3d2d9bd5
fixed bug in deactivation date while update user
Showing
3 changed files
with
29 additions
and
21 deletions
400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs
@@ -207,13 +207,28 @@ namespace AIAHTML5.ADMIN.API.Controllers | @@ -207,13 +207,28 @@ namespace AIAHTML5.ADMIN.API.Controllers | ||
207 | UserEntity.CreatorId = jsonUserData["Modifiedby"].Value<int>(); | 207 | UserEntity.CreatorId = jsonUserData["Modifiedby"].Value<int>(); |
208 | 208 | ||
209 | JToken typeToken= jsonUserData["DeactivationDate"]; | 209 | JToken typeToken= jsonUserData["DeactivationDate"]; |
210 | - if (typeToken.Type != JTokenType.Null) | ||
211 | - { | ||
212 | - UserEntity.DeactivationDate = typeToken.Value<DateTime>(); | ||
213 | - } | ||
214 | 210 | ||
215 | try | 211 | try |
216 | { | 212 | { |
213 | + try | ||
214 | + { | ||
215 | + if (typeToken.Type != JTokenType.Null) | ||
216 | + { | ||
217 | + string dateString=typeToken.Value<String>(); | ||
218 | + if(!string.IsNullOrWhiteSpace(dateString)) | ||
219 | + { | ||
220 | + UserEntity.DeactivationDate = typeToken.Value<DateTime>(); | ||
221 | + } | ||
222 | + | ||
223 | + } | ||
224 | + } | ||
225 | + catch (Exception ex) | ||
226 | + { | ||
227 | + // Log exception code goes here | ||
228 | + return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message); | ||
229 | + } | ||
230 | + | ||
231 | + | ||
217 | Status = UserModel.UpdateUser(dbContext, UserEntity); | 232 | Status = UserModel.UpdateUser(dbContext, UserEntity); |
218 | if (Status.Equals("1")) | 233 | if (Status.Equals("1")) |
219 | { | 234 | { |
400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
@@ -301,7 +301,7 @@ | @@ -301,7 +301,7 @@ | ||
301 | <div class="form-group"> | 301 | <div class="form-group"> |
302 | <label for="inputEmail3" class="col-sm-5 control-label">Deactivation Date :</label> | 302 | <label for="inputEmail3" class="col-sm-5 control-label">Deactivation Date :</label> |
303 | <div class="col-sm-7"> | 303 | <div class="col-sm-7"> |
304 | - <input class="form-control input-sm" id="DeactivationDate" placeholder="" type="text" formControlName="DeactivationDate"> | 304 | + <input class="form-control input-sm" id="DeactivationDate" placeholder="" type="text" formControlName="DeactivationDate" (keydown.space)="$event.preventDefault();"> |
305 | <!-- <div *ngIf="!adduserFrm.controls.DeactivationDate.valid && adduserFrm.controls.DeactivationDate.dirty" class="alert alert-danger" style="padding: 2px; margin-bottom: 2px;"></div> --> | 305 | <!-- <div *ngIf="!adduserFrm.controls.DeactivationDate.valid && adduserFrm.controls.DeactivationDate.dirty" class="alert alert-danger" style="padding: 2px; margin-bottom: 2px;"></div> --> |
306 | </div> | 306 | </div> |
307 | </div> | 307 | </div> |
400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts
@@ -53,7 +53,6 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -53,7 +53,6 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
53 | selectedId: number = 0; | 53 | selectedId: number = 0; |
54 | divClass: string; | 54 | divClass: string; |
55 | isActive: boolean; | 55 | isActive: boolean; |
56 | - deaDateblank:boolean; | ||
57 | NoRecord: string; | 56 | NoRecord: string; |
58 | checkedRecords: Array<number>; | 57 | checkedRecords: Array<number>; |
59 | UncheckedRecords: Array<number>; | 58 | UncheckedRecords: Array<number>; |
@@ -102,7 +101,8 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -102,7 +101,8 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
102 | ModifiedDate: [''], | 101 | ModifiedDate: [''], |
103 | Createdby: [''], | 102 | Createdby: [''], |
104 | Modifiedby: [''], | 103 | Modifiedby: [''], |
105 | - DeactivationDate: ['',this.noWhitespaceValidator], | 104 | + DeactivationDate: [''], |
105 | + //DeactivationDate: ['',this.noWhitespaceValidator], | ||
106 | isActive: [false], | 106 | isActive: [false], |
107 | UserStatusActive: ['false'], | 107 | UserStatusActive: ['false'], |
108 | UserStatusInActive:[''] | 108 | UserStatusInActive:[''] |
@@ -341,7 +341,6 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -341,7 +341,6 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
341 | this.bindUsers(x); | 341 | this.bindUsers(x); |
342 | }, error => this.error = <any>error); | 342 | }, error => this.error = <any>error); |
343 | 343 | ||
344 | - //this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserEntity.DeactivationDate, 'MM/dd/yyyy')) | ||
345 | if (this.UserEntity.UserStatus == 'Active') { | 344 | if (this.UserEntity.UserStatus == 'Active') { |
346 | this.adduserFrm.controls['UserStatusActive'].setValue('true') | 345 | this.adduserFrm.controls['UserStatusActive'].setValue('true') |
347 | } | 346 | } |
@@ -355,9 +354,7 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -355,9 +354,7 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
355 | 354 | ||
356 | } | 355 | } |
357 | bindUsers(data) { | 356 | bindUsers(data) { |
358 | - | ||
359 | - //console.log(data); | ||
360 | - //alert(JSON.stringify(data)); | 357 | + |
361 | this.UserDetailEntity = data[0]; | 358 | this.UserDetailEntity = data[0]; |
362 | this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserDetailEntity.DeactivationDate, 'MM/dd/yyyy')) | 359 | this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserDetailEntity.DeactivationDate, 'MM/dd/yyyy')) |
363 | this.adduserFrm.controls['Createdby'].setValue(this.UserDetailEntity.Createdby) | 360 | this.adduserFrm.controls['Createdby'].setValue(this.UserDetailEntity.Createdby) |
@@ -378,6 +375,7 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -378,6 +375,7 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
378 | //this.managerightFrm.contains['UserId'].setValue(this.UserEntity.Id); | 375 | //this.managerightFrm.contains['UserId'].setValue(this.UserEntity.Id); |
379 | 376 | ||
380 | } | 377 | } |
378 | + | ||
381 | 379 | ||
382 | public UpdateUser() { | 380 | public UpdateUser() { |
383 | this.alerts = ''; | 381 | this.alerts = ''; |
@@ -401,21 +399,16 @@ export class UsersList implements OnInit, AfterViewChecked { | @@ -401,21 +399,16 @@ export class UsersList implements OnInit, AfterViewChecked { | ||
401 | if (this.adduserFrm.value.FirstName == '') { | 399 | if (this.adduserFrm.value.FirstName == '') { |
402 | this.alerts += '</br><span>First Name is required.</span>'; | 400 | this.alerts += '</br><span>First Name is required.</span>'; |
403 | } | 401 | } |
404 | - this.deaDateblank=false; | ||
405 | - if (this.adduserFrm.value.DeactivationDate == '' ||this.adduserFrm.value.DeactivationDate == null) { | ||
406 | - this.deaDateblank=true; | ||
407 | - //set date to pass from validation and later remove | ||
408 | - this.adduserFrm.controls['DeactivationDate'].setValue('01/01/2020'); | 402 | + if (this.adduserFrm.value.DeactivationDate != null) { |
403 | + if(this.adduserFrm.value.DeactivationDate.trim() == '') | ||
404 | + { | ||
405 | + this.adduserFrm.controls['DeactivationDate'].setValue(null); | ||
406 | + } | ||
409 | } | 407 | } |
410 | 408 | ||
411 | 409 | ||
412 | if (this.adduserFrm.valid && this.alerts == '') { | 410 | if (this.adduserFrm.valid && this.alerts == '') { |
413 | this.adduserFrm.controls['isActive'].setValue(this.adduserFrm.value.UserStatusActive) ; | 411 | this.adduserFrm.controls['isActive'].setValue(this.adduserFrm.value.UserStatusActive) ; |
414 | - | ||
415 | - if(this.deaDateblank) | ||
416 | - { | ||
417 | - this.adduserFrm.controls['DeactivationDate'].setValue(null); | ||
418 | - } | ||
419 | 412 | ||
420 | var Userobj = this.adduserFrm.value; | 413 | var Userobj = this.adduserFrm.value; |
421 | 414 |