Add commodity and quantity to input forms
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user