var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var Peanut;
(function (Peanut) {
    var HelloWorldViewModel = (function (_super) {
        __extends(HelloWorldViewModel, _super);
        function HelloWorldViewModel() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.planetList = [];
            _this.nextPlanet = 1;
            _this.planetName = ko.observable('');
            _this.planetDescription = ko.observable('');
            return _this;
        }
        HelloWorldViewModel.prototype.getPlanet = function () {
            var me = this;
            var planet = me.planetList[me.nextPlanet - 1];
            if (me.nextPlanet == me.planetList.length) {
                me.nextPlanet = 1;
            }
            else {
                me.nextPlanet++;
            }
            me.planetName(planet.name);
            me.planetDescription(planet.description);
        };
        HelloWorldViewModel.prototype.getPlanetList = function (successFunction) {
            var me = this;
            var request = { 'includePluto': 1 };
            me.application.hideServiceMessages();
            me.application.showWaiter('Getting the solar system...');
            me.services.executeService('test\\GetPlanets', request, function (serviceResponse) {
                if (serviceResponse.Result == Peanut.serviceResultSuccess) {
                    me.planetList = serviceResponse.Value;
                    successFunction();
                }
            }).always(function () {
                me.application.hideWaiter();
            }).fail(function () {
                alert('Process failed!!');
            });
        };
        HelloWorldViewModel.prototype.init = function (successFunction) {
            var me = this;
            me.getPlanetList(successFunction);
        };
        return HelloWorldViewModel;
    }(Peanut.ViewModelBase));
    Peanut.HelloWorldViewModel = HelloWorldViewModel;
})(Peanut || (Peanut = {}));
//# sourceMappingURL=HelloWorldViewModel.js.map