public IActionResult UpdateCourseComment([FromRoute] int assignmentId, [FromRoute] int commentId, [FromBody] JObject json) { return(this.NoContent(() => { AssignmentCommentDTO dto = json.ToObject <AssignmentCommentDTO>(); return _AssignmentRepo.UpdateComment(assignmentId, commentId, dto).Equals(TransactionStatus.SUCCESS); }, _Logger)); }
public IActionResult UpdateCourseComment([FromRoute] int assignmentId, [FromRoute] int commentId, [FromBody] JObject json) { int successTransactionValue = (int)TransactionStatus.SUCCESS; return(this.NoContent(() => { AssignmentCommentDTO dto = json.ToObject <AssignmentCommentDTO>(); return _AssignmentRepo.UpdateComment(assignmentId, commentId, dto).Equals(successTransactionValue); })); }
public IActionResult AddAssignmentComment([FromRoute] int assignmentId, [FromBody] AssignmentCommentAddDTO dto) { return(this.Created(() => { AssignmentCommentDTO comment = _Mapper.Map <AssignmentCommentAddDTO, AssignmentCommentDTO>(dto); comment.Author = User.Identity.Name; return _AssignmentRepo.AddComment(assignmentId, comment).Equals((int)TransactionStatus.SUCCESS) ? dto.ToJson() : new JObject(); })); }
public int UpdateComment(int assignmentId, int commentId, AssignmentCommentDTO dto) { Assignment assignment = Find(i => i.Id.Equals(assignmentId)); AssignmentComment comment = _Context.AssignmentComments.Where(i => i.Id.Equals(commentId)).FirstOrDefault(); if (assignment is null || assignment.Id <= 0 || comment is null || comment.Id <= 0) { return((int)TransactionStatus.ENTITY_NOT_FOUND); } _Context.Entry(comment).CurrentValues.SetValues(dto); return(_Context.SaveChanges()); }
public int AddComment(int assignmentId, AssignmentCommentDTO dto) { Assignment assignment = Find(i => i.Id.Equals(assignmentId)); if (assignment is null || assignment.Id <= 0) { return((int)TransactionStatus.ENTITY_NOT_FOUND); } AssignmentComment comment = _Mapper.Map <AssignmentCommentDTO, AssignmentComment>(dto); assignment.Comments.Add(comment); return(_Context.SaveChanges()); }