"use strict";
webapimodule.config(function ($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise("/Login");
    //Defining 
    var states = [
        ({ name: 'Login', url: '/Login', templateUrl: 'index.html' }),
        ({ name: 'Home', url: '/Home', template: '<div home></div>' }),
    ];

    angular.forEach(states, function (item) {
        $stateProvider.state(item);
    });
});


webapimodule.controller("webapicontroller", function ($scope, $http, $location, $state) {
    $scope.isLoginSuccess = false;
    //$scope.response = "asdsd";
    $scope.UserDetails = {};
    /***********************************Get Today's Date Start***********************************************/
    $scope.todayDate = new Date();
    /***********************************Get Today's Date End***********************************************/


    $scope.record = 0;



    $scope.go = function (path) {

        $state.transitionTo(path);
    };

    $scope.onLoginClicked = function () {

        $scope.UserModel = {};
        $scope.UserModel.USERID = $scope.USERID;
        $scope.UserModel.PASSWORD = $scope.PASSWORD;
        var response={};
        response.IsValid = true;
        {
            if (response.IsValid) {
                $scope.IsLoginFailed = false;
                $scope.UserDetails = response;
                $scope.isLoginSuccess = $scope.UserDetails.IsValid;
                $scope.go('Home');
                //$scope.GetEmployeeFiles();
            }
            else {
                $scope.IsLoginFailed = true;
                ShowErrorMessage('Invalid username or password');
            }
        };
    }



    //For Logout Option
    $scope.onLogOut = function () {
        $scope.UserDetails = {};
        $scope.isLoginSuccess = false;
        $scope.mainGridOptions.dataSource.data([]);
        $scope.go('Login');
    }

    $scope.localAdminsClick = function () {
        //$scope.go('LocalAdmins');
    }
});
