import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { environment } from 'src/environments/environment'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @Injectable({ providedIn: 'root', }) export class GoalPlanInventoryService { private baseUrl = ''; private baseUDCUrl = ''; private params = new HttpParams(); constructor(private http: HttpClient) { this.baseUrl = environment.hostUrl + '/DataManage'; this.baseUDCUrl = environment.hostUrl + '/udc'; } getGoalPlanTemplateDataById(templateId: number): Observable { const apid: number = environment.api.GoalPlanTemplateData; return this.http.get(this.baseUrl + '/' + apid + '?search=Id:' + templateId).pipe(map(res => res as T[] | any)); } getGoalPlanTemplateData(): Observable { const apid: number = environment.api.GoalPlanTemplateData; return this.http.get(this.baseUrl + '/' + apid + '?search=IsActive:1').pipe(map(res => res as T[] | any)); } getGoalPlanInventoryData(templateId, email): Observable { const apid: number = environment.api.GoalPlanInventory; return this.http.get(this.baseUrl + '/' + apid + '?search=GoalPlanTemplateId:' + templateId + ' and CreatedBy:' + "'" + email + "'").pipe(map(res => res as T[] | any)); } addGoalPlanTemplate(value: T, id: number) { const apid: number = environment.api.GoalPlanInventory; return this.http.post(this.baseUrl + '/' + apid, value).pipe(map(res => res as boolean | any)); // Successfull Insert response=TRUE,Else=False } updateGoalPlanTemplate(value: T, params: number) { const apid: number = environment.api.GoalPlanInventory; return this.http.put(this.baseUrl + '/' + apid + '?search=Id:' + params, value) .pipe(map(res => res as boolean| any)); // Successfull Update response=TRUE,Else=False } deleteGoalPlan(params: number): Observable { const apid: number = environment.api.GoalPlanInventory; return this.http.delete(this.baseUrl + '/' + apid + '?search=Id:' + params).pipe(map(res => res as boolean| any)); } getGoalCategoryActiveData(): Observable { const apid: number = environment.api.GoalCategoryData; return this.http.get(this.baseUrl + '/' + apid + '?search=IsActive:1').pipe(map(res => res as T[] | any)); } }