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

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

  Get(chklistid: number ): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.get<any>(this.baseUrl + 'api/CheckListDetailsApi/' + chklistid.toString() );
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/CheckListDetailsApi/GetActiveCheckList');
  }
  GetCheckList(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/CheckListDetailsApi/GetCheckList');
  }
  Post(checklist: Checklistdetails): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/CheckListDetailsApi/add', checklist, { headers: header, observe: 'response' });
  }
  Delete(checklist: Checklistdetails) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/CheckListDetailsApi/activeordeactive', checklist, { headers: header, observe: 'response' });
  }
  Put(checklist: Checklistdetails): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/CheckListDetailsApi/Update', checklist, { headers: header, observe: 'response' });
  }
}
