Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public update(): void {
  2.     if (this.isCompany) {
  3.       let promise = this.companyService.update(new CompanyUpdateModel(this.tokenDataService.getTokenData()['CLIENT'], this.getformCompany(this.htmlNames['COMPANY_EDIT']).value['name']));
  4.       promise.then(data => {
  5.         this.noticeService.openNotice(1.5, data.getContentNoKey(), f => {
  6.           window.location.reload();
  7.         });
  8.       });
  9.  
  10.       promise.catch(e => {
  11.         console.log(e);
  12.         this.noticeService.openNotice(2.5, environment.ERROR.GENERAL);
  13.       });
  14.     } else {
  15.       let forename: string = this.getformEmployee(this.htmlNames['EMPLOYEE_EDIT']).value['forename'];
  16.       let surname: string = this.getformEmployee(this.htmlNames['EMPLOYEE_EDIT']).value['surname'];
  17.       let document: number = Number(this.getformEmployee(this.htmlNames['EMPLOYEE_EDIT']).value['document']);
  18.  
  19.       if (document == 0){
  20.         document = -1;
  21.       }else{
  22.         if(!this.validationService.validateDocument(document)){
  23.           console.log(this.validationService.validateDocument(document))
  24.           this.noticeService.openNotice(1.5 , environment.ERROR.EMPLOYEE.DOCUMENT_INVALID)
  25.           return;
  26.         }
  27.       }
  28.  
  29.       let promise = this.employeeService.update(new EmployeeUpdateModel(this.tokenDataService.getTokenData()['CLIENT'], forename, surname, document));
  30.       promise.then(data => {
  31.         this.noticeService.openNotice(1.5, data.getContentNoKey(), f => {
  32.           window.location.reload();
  33.         });
  34.       });
  35.  
  36.       promise.catch(e => {
  37.         console.log(e);
  38.         this.noticeService.openNotice(2.5, environment.ERROR.GENERAL);
  39.       });
  40.     }
  41.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement