(function () {
    BemsWebApplication.FmsConstructionEstimationViewModel = function (data) {
        this.SiteId = ko.observable();
        this.ConstructionId = ko.observable();
        this.EstimateDate = ko.observable();
        this.EstimateUserId = ko.observable();
        this.Safety01_CleanUp = ko.observable();
        this.Safety02_PersonalProtection = ko.observable();
        this.Safety03_FireExtinguisher = ko.observable();
        this.Safety04_HighPlaceWork = ko.observable();
        this.Safety05_Weld = ko.observable();
        this.Safety06_SurroundingCleanUp = ko.observable();
        this.Safety07_SurroundingHealthy = ko.observable();
        this.Safety08_Noise = ko.observable();
        this.Safety09_FacilityProtection = ko.observable();
        this.Safety10_Waste = ko.observable();
        this.Safety11_Execution = ko.observable();
        this.Safety12_Announcement = ko.observable();
        this.Ability01_Compliance = ko.observable();
        this.Ability02_Fault = ko.observable();
        this.Ability03_SkillLevel = ko.observable();
        this.Ability04_ProcessManagement = ko.observable();
        this.Ability05_Collaboration = ko.observable();
        this.Service01_Compliance = ko.observable();
        this.Service02_SkillLevel = ko.observable();
        this.Comment = ko.observable();
        this.TotalEstimateScore = ko.observable();
        this.SafetyScore = ko.observable();
        this.AbilityScore = ko.observable();
        this.ServiceScore = ko.observable();
        
        if (data)
            this.fromJS(data);
    };

    $.extend(BemsWebApplication.FmsConstructionEstimationViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                ConstructionId: this.ConstructionId(),
                EstimateDate: this.EstimateDate(),
                EstimateUserId: this.EstimateUserId(),
                Safety01_CleanUp: this.Safety01_CleanUp(),
                Safety02_PersonalProtection: this.Safety02_PersonalProtection(),
                Safety03_FireExtinguisher: this.Safety03_FireExtinguisher(),
                Safety04_HighPlaceWork: this.Safety04_HighPlaceWork(),
                Safety05_Weld: this.Safety05_Weld(),
                Safety06_SurroundingCleanUp: this.Safety06_SurroundingCleanUp(),
                Safety07_SurroundingHealthy: this.Safety07_SurroundingHealthy(),
                Safety08_Noise: this.Safety08_Noise(),
                Safety09_FacilityProtection: this.Safety09_FacilityProtection(),
                Safety10_Waste: this.Safety10_Waste(),
                Safety11_Execution: this.Safety11_Execution(),
                Safety12_Announcement: this.Safety12_Announcement(),
                Ability01_Compliance: this.Ability01_Compliance(),
                Ability02_Fault: this.Ability02_Fault(),
                Ability03_SkillLevel: this.Ability03_SkillLevel(),
                Ability04_ProcessManagement: this.Ability04_ProcessManagement(),
                Ability05_Collaboration: this.Ability05_Collaboration(),
                Service01_Compliance: this.Service01_Compliance(),
                Service02_SkillLevel: this.Service02_SkillLevel(),
                Comment: this.Comment(),
                TotalEstimateScore: this.TotalEstimateScore(),
                SafetyScore: this.SafetyScore(),
                AbilityScore: this.AbilityScore(),
                ServiceScore: this.ServiceScore(),
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.ConstructionId(data.ConstructionId);
                this.EstimateDate(data.EstimateDate);
                this.EstimateUserId(data.EstimateUserId);
                this.Safety01_CleanUp(data.Safety01_CleanUp);
                this.Safety02_PersonalProtection(data.Safety02_PersonalProtection);
                this.Safety03_FireExtinguisher(data.Safety03_FireExtinguisher);
                this.Safety04_HighPlaceWork(data.Safety04_HighPlaceWork);
                this.Safety05_Weld(data.Safety05_Weld);
                this.Safety06_SurroundingCleanUp(data.Safety06_SurroundingCleanUp);
                this.Safety07_SurroundingHealthy(data.Safety07_SurroundingHealthy);
                this.Safety08_Noise(data.Safety08_Noise);
                this.Safety09_FacilityProtection(data.Safety09_FacilityProtection);
                this.Safety10_Waste(data.Safety10_Waste);
                this.Safety11_Execution(data.Safety11_Execution);
                this.Safety12_Announcement(data.Safety12_Announcement);
                this.Ability01_Compliance(data.Ability01_Compliance);
                this.Ability02_Fault(data.Ability02_Fault);
                this.Ability03_SkillLevel(data.Ability03_SkillLevel);
                this.Ability04_ProcessManagement(data.Ability04_ProcessManagement);
                this.Ability05_Collaboration(data.Ability05_Collaboration);
                this.Service01_Compliance(data.Service01_Compliance);
                this.Service02_SkillLevel(data.Service02_SkillLevel);
                this.Comment(data.Comment);
                this.TotalEstimateScore(data.TotalEstimateScore);

                this.SafetyScore(data.SafetyScore);
                this.AbilityScore(data.AbilityScore);
                this.ServiceScore(data.ServiceScore);
                
            }
        }
    });
})();