public async Task <IActionResult> AddProjectComment([FromBody] [Bind("projectId", "user", "CommentHeading", "comment")] AddProjectComment projectComment) { if (ModelState.IsValid) { ProjectComment pC = await _projectRepository.AddProjectCommentAsync(projectComment); if (pC != null) { return(Ok(pC)); } else { return(Ok("error")); } } else { return(BadRequest()); } }
//////////////// //////////////// //////////////// Comments //////////////// // Are divided in 3 just in case we want to make the // // comment-sections different. Information etc.. // public async Task <ProjectComment> AddProjectCommentAsync(AddProjectComment pC) { ProjectComment comment = new ProjectComment { CommentRegistered = DateTime.Now, ByUser = pC.user, Comment = pC.comment, CommentHeading = pC.commentHeading, ProjectId = await getProjectId(pC.projectId), Unique_IdString = getGuid() }; _db.Add(comment); if (await _db.SaveChangesAsync() > 0) { return(comment); } else { return(null); } }