Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. [HttpGet("{id}", Name = "Get")]
  2. public IActionResult Get(string id)
  3. {
  4. try
  5. {
  6. ObjectResult result;
  7. Documents documents = Consulta.Consul(id);
  8. if (documents.CaseNumber == null)
  9. {
  10. result = new ObjectResult("No existe informacion con el ID de transacción: " + id)
  11. {
  12. StatusCode = (int)HttpStatusCode.InternalServerError
  13. };
  14. _logger.LogWarning(DateTime.Now.ToString() + "--No existe informacion con el ID de transacción: " + id);
  15. return result;
  16. }
  17. else
  18. {
  19. result = new ObjectResult(documents)
  20. {
  21. StatusCode = (int)HttpStatusCode.OK
  22. };
  23. _logger.LogInformation(DateTime.Now.ToString() + "--Consulta correcta: " + id);
  24. return result;
  25. }
  26. }
  27. catch(Exception ex)
  28. {
  29. ObjectResult result = new ObjectResult(ex.ToString())
  30. {
  31. StatusCode = (int)HttpStatusCode.InternalServerError
  32. };
  33. _logger.LogError(DateTime.Now.ToString() + "--" + ex.ToString());
  34. return result;
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement