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 demotestservice{
  private StepperURL = "Stepper_table_config/Stepper_table_config";
  private FormaURL = "Forma/Forma" ;  private Advtest1URL = "Advtest1/Advtest1" ;  constructor(
    private http: HttpClient,
    private apiRequest: ApiRequestService,
  ) { }
gettabledata(id: number): Observable<any> {
    const _http = this.StepperURL + "/stepId/" + id;
    return this.apiRequest.get(_http);
  }

  saveStepperConfig(stepperId: number, tableId: number, tableName: string): Observable<any> {
    const params = new HttpParams()
      .set('stepperId', stepperId.toString())
      .set('tableId', tableId.toString())
      .set('tableName', tableName);

    return this.apiRequest.post(this.StepperURL, null, params); // null body, params used
  }  getAllForma(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.FormaURL);
  }
  getFormaById(id: number): Observable<any> {
    const _http = this.FormaURL + "/" + id;
    return this.apiRequest.get(_http);
  }
  createForma(data: any): Observable<any> {
    return this.apiRequest.post(this.FormaURL, data);
  }
  updateForma(id: number, data: any): Observable<any> {
    const _http = this.FormaURL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  deleteForma(id: number): Observable<any> {
    const _http = this.FormaURL + "/" + id;
    return this.apiRequest.delete(_http);
  }




























  getAllAdvtest1(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.Advtest1URL);
  }
  getAdvtest1ById(id: number): Observable<any> {
    const _http = this.Advtest1URL + "/" + id;
    return this.apiRequest.get(_http);
  }
  createAdvtest1(data: any): Observable<any> {
    return this.apiRequest.post(this.Advtest1URL, data);
  }
  updateAdvtest1(id: number, data: any): Observable<any> {
    const _http = this.Advtest1URL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  deleteAdvtest1(id: number): Observable<any> {
    const _http = this.Advtest1URL + "/" + id;
    return this.apiRequest.delete(_http);
  }








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

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


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

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

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


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

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

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


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

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

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


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







// updateaction
}