public async Task <IHttpActionResult> GetByUserCriteriaAsync() { try { if (User.Identity.IsAuthenticated) { var sub = (User as ClaimsPrincipal).FindFirst("sub"); var result = await _courseService.GetByIdUserAsync(sub.Value); return(result == null?NotFound() : (IHttpActionResult)Ok(result)); } return(BadRequest()); } catch (InvalidOperationException ex) { return(InternalServerError(ex)); } }