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

@Injectable({
  providedIn: 'root'
})
export class MenuService {

  baseUrl: string = environment.serviceUrl;

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/MenuApi')
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/MenuApi/GetActiveMenu');
  }
  GetAllWithExclude(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/MenuApi/GetAllWithExclude');
  }
  Post(menu: Menu): Observable<any> {

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