You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
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<Cart> {
|
|
let cart_post_api = this.path + "/cart/" + uid + "/" + pid;
|
|
return this.httpClent.post<Cart>(cart_post_api,cart);
|
|
}
|
|
|
|
public getCartByUser(uid:string): Observable<Cart[]> {
|
|
let cart_get_api = this.path + "/cart/" + uid;
|
|
return this.httpClent.get<Cart[]>(cart_get_api);
|
|
}
|
|
|
|
public editCartItem(cart:Cart,cid:number): Observable<any> {
|
|
let cart_get_api = this.path + "/cart/" + cid;
|
|
return this.httpClent.put<any>(cart_get_api,cart);
|
|
}
|
|
|
|
public deleteCartItem(cid:number): Observable<any> {
|
|
let cart_delete_api = this.path + "/cart/" + cid;
|
|
return this.httpClent.delete<any>(cart_delete_api);
|
|
}
|
|
}
|