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

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


    constructor(private httpClient: HttpClient) {
    }

    Get(): Observable<any> {
        return this.httpClient.get<any>(this.baseUrl + 'api/CustomerContactApi');
    }
    GetActive(): Observable<any> {
        return this.httpClient.get<any>(this.baseUrl + 'api/CustomerContactApi/GetActiveCustomerContact');
    }
    Post(customercontact: Customercontact): Observable<any> {

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

}
