-------

-------

  • NA
  • 213
  • 6.2k

trying to record update after get the record from the list

Sep 4 2020 1:51 AM
I am trying to update the record
 
but when I click on edit button then get an error 
 
  
see below code:
 
registration.component.html
  1. <div>    
  2.       <button type="button" (click)="registration()">Submit</button>    
  3.          
  4.       <button type="button" (click)="edit()">Edit</button>    
  5. </div>    
  6.      
  7. <h2>List Of Employee</h2>    
  8.     
  9. <ag-grid-angular style="width: 1150px; height: 200px;"    
  10.                  class="ag-theme-balham"    
  11.                  [rowData]="elist"    
  12.                  [columnDefs]="columnDefs"    
  13.                  (rowClicked)='onGridRowClicked($event)'>    
  14. </ag-grid-angular>   
registration.component.ts
  1. columnDefs = [    
  2.   { headerName: 'empid', field: 'empid' },    
  3.   { headerName: 'username', field: 'username' },    
  4.   { headerName: 'empaddress', field: 'empaddress' },    
  5.   { headerName: 'password', field: 'password' },    
  6.   { headerName: 'country', field: 'country' },    
  7.   {    
  8.     headerName: 'Edit',    
  9.     
  10.     template: '<span><i class="fa fa-edit" data-action-type="edit"></i></span>',    
  11.   }    
  12. ];    
  13.     
  14. onGridRowClicked(e: any) {    
  15.   if (e.event.target !== undefined) {    
  16.     let actionType = e.event.target.getAttribute("data-action-type");    
  17.     if (actionType == "edit") {    
  18.     
  19.       this.rowData = this.myservice.getExistRecord(e.data.empid).subscribe((data: any) => {    
  20.         console.log("inside get data from list 1")    
  21.         if (data.message == "GetSuccess") {    
  22.     
  23.           //get data from the list    
  24.           debugger    
  25.           this.txtusername = e.data.username;    
  26.           this.txtempaddress = e.data.empaddress;    
  27.           this.txtpassword = e.data.password;    
  28.           this.txtcountry = e.data.country;    
  29.           this.empid = e.data.empid;    
  30.           this.dataUpdate();    
  31.           console.log("empid", e.data.empid);    
  32.           console.log("Edit Icon Clicked");    
  33.         }    
  34.       });    
  35.     }    
  36.     else if (actionType == "delete") {    
  37.       console.log("View delete action clicked");    
  38.     }    
  39.   }    
  40. }    
  41.     
  42. //after get the data then update a record    
  43. dataUpdate() {    
  44.   this.myservice.editExistRecord(this.empid, this.txtusername, this.txtempaddress, this.txtpassword, this.txtcountry).subscribe((data: any) => {    
  45.     console.log("Inside editExistRecord")    
  46.     if (data.message == "UpdateSuccessfully") {    
  47.       debugger    
  48.       this.list();    
  49.     }    
  50.     else if (data.message == "UpdateSuccessfully") {    
  51.       debugger    
  52.       this.list();    
  53.     }    
  54.   });    
  55. }    
  56.     
  57. edit() {    
  58.   this.dataUpdate();    
  59. }  
backendservice.service.ts
  1. //getdata from the list for update record    
  2.  public getExistRecord(empid) {    
  3.    this.url = "https://localhost:44371/emps/GetRecordForEdit?empid=" + empid;       
  4.   // this.url = "https://localhost:44371/emps/Edit?empid=" + 2013;      
  5.    console.log(this.url);    
  6.    return this.httpClient.get<any>(this.url);    
  7.  }    
  8.     
  9.  //update record    
  10.  public editExistRecord(empid,username, empaddress, password, country): Observable<any> {    
  11.    debugger    
  12.    //https://localhost:44371/emps/Edit?empid=2013    
  13.    this.url = "https://localhost:44371/emps/Edit?empid=" + empid + "&username=" + username + "&empaddress=" +  empaddress + "&password=" + password + "&country=" + country;    
  14.    const postdata = {    
  15.      'username': username,    
  16.      'empaddress': empaddress,    
  17.      'password': password,    
  18.      'country': country,    
  19.    }    
  20.    console.log(this.url);    
  21.    return this.httpClient.put<any>(this.url, postdata);    
  22.  } 
(NetWork tabl 404 not found):
 
 
 
is there any issue with my webservice?
 
why my record is not updated

Answers (6)