public IHttpActionResult GetById(string id) { //validate id if (string.IsNullOrEmpty(id) || !Guid.TryParse(id, out var _)) { return(BadRequest()); } try { var result = _courseService.GetById(id); return(result == null?NotFound() : (IHttpActionResult)Ok(result)); } catch (InvalidOperationException ex) { return(InternalServerError(ex)); } }