import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { Cart } from '../model/cart.model'; @Injectable({ providedIn: 'root' }) export class CartService { path:String = "http://localhost:59279/api2"; constructor(private httpClent:HttpClient) { } public postCart(cart:Cart,uid:string,pid:number): Observable { let cart_post_api = this.path + "/cart/" + uid + "/" + pid; return this.httpClent.post(cart_post_api,cart); } public getCartByUser(uid:string): Observable { let cart_get_api = this.path + "/cart/" + uid; return this.httpClent.get(cart_get_api); } public editCartItem(cart:Cart,cid:number): Observable { let cart_get_api = this.path + "/cart/" + cid; return this.httpClent.put(cart_get_api,cart); } public deleteCartItem(cid:number): Observable { let cart_delete_api = this.path + "/cart/" + cid; return this.httpClent.delete(cart_delete_api); } }