public HttpResponseMessage GetAParentByJmbg(string jmbg) { string userId = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value; logger.Info("UserId: " + userId + ": Requesting User Account By Jmbg: " + jmbg); if (jmbg.Length != 13) { logger.Info("The JMBG must be 13 characters long."); return(Request.CreateResponse(HttpStatusCode.BadRequest, "The JMBG must be 13 characters long. " + "You entered " + jmbg.Length + " characters.")); } try { Parent user = parentsService.GetByJmbg(jmbg); if (user == null) { logger.Info("The user is not in the system."); return(Request.CreateResponse(HttpStatusCode.BadRequest, "The user is not in the system.")); } logger.Info("Success!"); return(Request.CreateResponse(HttpStatusCode.OK, user)); } catch (Exception e) { logger.Error(e); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }