public async Task <ActionResult> AddObservation() { User user = this.GetUserFromRequest(HttpContext.User); if (user == null) { return(BadRequest("There is no user associated with the observation!")); } Observation observation = await GetObservationFromBody(HttpContext.Request.Body); if (observation == null) { return(BadRequest("No observation data specified!")); } observation.UserID = user.UserID; if (!this.ValidateObservation(observation, out string errorMessage)) { return(BadRequest(errorMessage)); } bool success = _context.AddObservation(observation); if (success) { return(Ok(observation)); } else { return(BadRequest("There was an issue adding the observation to the database!")); } }