public HttpResponseMessage PostAndReturnId([FromBody] PlanDTO value) { try { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var result = planService.AddAndGetId(value); if (result != null) { var log = $"Succesfully created plan {value.Name} with id = {result} by user with id = {value.CreatorId}"; tracer.Info(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, log); return(Request.CreateResponse(HttpStatusCode.OK, result)); } } catch (EntityException e) { tracer.Error(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } tracer.Warn(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, "Error occured on creating plan"); const string message = "Incorrect request syntax."; return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, message)); }