示例#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);
        }
示例#3
0
        public bool ValidarCliente(string cliente, string password)
        {
            var pwd = CriptografiaAESHelper.Descriptografar(password);

            var registro = _repositorio.FindAll().FirstOrDefault(x => x.Nome == cliente && x.Password == pwd);

            return(registro != null ? registro.Ativo : false);
        }