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

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

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/AllocationTypeApi');
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/AllocationTypeApi/GetActiveAllocationType');
  }
  Post(allocationtype: AllocationType): Observable<any> {

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

}
