public HttpResponseMessage GetWorkingTeachersByFirstThreeLetters([FromUri] string startsWith) { string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value; string userRole = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == ClaimTypes.Role).Value; logger.Info("UserRole: " + userRole + ", UserId: " + userId + ": Requesting Teacher ByFirstThreeLetters: " + startsWith); if (startsWith.Length != 3) { logger.Error("You entered " + startsWith.Length + " letters. Please put exactly three letters for this search."); return(Request.CreateResponse(HttpStatusCode.BadRequest, "You entered " + startsWith.Length + " letters. " + "Please put exactly three letters for this search.")); } try { IEnumerable <TeacherDTOItem> teachers = teachersService.GetWorkingTeachersByFirstThreeLetters(startsWith); logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, teachers)); } catch (Exception e) { logger.Error(e); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }