import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { ListResponseModel } from '../models/listResponseModel' ; import { Product } from '../models/product' ; import { ResponseModel } from '../models/responseModel' ; @ Injectable ( { providedIn : 'root' } ) export class ProductService { apiUrl = 'https://localhost:44314/api/' ; constructor ( private httpClient ) { } getProducts ( ) { let newPath = this . apiUrl + "products/getall" ; return this . httpClient . get < ListResponseModel < Product > > ( newPath ) ; } getProductsByCategory ( categoryId ) { let newPath = this . apiUrl + "products/getbycategory?categoryId=" + categoryId ; return this . httpClient . get < ListResponseModel < Product > > ( newPath ) ; } add ( product ) { return this . httpClient . post < ResponseModel > ( this . apiUrl + "products/add" , product ) ; } }