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

@Injectable({
  providedIn: 'root'
})
export class ChecklistService {
  baseUrl: string = environment.serviceUrl;

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/CheckListApi')
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/CheckListApi/GetActiveCheckList')
  }
  Post(checklist: CheckList): Observable<any> {

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

}
