public HttpResponseMessage Post(int planTaskId, CommentDTO comment) { try { if (commentService.AddCommentToPlanTask(planTaskId, comment)) { return(Request.CreateResponse(HttpStatusCode.OK, "Comment succesfully created")); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Creation error")); } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Internal creation error")); } }
public HttpResponseMessage Post(int planTaskId, CommentDTO comment) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } try { if (commentService.AddCommentToPlanTask(planTaskId, comment)) { var log = $"Succesfully created comment with id = {comment.Id} by user id = {comment.CreatorId}"; tracer.Info(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, log); return(Request.CreateResponse(HttpStatusCode.OK, "Comment succesfully created")); } tracer.Warn(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, "Error occured on creating comment"); return(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Not possibly to add comment: task in this plan does not exist")); } catch (EntityException e) { tracer.Error(Request, ControllerContext.ControllerDescriptor.ControllerType.FullName, e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Internal creation error")); } }