Пример #1
0
        public static string CadastrarNovaTRansacao(TransacaoCadastroModel transacao)
        {
            var requestUri =
                string.Format("{0}/transacao/cadastrar", baseURI);

            transacao.Password = CriptografiaAESHelper.Criptografar(transacao.Password);

            string retorno;

            using (var client = new HttpClient())
            {
                string postBody = JsonConvert.SerializeObject(transacao);

                var content = new StringContent(postBody, Encoding.UTF8, "application/json");

                var responseMessage = client.PostAsync(new Uri(requestUri), content).Result;

                responseMessage.EnsureSuccessStatusCode();

                var jsonResult = responseMessage.Content.ReadAsStringAsync().Result;

                retorno = JsonConvert.DeserializeObject <string>(jsonResult);
            }

            return(retorno);
        }
Пример #2
0
        public static bool AutenticarCliente(string nomeCliente, string password)
        {
            var cliente = new ClienteValidaModel
            {
                Nome     = nomeCliente,
                Password = CriptografiaAESHelper.Criptografar(password)
            };

            var requestUri =
                string.Format("{0}/cliente/validar", baseURI);

            bool ehValido;

            using (var client = new HttpClient())
            {
                string postBody = JsonConvert.SerializeObject(cliente);

                var content = new StringContent(postBody, Encoding.UTF8, "application/json");

                var responseMessage = client.PostAsync(new Uri(requestUri), content).Result;

                responseMessage.EnsureSuccessStatusCode();

                var jsonResult = responseMessage.Content.ReadAsStringAsync().Result;

                ehValido = JsonConvert.DeserializeObject <bool>(jsonResult);
            }

            return(ehValido);
        }