(function () {
    BemsWebApplication.FmsMaterialReleaseViewModel = function (data) {
        this.SiteId = ko.observable();
        this.ReleaseDate = ko.observable();
        this.MaterialReleaseId = ko.observable();
        this.ReleaseTypeId = ko.observable();
        this.WorkRequestId = ko.observable();
        this.BusinessFieldId = ko.observable();
        this.WarehouseId = ko.observable();
        this.MaterialId = ko.observable();
        this.MaterialCount = ko.observable();
        this.ReleaseTotalCost = ko.observable();
        this.ConfirmedUserId = ko.observable();
        this.ConfirmedDate = ko.observable();
        this.IsConfirmed = ko.observable();
        this.Comment = ko.observable();
        this.AdjustmentUserId = ko.observable();
        this.AdjustmentTypeId = ko.observable();

        this.StockCountByPoint = ko.observable();

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

    $.extend(BemsWebApplication.FmsMaterialReleaseViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                ReleaseDate: this.ReleaseDate(),
                MaterialReleaseId: this.MaterialReleaseId(),
                ReleaseTypeId: this.ReleaseTypeId(),
                WorkRequestId: this.WorkRequestId(),
                BusinessFieldId: this.BusinessFieldId(),
                WarehouseId: this.WarehouseId(),
                MaterialId: this.MaterialId(),
                MaterialCount: this.MaterialCount(),
                ReleaseTotalCost: this.ReleaseTotalCost(),
                ConfirmedUserId: this.ConfirmedUserId(),
                ConfirmedDate: this.ConfirmedDate(),
                IsConfirmed: this.IsConfirmed(),
                Comment: this.Comment(),
                AdjustmentUserId: this.AdjustmentUserId(),
                AdjustmentTypeId: this.AdjustmentTypeId(),
                StockCountByPoint: this.StockCountByPoint()
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.ReleaseDate(data.ReleaseDate);
                this.MaterialReleaseId(data.MaterialReleaseId);
                this.ReleaseTypeId(data.ReleaseTypeId);
                this.WorkRequestId(data.WorkRequestId);
                this.BusinessFieldId(data.BusinessFieldId);
                this.WarehouseId(data.WarehouseId);
                this.MaterialId(data.MaterialId);
                this.MaterialCount(data.MaterialCount);
                this.ReleaseTotalCost(data.ReleaseTotalCost);
                this.ConfirmedUserId(data.ConfirmedUserId);
                this.ConfirmedDate(data.ConfirmedDate);
                this.IsConfirmed(data.IsConfirmed);
                this.Comment(data.Comment);
                this.AdjustmentUserId(data.AdjustmentUserId);
                this.AdjustmentTypeId(data.AdjustmentTypeId);
                this.StockCountByPoint(data.StockCountByPoint);
                

            }
        }
    });
})();