public async Task <IActionResult> UpdateProjectComment(int id, [FromBody] NewComment newComment) { var userId = GetUserId(); var project = await _db.Projects .SingleAsync(p => p.OwnerId == userId && p.Id == id); if (project == null) { return(new NotFoundResult()); } project.Comment = newComment.Comment; await _db.SaveChangesAsync(); return(new JsonResult(project)); }
public async Task <IActionResult> UpdateExperimentComment(int id, [FromBody] NewComment n) { var userId = GetUserId(); var exper = await _db.Experiments.FindAsync(id); if (exper == null || exper.OwnerId != userId) { return(NotFound()); } exper.Comment = n.Comment; _db.Experiments.Update(exper); await _db.SaveChangesAsync(); return(new JsonResult(exper)); }