import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { Observable } from 'rxjs';
import { HttpHeaders, HttpClient } from '@angular/common/http';
import { Subskill } from './subskill';

@Injectable({
  providedIn: 'root'
})
export class SubskillService {
  baseUrl: string = environment.serviceUrl;
  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/SubSkillApi');
  }

  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/SubSkillApi/GetActiveStage');
  }

  GetActiveSkill(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/SkillApi/GetActiveSkill');
  }

  Post(data: Subskill): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/SubSkillApi/add', data, { headers: header, observe: 'response' });
  }

  Delete(data: Subskill) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/SubSkillApi/activeordeactive', data, { headers: header, observe: 'response' });
  }

  Put(data: Subskill): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/SubSkillApi/Update', data, { headers: header, observe: 'response' });
  }

}
