public async Task <AutenticacaoResponsePost> Post([FromBody] AutenticacaoRequestPost request) { AutenticacaoResponsePost result = new AutenticacaoResponsePost(); if (request.Email == "*****@*****.**" && request.Password == "123456") { AutenticacaoModel autenticacaoModel = new AutenticacaoModel { Token = "dfadsfa4567" }; result.Autenticacao = autenticacaoModel; result.IsValid = 1; } else { result.IsValid = 0; } return(result); }
public static async Task <AutenticacaoResponsePost> Post(RequestAutenticacaoPost request) { var uri = new Uri(string.Format("{0}/Autenticacao/", urlBase)); AutenticacaoResponsePost retorno = null; using (var cliente = new HttpClient()) { var data = JsonConvert.SerializeObject(request); var content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = await cliente.PostAsync(uri, content); if (response.IsSuccessStatusCode) { var responseString = await response.Content.ReadAsStringAsync(); retorno = JsonConvert.DeserializeObject <AutenticacaoResponsePost>(responseString); } } return(retorno); }