Пример #1
0
        public ReturnServices Get(string valor)
        {
            ReturnServices           retorno = new ReturnServices();
            Dictionary <int, string> procura = new Dictionary <int, string>();

            try
            {
                List <String> Dados = new SplitEntrada().SplitDados(valor);
                foreach (var ResultadoDados in Dados)
                {
                    for (int i = 0; i < lista.Count; i++)
                    {
                        if (lista[i].Key == int.Parse(ResultadoDados))
                        {
                            procura.Add(int.Parse(ResultadoDados), lista[i].Value);
                        }
                    }
                }
                string jsonString = JsonConvert.SerializeObject(procura, Formatting.None);
                retorno.Result       = true;
                retorno.ErrorMessage = string.Empty;
                retorno.Dados        = jsonString;
            } catch (Exception ex)
            {
                retorno.Result       = false;
                retorno.ErrorMessage = $"Ocorreu um erro: {ex.Message}";
                retorno.Dados        = string.Empty;
            }

            return(retorno);
        }
Пример #2
0
        public ReturnServices Get()
        {
            ReturnServices retorno    = new ReturnServices();
            string         jsonString = JsonConvert.SerializeObject(lista, Formatting.None);

            retorno.Result       = true;
            retorno.ErrorMessage = string.Empty;
            retorno.Dados        = jsonString;

            return(retorno);
        }
Пример #3
0
        public ReturnServices CadastrarCliente([FromBody] ClienteModel dados)
        {
            ReturnServices retorno = new ReturnServices();

            try
            {
                dados.RegistrarCliente();
                retorno.Result       = true;
                retorno.ErrorMessage = string.Empty;
            }
            catch (Exception e)
            {
                retorno.Result       = true;
                retorno.ErrorMessage = "Error ao tentar registrar cliente" + e.Message;
            }
            return(retorno);
        }
Пример #4
0
        public ReturnServices ExcluirCliente(int id)
        {
            ReturnServices retorno = new ReturnServices();

            try
            {
                retorno.Result       = true;
                retorno.ErrorMessage = "Cliente excluído com sucesso!!!";
                //AutenticaoService.Autenticar();
                new ClienteModel().ExcluirCliente(id);
            }
            catch (Exception e)
            {
                retorno.Result       = false;
                retorno.ErrorMessage = e.Message;
            }
            return(retorno);
        }
Пример #5
0
        public ReturnServices Post([FromBody] Calculo calc)
        {
            ReturnServices retorno = new ReturnServices();

            try
            {
                decimal resultado = (calc.Parcelas * calc.Valor) * 1.05m;
                retorno.Result       = true;
                retorno.ErrorMessage = string.Empty;
                retorno.Dados        = resultado.ToString();
            } catch (Exception ex)
            {
                retorno.Result       = false;
                retorno.ErrorMessage = $"Ocorreu um erro: {ex.Message}";
                retorno.Dados        = string.Empty;
            }

            return(retorno);
        }