public IHttpActionResult ClockIn([FromBody] bool state) { if (!ModelState.IsValid || state == null) { string errors = ""; foreach (var modelstate in ModelState.Values) { foreach (var error in modelstate.Errors) { errors += "|" + error.ErrorMessage + "|" + error.Exception; } } throw new BadInputException() { ExceptionMessage = errors }; } var authenticatedUser = this.ActionContext.RequestContext.Principal as ClaimsPrincipal; var username = authenticatedUser.Claims.FirstOrDefault(x => x.Type == "user_name").Value; var id = _accountService.GetAccountByUsername(username).GordonID; var result = _jobsService.ClockIn(state, id); if (result == null) { return(NotFound()); } return(Created("Recorded answer :", result)); }