(function() { BemsWebApplication.FmsMaterialPurchaseOrderMaterialViewModel = function(data) { this.SiteId = ko.observable(); this.BusinessFieldId = ko.observable(); this.PurchaseOrderId = ko.observable(); this.MaterialId = ko.observable(); this.MaterialCount = ko.observable(); this.UnitCost = ko.observable(); this.StoredCount = ko.observable(); if(data) this.fromJS(data); }; $.extend(BemsWebApplication.FmsMaterialPurchaseOrderMaterialViewModel.prototype, { toJS: function() { return { SiteId: this.SiteId(), BusinessFieldId: this.BusinessFieldId(), PurchaseOrderId: this.PurchaseOrderId(), MaterialId: this.MaterialId(), MaterialCount: this.MaterialCount(), UnitCost: this.UnitCost(), StoredCount: this.StoredCount(), }; }, fromJS: function(data) { if(data) { this.SiteId(data.SiteId); this.BusinessFieldId(data.BusinessFieldId); this.PurchaseOrderId(data.PurchaseOrderId); this.MaterialId(data.MaterialId); this.MaterialCount(data.MaterialCount); this.UnitCost(data.UnitCost); this.StoredCount(data.StoredCount); } } }); })();