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

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

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DepartmentApi')
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DepartmentApi/GetActiveDepartment')
  }
  Post(department: Department): Observable<any> {

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

}
