Guest User

Untitled

a guest
Dec 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. {
  2. id: 1, name: 'Mr.', description: 'dasdad', image: "sada", products: [
  3. { id: 0, name: 'Milos', description: "sdada", numberOfProduct: 1, image: 'ssad' },
  4. ]
  5.  
  6.  
  7.  
  8. },
  9. {
  10. id: 2, name: 'Misko', description: 'dasdad', image: "sada", products: [
  11. { id: 0, name: 'Milos', description: "sdada", numberOfProduct: 1, image: 'ssad' },
  12. { id: 1, name: 'Somi', description: "haha", numberOfProduct: 1, image: 'haha' }
  13. ]
  14. }
  15.  
  16. deleteCategory(product: CategoryModel | number): Observable<CategoryModel> {
  17. const id = typeof product === 'number' ? product : product.id;
  18. const url = `${this.cateogryUrl}/${id}`;
  19.  
  20. return this.http.delete<CategoryModel>(url, httpOptions).pipe(
  21.  
  22. catchError(this.handleError<CategoryModel>('deleteProduct'))
  23. );
  24. }
  25.  
  26. deleteProduct(product: ProductModel | number, index:number): Observable<ProductModel> {
  27. const idCategory = typeof product === 'number' ? product : product.id;
  28. const id = index;
  29.  
  30. const url = `${this.cateogryUrl}/${id}/${idCategory}`;
  31.  
  32. return this.http.delete<ProductModel>(url, httpOptions).pipe(
  33.  
  34. catchError(this.handleError<ProductModel>('deleteProduct'))
  35. );
  36.  
  37.  
  38. }
  39.  
  40. deteleProduct(indexCategory: number, indexProduct: number, category: ProductModel) {
  41. this.dataStorageServiceService.deleteProduct(category,indexProduct).subscribe()
  42. this.categoryList[indexCategory].products.splice(indexProduct, 1);
  43.  
  44. }
  45.  
  46. deteleCategory(indexProduct: number, category: CategoryModel) {
  47. this.dataStorageServiceService.deleteCategory(category).subscribe();
  48. this.categoryList.splice(indexProduct, 1);
  49.  
  50. }
Add Comment
Please, Sign In to add comment