(function () {
    BemsWebApplication.FmsEquipmentHistoryViewModel = function (data) {
        this.SiteId = ko.observable();
        this.EquipmentHistoryId = ko.observable();
        this.EquipmentId = ko.observable();
        this.TotalStockCount = ko.observable();
        this.CurrentStockCount = ko.observable();
        this.RentCount = ko.observable();
        this.CurrentRentCount = ko.observable();
        this.ReturnCount = ko.observable();
        this.LossCount = ko.observable();
        this.StoredCount = ko.observable();
        this.EquipmentRentId = ko.observable();
        this.EquipmentStateTypeId = ko.observable();
        this.AddDate = ko.observable();
        this.UpdateDate = ko.observable();
        this.IsReturned = ko.observable();

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

    $.extend(BemsWebApplication.FmsEquipmentHistoryViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                EquipmentHistoryId: this.EquipmentHistoryId(),
                EquipmentId: this.EquipmentId(),
                TotalStockCount: this.TotalStockCount(),
                CurrentStockCount: this.CurrentStockCount(),
                RentCount: this.RentCount(),
                CurrentRentCount: this.CurrentRentCount(),
                ReturnCount: this.ReturnCount(),
                LossCount: this.LossCount(),
                StoredCount: this.StoredCount(),
                EquipmentRentId: this.EquipmentRentId(),
                EquipmentStateTypeId: this.EquipmentStateTypeId(),
                AddDate: this.AddDate(),
                UpdateDate: this.UpdateDate(),
                IsReturned: this.IsReturned(),
                
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.EquipmentHistoryId(data.EquipmentHistoryId);
                this.EquipmentId(data.EquipmentId);
                this.TotalStockCount(data.TotalStockCount);
                this.CurrentStockCount(data.CurrentStockCount);
                this.RentCount(data.RentCount);
                this.CurrentRentCount(data.CurrentRentCount);
                this.ReturnCount(data.ReturnCount);
                this.LossCount(data.LossCount);
                this.StoredCount(data.StoredCount);
                this.EquipmentRentId(data.EquipmentRentId);
                this.EquipmentStateTypeId(data.EquipmentStateTypeId);
                this.AddDate(data.AddDate);
                this.UpdateDate(data.UpdateDate);
                this.IsReturned(data.IsReturned);
                
            }

        }
    });
})();