public void AddComment(CommentViewModel model, DateTime myDate) { var comment = _autoMapper.Map <Comment>(model); comment.date = myDate; _commentsRepository.AddComment(comment); }
public void AddComment(CommentViewModel model) { var comment = _autoMapper.Map <Comment>(model); comment.SubmissionFK = comment.Submission.Id; comment.Submission = null; _comrepo.AddComment(comment); }
public void AddComment(CommentViewModel model, DateTime createdDate, string commenterEmail) { var comm = _autoMapper.Map <Comment>(model); comm.SubmissionId = comm.submission.id; comm.submission = null; comm.commentDate = createdDate; comm.commenterEmail = commenterEmail; _commentRepo.AddComment(comm); }
public async Task <IActionResult> AddComment([FromBody] CommentsDTO commentInfo) { bool added = await _commentsRepository.AddComment(commentInfo); if (!added) { return(BadRequest(new { message = "Failed to save comment" })); } return(Ok(new { message = "Comment saved" })); }
public async void AddComment_ShouldPass(string postText, string commentText) { var post = await _postrepository.AddPost(new Post { Text = postText }); var firstComments = post.Comments?.ToList(); await _commentsRepository.AddComment(new Comment { Post = post, Text = commentText }); var secondComments = post.Comments.First(); Assert.Null(firstComments); Assert.Equal(commentText, secondComments.Text); }
public PartialViewResult AddComment(int articleId, String sender, String body) { sender = sender?.Trim(); body = body?.Trim(); commentsRepository.AddComment(articleId, new Comment { Body = body, Sender = sender, CreationDate = DateTime.Now, }); return(GetComments(articleId)); }
public async Task <Comment> AddComment(Comment comment) { if (comment == null) { throw new ArgumentException(nameof(comment)); } if (comment.Post == null) { throw new ArgumentNullException(nameof(comment.Post), "Post cannot be null."); } if (string.IsNullOrWhiteSpace(comment.Text)) { throw new ArgumentNullException(nameof(comment.Text), "Text cannot be null."); } return(await _repository.AddComment(comment)); }
public JsonResult Add_Comment([Bind(Include = "Description,ItemID")] Comment comment) { comment.UserID = User.Identity.GetUserId(); JsonResult result = new JsonResult { Data = "Invalid Model." }; if (ModelState.IsValid) { try { result = _commentsRepository.AddComment(comment); } catch (Exception ex) { result = new JsonResult { Data = "Error: " + ex.InnerException }; } } return(result); }
public async Task AddComment(Guid PostId, Guid AuthorId, Guid CommentId, string Text) { Comment comment = new Comment() { PostId = PostId, Author = new User() { Id = AuthorId }, CommentId = CommentId, Text = Text }; if (comment.IsValidData()) { await _commentsRepository.AddComment(comment); } else { throw new ArgumentException("Invalid arguments"); } }
public async Task <IActionResult> AddComment([FromBody] CommentDto comment) { try { Comment entity = Mapper.Map <Comment>(comment); DateTime now = DateTime.UtcNow; entity.CreatedDateTime = now; entity.ModifiedDateTime = now; entity.Approved = true; await _commentsRepository.AddComment(entity); await _commentsRepository.SaveChanges(); } catch (Exception e) { return(BadRequest(e.Message)); } return(Ok()); }
public void AddComment(CommentViewModel comment) { _commentsRepo.AddComment(_mapper.Map <Comment>(comment)); }
public async Task <IActionResult> Add([FromBody] CommentsVM cmt) { return(Ok(await _commentRepository.AddComment(cmt))); }
public void AddComment(Koment k) { repository.AddComment(k); }
public void AddComment(CommentViewModel model) { _commentsRepo.AddComment(_autoMapper.Map <Comment>(model)); }