Пример #1
0
 public IActionResult GetAllUsuarios()
 {
     try {
         Console.WriteLine("[GetAllUsuarios] -> listar todos los usuarios");
         List <Usuario> result = usuariosService.ListAllUsuarios();
         if (result == null || result.Count() == 0)
         {
             Console.WriteLine("[GetAllUsuarios] -> no hay resultados");
             RestResponse r = RestUtils.GenerateResponseOkEmpty();
             r.Header.Message = RestUtils.RESPONSE_NOTFOUND_MSG;
             return(NotFound(r));
         }
         Console.WriteLine("[GetAllUsuarios] -> request exitosa");
         RestResponse response = RestUtils.GenerateResponseOkWithData(result);
         return(Ok(response));
     } catch (Exception exception) {
         Console.WriteLine("[GetAllUsuarios] -> " + RestUtils.RESPONSE_INTERNAL_ERROR_MSG);
         RestResponse response = RestUtils.GenerateResponseErrorWith(
             new ResponseError(
                 exception.Message,
                 exception.GetType().ToString()
                 )
             );
         response.Header.Message = RestUtils.RESPONSE_INTERNAL_ERROR_MSG;
         return(StatusCode(
                    StatusCodes.Status500InternalServerError,
                    response
                    ));
     }
 }