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

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

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/ApplicationApi');
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/ApplicationApi/GetActiveApplication');
  }
  Post(application: Application): Observable<any> {

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

}
