Merged
Merge Request #1017 · created by Birendra Kumar


fixed bug in deactivation date while update user

merge into production


From FixBugDeactivationDate into AIA_Production

Merged by Birendra Kumar

1 participants

400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs
... ... @@ -207,13 +207,28 @@ namespace AIAHTML5.ADMIN.API.Controllers
207 207 UserEntity.CreatorId = jsonUserData["Modifiedby"].Value<int>();
208 208  
209 209 JToken typeToken= jsonUserData["DeactivationDate"];
210   - if (typeToken.Type != JTokenType.Null)
211   - {
212   - UserEntity.DeactivationDate = typeToken.Value<DateTime>();
213   - }
214 210  
215 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 232 Status = UserModel.UpdateUser(dbContext, UserEntity);
218 233 if (Status.Equals("1"))
219 234 {
... ...
400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
... ... @@ -301,7 +301,7 @@
301 301 <div class="form-group">
302 302 <label for="inputEmail3" class="col-sm-5 control-label">Deactivation Date :</label>
303 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 305 <!-- <div *ngIf="!adduserFrm.controls.DeactivationDate.valid && adduserFrm.controls.DeactivationDate.dirty" class="alert alert-danger" style="padding: 2px; margin-bottom: 2px;"></div> -->
306 306 </div>
307 307 </div>
... ...
400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts
... ... @@ -53,7 +53,6 @@ export class UsersList implements OnInit, AfterViewChecked {
53 53 selectedId: number = 0;
54 54 divClass: string;
55 55 isActive: boolean;
56   - deaDateblank:boolean;
57 56 NoRecord: string;
58 57 checkedRecords: Array<number>;
59 58 UncheckedRecords: Array<number>;
... ... @@ -102,7 +101,8 @@ export class UsersList implements OnInit, AfterViewChecked {
102 101 ModifiedDate: [''],
103 102 Createdby: [''],
104 103 Modifiedby: [''],
105   - DeactivationDate: ['',this.noWhitespaceValidator],
  104 + DeactivationDate: [''],
  105 + //DeactivationDate: ['',this.noWhitespaceValidator],
106 106 isActive: [false],
107 107 UserStatusActive: ['false'],
108 108 UserStatusInActive:['']
... ... @@ -341,7 +341,6 @@ export class UsersList implements OnInit, AfterViewChecked {
341 341 this.bindUsers(x);
342 342 }, error => this.error = <any>error);
343 343  
344   - //this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserEntity.DeactivationDate, 'MM/dd/yyyy'))
345 344 if (this.UserEntity.UserStatus == 'Active') {
346 345 this.adduserFrm.controls['UserStatusActive'].setValue('true')
347 346 }
... ... @@ -355,9 +354,7 @@ export class UsersList implements OnInit, AfterViewChecked {
355 354  
356 355 }
357 356 bindUsers(data) {
358   -
359   - //console.log(data);
360   - //alert(JSON.stringify(data));
  357 +
361 358 this.UserDetailEntity = data[0];
362 359 this.adduserFrm.controls['DeactivationDate'].setValue(this.datePipe.transform(this.UserDetailEntity.DeactivationDate, 'MM/dd/yyyy'))
363 360 this.adduserFrm.controls['Createdby'].setValue(this.UserDetailEntity.Createdby)
... ... @@ -378,6 +375,7 @@ export class UsersList implements OnInit, AfterViewChecked {
378 375 //this.managerightFrm.contains['UserId'].setValue(this.UserEntity.Id);
379 376  
380 377 }
  378 +
381 379  
382 380 public UpdateUser() {
383 381 this.alerts = '';
... ... @@ -401,21 +399,16 @@ export class UsersList implements OnInit, AfterViewChecked {
401 399 if (this.adduserFrm.value.FirstName == '') {
402 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 410 if (this.adduserFrm.valid && this.alerts == '') {
413 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 413 var Userobj = this.adduserFrm.value;
421 414  
... ...