public HttpResponseMessage PutTaskToPlan(int id, int taskId, string sectionId, string priority) { try { int?section; int?priorityNew; if (string.IsNullOrEmpty(sectionId)) { section = null; } else { section = int.Parse(sectionId); } if (string.IsNullOrEmpty(priority)) { priorityNew = null; } else { priorityNew = int.Parse(priority); } var success = planService.AddTaskToPlan(id, taskId, section, priorityNew); if (success) { var log = $"Succesfully add task with id {taskId} to plan with id = {id}"; tracer.Info(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, log); return(Request.CreateResponse(HttpStatusCode.OK, $"Succesfully added task to plan ({id}).")); } tracer.Warn(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, "Error occured on adding task to plan"); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Incorrect request syntax or task or plan does not exist.")); } catch (EntityException e) { tracer.Error(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }