(function () {
    'use strict';

    angular
        .module('controleApp')
        .factory('Consulta', Consulta);

    Consulta.$inject = ['$injector', 'Server'];

    function Consulta($injector, Server) {

        function ConsultaUsuarioLogado(successCallback, errorCallback) {
            let action = 'Autenticador/Autenticador/ConsultaUsuarioLogado';
            Server.getArea(action, null, successCallback, errorCallback);
        }

        function ConsultaVersao(successCallback, errorCallback) {
            let action = 'Configuracoes/ConsultaVersao';
            Server.get(action, null, successCallback, errorCallback);
        }

        function ConsultaMensagensRapidas(obj, successCallback, errorCallback) {
            let action = 'Mensagens/CarregarMensagensRapidas?take=' + obj.take + '&skip=' + obj.skip + '&typeOrder=' + obj.typeOrder + "&orderAsc=" + obj.orderAsc;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarMensagemPorCodigo(codigo, successCallback, errorCallback) {
            let action = 'Mensagens/CarregarMensagemPorCodigo?codigo=' + codigo;
            Server.get(action, null, successCallback, errorCallback);
        }

        function ConsultaAlertas(obj, successCallback, errorCallback) {
            let action = 'Alertas/CarregarAlertas?take=' + obj.take + '&skip=' + obj.skip + '&typeOrder=' + obj.typeOrder + "&orderAsc=" + obj.orderAsc;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarAlertaPorCodigo(codigo, successCallback, errorCallback) {
            let action = 'Alertas/CarregarAlertaPorCodigo?codigo=' + codigo;
            Server.get(action, null, successCallback, errorCallback);
        }

        function ConsultaConfiguracoes(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarConfiguracoes?take=' + obj.take + '&skip=' + obj.skip + '&typeOrder=' + obj.typeOrder + "&orderAsc=" + obj.orderAsc;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarOperacoes(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarOperacoes?codigoOperacao=' + obj;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarMacros(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarMacros?codigoOperacao=' + obj;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarAplicacoes(successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarAplicacoes';
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarConfigAplicacoes(successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarConfigAplicacoes';
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarCodigoAplicacao(successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarCodigoAplicacao';
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarConfiguracaoEdicao(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarConfiguracaoEdicao?codigoConfiguracao=' + obj;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarHistorico(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarHistorico?codigoConfiguracao=' + obj;
            Server.get(action, null, successCallback, errorCallback);
        }

        function CarregarListaMacros(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/CarregarListaMacros?codigoMacro=' + obj;
            Server.get(action, null, successCallback, errorCallback);
        }

        function LimparFiltro(obj, successCallback, errorCallback) {
            let action = 'Configuracoes/LimparFiltro?take=' + obj.take + '&typeOrder=' + obj.typeOrder + '&asc=' + obj.asc;
            Server.get(action, null, successCallback, errorCallback);
        }

        return {
            ConsultaUsuarioLogado: ConsultaUsuarioLogado,
            ConsultaVersao: ConsultaVersao,
            ConsultaMensagensRapidas: ConsultaMensagensRapidas,
            CarregarMensagemPorCodigo: CarregarMensagemPorCodigo,
            ConsultaAlertas: ConsultaAlertas,
            CarregarAlertaPorCodigo: CarregarAlertaPorCodigo,
            ConsultaConfiguracoes: ConsultaConfiguracoes,
            CarregarOperacoes: CarregarOperacoes,
            CarregarMacros: CarregarMacros,
            CarregarAplicacoes: CarregarAplicacoes,
            CarregarConfigAplicacoes: CarregarConfigAplicacoes,
            CarregarCodigoAplicacao: CarregarCodigoAplicacao,
            CarregarConfiguracaoEdicao: CarregarConfiguracaoEdicao,
            CarregarHistorico: CarregarHistorico,
            CarregarListaMacros: CarregarListaMacros,
            LimparFiltro: LimparFiltro,
        }
    }
})();
