(function () {
    BemsWebApplication.FmsContractViewModel = function (data) {
        this.SiteId = ko.observable();
        this.ContractId = ko.observable();
        this.Name = ko.observable();
        this.PartnerTypeId = ko.observable();
        this.PartnerId = ko.observable();
        this.ContractDate = ko.observable();
        this.StartDate = ko.observable();
        this.EndDate = ko.observable();
        this.OwnerShipName = ko.observable();
        this.OwnerShipPhoneNo = ko.observable();
        this.CommitmentMan = ko.observable();
        this.Comment = ko.observable();

        this.ContractClassId = ko.observable();
        this.ContractTypeId = ko.observable();
        this.ContractMethodId = ko.observable();
        this.PaymentTypeId = ko.observable();
        
        if (data)
            this.fromJS(data);
    };

    $.extend(BemsWebApplication.FmsContractViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                ContractId: this.ContractId(),
                Name: this.Name(),
                PartnerTypeId: this.PartnerTypeId(),
                PartnerId: this.PartnerId(),
                ContractDate: this.ContractDate(),
                StartDate: this.StartDate(),
                EndDate: this.EndDate(),
                OwnerShipName: this.OwnerShipName(),
                OwnerShipPhoneNo: this.OwnerShipPhoneNo(),
                CommitmentMan: this.CommitmentMan(),
                Comment: this.Comment(),

                ContractClassId: this.ContractClassId(),
                ContractTypeId: this.ContractTypeId(),
                ContractMethodId: this.ContractMethodId(),
                PaymentTypeId: this.PaymentTypeId(),
                
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.ContractId(data.ContractId);
                this.Name(data.Name);
                this.PartnerTypeId(data.PartnerTypeId);
                this.PartnerId(data.PartnerId);
                this.ContractDate(data.ContractDate);
                this.StartDate(data.StartDate);
                this.EndDate(data.EndDate);
                this.OwnerShipName(data.OwnerShipName);
                this.OwnerShipPhoneNo(data.OwnerShipPhoneNo);
                this.CommitmentMan(data.CommitmentMan);
                this.Comment(data.Comment);
                
                this.ContractClassId(data.ContractClassId);
                this.ContractTypeId(data.ContractTypeId);
                this.ContractMethodId(data.ContractMethodId);
                this.PaymentTypeId(data.PaymentTypeId);
                
                
            }
        }
    });
})();