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

@Injectable({
  providedIn: 'root'
})
export class TrackService {
  baseUrl: string = environment.serviceUrl;
  constructor(private httpClient: HttpClient) { }
  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/TrackApi');
}
GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/TrackApi/GetActiveTrack');
}
Post(track: Track): Observable<any> {

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