public static Comment ToEntity(this SaveCommentRequestDTO saveCommentRequestDTO, Comment comment) { comment.CreatedDate = DateTime.Now; comment.ModifiedDate = DateTime.Now; comment.IsActive = true; comment.UserId = saveCommentRequestDTO.UserId; comment.CardId = saveCommentRequestDTO.CardId; comment.Comments = saveCommentRequestDTO.Comment; comment.Id = 0; return(comment); }
public async Task <IActionResult> SaveComment(SaveCommentRequestDTO saveCommentRequestDTO) { try { await _commentService.SaveComment(saveCommentRequestDTO); return(Ok()); } catch (Exception ex) { return(BadRequest("An error has occurred on Saving Card " + ex)); } }
public async Task SaveComment(SaveCommentRequestDTO saveCommentRequestDTO) { Comment comment = new Comment(); try { if (saveCommentRequestDTO != null) { saveCommentRequestDTO.ToEntity(comment); await _unitOfWork.CommentRepository.InsertCommentAsync(comment); } await _unitOfWork.Complete(); } catch (Exception ex) { _logger.LogExceptionError(ex.ToString()); throw ex; } }