Add commodity and quantity to input forms

This commit is contained in:
2016-08-11 09:27:38 -04:00
parent 0b0cb7c73a
commit f4e3ac1cce
11 changed files with 200 additions and 29 deletions
@@ -11,7 +11,7 @@
add: add,
update: update,
inventories: inventories,
getInventory: getInventory
getInventory: getInventory,
};
return svc;
@@ -42,6 +42,56 @@
if (inventories[i].Id == id) return inventories[i];
}
return null;
}
}
})();
(function () {
window.app.factory('inventoryTypeSvc', inventoryTypeSvc);
inventoryTypeSvc.$inject = ['$http'];
function inventoryTypeSvc($http) {
var inventoryTypes = [];
loadInventoryTypes();
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
getInventoryType: getInventoryType
};
return svc;
function loadInventoryTypes() {
$http.post('/InventoryType/All')
.success(function (data) {
inventoryTypes.addRange(data);
});
}
function add(inventoryType) {
return $http.post('/InventoryType/Add', inventoryType)
.success(function (inventoryType) {
inventoryTypes.unshift(inventoryType);
});
}
function update(existingInventory, updatedInventory) {
return $http.post('/InventoryType/Update', updatedInventory)
.success(function (inventory) {
angular.extend(existingInventory, inventory);
});
}
function getInventoryType(id) {
for (var i = 0; i < inventoryTypes.length; i++) {
if (inventoryTypes[i].Id == id) return inventoryTypes[i];
}
return null;
}
}