(function () {
    BemsWebApplication.FmsEquipmentExViewModel = function (data) {
        this.SiteId = ko.observable();
        this.EquipmentId = ko.observable();
        this.Name = ko.observable();
        this.EquipmentTypeId = ko.observable();
        this.WarehouseId = ko.observable();
        this.Unit = ko.observable();
        this.Standard = ko.observable();
        this.AddDate = ko.observable();
        this.UpdateDate = ko.observable();
        this.RegisterUserId = ko.observable();
        this.SupplierName = ko.observable();
        this.SupplierPhoneNo = ko.observable();
        
        this.EquipmentCodeTypeName = ko.observable();
        this.TotalStockCount = ko.observable();
        this.CurrentStockCount = ko.observable();
        this.StoredCount = ko.observable();
        this.CurrentRentCount = ko.observable();
        
        this.CurrentStoredCount = ko.observable();
        this.CurrentReturnCount = ko.observable();
        this.CurrentLossCount = ko.observable();

        this.ImageFileId = ko.observable();

        if (data)
            this.fromJS(data);
    };

    $.extend(BemsWebApplication.FmsEquipmentExViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                Name: this.Name(),
                EquipmentId: this.EquipmentId(),
                EquipmentTypeId: this.EquipmentTypeId(),
                WarehouseId: this.WarehouseId(),
                Unit: this.Unit(),
                Standard: this.Standard(),
                AddDate: this.AddDate(),
                UpdateDate: this.UpdateDate(),
                RegisterUserId: this.RegisterUserId(),
                SupplierName: this.SupplierName(),
                SupplierPhoneNo: this.SupplierPhoneNo(),

                EquipmentCodeTypeName: this.EquipmentCodeTypeName(),
                TotalStockCount: this.TotalStockCount(),
                CurrentStockCount: this.CurrentStockCount(),
                StoredCount: this.StoredCount(),
                CurrentRentCount: this.CurrentRentCount(),

                CurrentStoredCount: this.CurrentStoredCount(),
                CurrentReturnCount: this.CurrentReturnCount(),
                CurrentLossCount: this.CurrentLossCount(),

                ImageFileId: this.ImageFileId()
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.Name(data.Name);
                this.EquipmentId(data.EquipmentId);
                this.EquipmentTypeId(data.EquipmentTypeId);
                this.WarehouseId(data.WarehouseId);
                this.Unit(data.Unit);
                this.Standard(data.Standard);
                this.AddDate(data.AddDate);
                this.UpdateDate(data.UpdateDate);
                this.RegisterUserId(data.RegisterUserId);
                this.SupplierName(data.SupplierName);
                this.SupplierPhoneNo(data.SupplierPhoneNo);

                this.EquipmentCodeTypeName(data.EquipmentCodeTypeName);
                this.TotalStockCount(data.TotalStockCount);
                this.CurrentStockCount(data.CurrentStockCount);
                this.StoredCount(data.StoredCount);
                this.CurrentRentCount(data.CurrentRentCount);

                this.CurrentStoredCount(data.CurrentStoredCount);
                this.CurrentReturnCount(data.CurrentReturnCount);
                this.CurrentLossCount(data.CurrentLossCount);
                
                this.ImageFileId(data.ImageFileId);
            }
        }
    });
})();