Created
October 15, 2017 16:56
-
-
Save brunoportess/18e712f8a30d5f55657902414e475936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ESSA É A CONTROLLER DA API QUE RECEBE OS DADOS (ASPNET CORE) | |
[Produces("application/json")] | |
[Route("api/cupons/[action]")] | |
public class CuponsController : Controller | |
{ | |
private readonly CupomDAO _cupomDao; | |
private readonly ClienteDAO _clienteDao; | |
public CuponsController(IConfiguration configuration) | |
{ | |
_cupomDao = new CupomDAO(configuration); | |
_clienteDao = new ClienteDAO(configuration); | |
} | |
// POST: api/Cupons | |
[HttpPost] | |
public string VerificaCupom(string idParceiro, string codigo) | |
{ | |
return codigo; | |
//return _cupomDao.CupomClienteParceiro(idParceiro, codigo); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ESSE É O HTTPCLIENT DO APP QUE ENVIA OS DADOS | |
using (var client = new HttpClient()) | |
{ | |
client.BaseAddress = new Uri(Settings.RestAPISettings); | |
// Add string parameters | |
var content = new FormUrlEncodedContent(new[] { | |
new KeyValuePair<string, string>("idParceiro", idParceiro), | |
new KeyValuePair<string, string>("codigo", codigo) | |
}); | |
var result = await client.PostAsync("cupons/VerificaCupom/", content); | |
if (!result.IsSuccessStatusCode) return null; | |
var resultContent = await result.Content.ReadAsStringAsync(); | |
return JsonConvert.DeserializeObject<List<Cupom>>(resultContent); | |
//Debug.WriteLine(resultContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment