Advertisement
Guest User

Untitled

a guest
Oct 14th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      this.saveProductCategory = function() {
  2.         var productCategory = {
  3.             name: $scope.productCategory
  4.         };
  5.         var promise = ProductCategory.saveProductCategory(productCategory)
  6.         .then(function(data) {
  7.             $scope.vendorProductData.product_category_id = data.id;
  8.         })
  9.         .catch(function(data) {
  10.             $scope.message = data;
  11.         });
  12.        
  13.         return promise;
  14.     };
  15.    
  16.     this.saveVendorProduct = function() {
  17.        
  18.         var functionsToExecute = [];
  19.        
  20.         if(!$scope.vendorProductData.product_name_id) {
  21.             functionsToExecute.push(this.saveProductName());
  22.         }
  23.        
  24.         if(!$scope.vendorProductData.product_type_id) {
  25.             functionsToExecute.push(this.saveProductType());
  26.         }
  27.        
  28.         if(!$scope.vendorProductData.product_category_id) {
  29.             functionsToExecute.push(this.saveProductCategory());
  30.         }
  31.        
  32.         $q.all(functionsToExecute)
  33.         .then(
  34.             VendorProduct.saveVendorProduct($scope.vendorProductData)
  35.             .then(function(data) {
  36.                 $state.go('products');
  37.             })
  38.             .catch(function(data) {
  39.                 $scope.message = data;
  40.             })
  41.         );
  42.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement