
--add this 2 events in html

 (change)="hideAndShow($event)"
 
 (change)='minAndMax($event)'
 
 --add in constructor
  private commonService: CommonService,
    private toastr: ToastrService
 --add this in ngOnInit()
  this.getuserPreferences();
  
 --add get image logic into seperate method
 
 ---add this 3 methods
 userPreferences: any = [];
  getuserPreferences() {

    var obj = {
      userid: +this.userid
    }
    this.commonService.getserPreferences(obj).subscribe(res => {
      if (res.status === 200 && res.body[0])
        this.userPreferences = JSON.parse(res.body[0]);

    }, err => {
      this.toastr.error('error in geting user preferences');

    })
  }
  hideAndShowText: string = 'Hide';
  hideAndShow(event) {
    let a = event.currentTarget.checked;
    let showandhide;
    
    if (a) {
      this.hideAndShowText = 'Show';
     
      //optionid=this.optionsList.find(e=>e.option.trim()==='hide'.trim());
      showandhide=0;
    }
    else {
      this.hideAndShowText = 'Hide';
      //optionid=this.optionsList.find(e=>e.option.trim()==='show'.trim());
      showandhide=1;
    }
    var obj = {
      userid: +this.userid,
      showandhide:showandhide
    }
    if(this.userPreferences.length===0){
      this.commonService.postuserpreference(obj).subscribe(res => {
        this.getuserPreferences();
        this.toastr.success('preference updated successfully');
      }, err => {
        this.toastr.error('error in geting ser preferences');
  
      })
    }
    if(this.userPreferences.length==1){
      this.commonService.UpadateUserPreferences(obj,'showandhideupdate').subscribe(res => {
        this.getuserPreferences();
        this.toastr.success('preference updated successfully');
      }, err => {
        this.toastr.error('error in geting ser preferences');
  
      })
    }
   
  }
  minAndMaxText: string = "Minimize";
  minAndMax(event) {
    let a = event.currentTarget.checked;
    let minandmax;
    if (a) {
      this.minAndMaxText = 'Maximize';
      //optionid=this.optionsList.find(e=>e.option.trim()==='minimize'.trim());
      minandmax=0
    }
    else {
      this.minAndMaxText = 'Minimize';
      //optionid=this.optionsList.find(e=>e.option.trim()==='maximize'.trim());
      minandmax=1
    }
    var obj = {
      userid: +this.userid,
      minandmax:minandmax
    }
    if(this.userPreferences.length===0)
    this.commonService.postuserpreference(obj).subscribe(res => {
      this.getuserPreferences();
      this.toastr.success('preference updated successfully');
    }, err => {
      this.toastr.error('error in geting ser preferences');

    })

    if(this.userPreferences.length===1){
      this.commonService.UpadateUserPreferences(obj,'minandmaxupdate').subscribe(res => {
        this.getuserPreferences();
        this.toastr.success('preference updated successfully');
      }, err => {
        this.toastr.error('error in geting ser preferences');
  
      })
    }
   
  }
 
 add this 3 methods in commonservice.ts
 
 getserPreferences(userpreference:any): Observable<any> {
    return this.httpClient.post(this.baseUrl + 'api/TopBarMenuApi/GetUserPreferences',userpreference,{ headers: header, observe: 'response' }
     );
  }
  postuserpreference(userpreference:any): Observable<any> {
    return this.httpClient.post(this.baseUrl + 'api/TopBarMenuApi/AddUserPreferences',userpreference,{ headers: header, observe: 'response' }
     );
  }
  UpadateUserPreferences(userpreference:any,updatetype:string): Observable<any> {
    return this.httpClient.put(this.baseUrl + 'api/TopBarMenuApi/UpadateUserPreferences/'+updatetype,userpreference,{ headers: header, observe: 'response' }
     );
  }
  
  --add this in startup.cs
  
   services.AddScoped<ITopBarMenu, TopBarMenuService>();
  
  