import { Injectable } from '@angular/core';
import { Observable } from "rxjs";
import { HttpClient, HttpHeaders, HttpParams, } from "@angular/common/http";
import { ApiRequestService } from "src/app/services/api/api-request.service";
import { environment } from 'src/environments/environment';
@Injectable({
  providedIn: 'root'
})
export class Formcservice{
  private baseURL = "Formc/Formc" ;  constructor(
    private http: HttpClient,
    private apiRequest: ApiRequestService,
  ) { }
  getAll(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.baseURL);
  }
  getById(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.get(_http);
  }
  create(data: any): Observable<any> {
    return this.apiRequest.post(this.baseURL, data);
  }
  update(id: number, data: any): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  delete(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.delete(_http);
  }




  uploadfilefileupload_field(ref:any, Formc:any, file:any): Observable<any>{
    const formData = new FormData();
    formData.append('file', file);
    return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Formc}`, formData);
  }

  uploadfilegetByIdfileupload_field(ref:any, Formc:any,): Observable<any> {
    return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Formc}`);
  }


  uploadfiledeletefileupload_field(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }

  uploadImageupload_field(ref:any, Formc:any, file:any): Observable<any>{
    const formData = new FormData();
    formData.append('file', file);
    return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Formc}`, formData);
  }

  uploadImageupload_fieldgetById(ref:any, Formc:any,): Observable<any> {
    return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Formc}`);
  }


  uploadImageupload_fielddelete(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }

  uploadAudio_field(ref:any, Formc:any, file:any): Observable<any>{
    const formData = new FormData();
    formData.append('file', file);
    return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Formc}`, formData);
  }

  uploadAudio_fieldgetById(ref:any, Formc:any,): Observable<any> {
    return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Formc}`);
  }


  uploadAudio_fielddelete(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }

  uploadVideo_field(ref:any, Formc:any, file:any): Observable<any>{
    const formData = new FormData();
    formData.append('file', file);
    return this.apiRequest.postFormData(`FileUpload/Uploadeddocs/${ref}/${Formc}`, formData);
  }

  uploadVideo_fieldgetById(ref:any, Formc:any,): Observable<any> {
    return this.apiRequest.get(`FileUpload/Uploadeddocs/${ref}/${Formc}`);
  }


  uploadVideo_fielddelete(id: number): Observable<any> {
    return this.apiRequest.delete(`FileUpload/Uploadeddocs/${id}`);
  }

// updateaction
}