public async Task <long> AddAsync(CommentsModel obj) { Comments comment = new Comments() { userId = obj.userId, blogId = obj.blogId, commentContent = obj.commentContent }; return(await _repository.AddAsync(comment)); }
public async Task AddAsync(Comment comment) { Validator.Validate(comment); var postAlreadyAdded = await postRepository.GetAsync(comment.PostId); if (postAlreadyAdded == null) { throw new Exception("post not found for adding comment"); } var commentAlreadyAdded = await GetAsync(comment.Id); if (commentAlreadyAdded != null) { throw new Exception("already added"); } await repository.AddAsync(comment); }