Exemple #1
0
        public void getComments()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                var cd = this.getGlobalObject <IContentDispatcher>();

                // create a version
                DMSVersion created = cc.getNewContent <DMSVersion>();
                created.title = "Pippo";
                cd.Add(created);

                // sign action
                var addCommentAction = new DMSAddCommentAction(created, null);
                var input            = new AddCommentInput();
                input.comment_text = "ciao";
                input.content      = created;

                addCommentAction.input = input;

                WebActionResult result = e.executeAction(addCommentAction);
                Assert.IsTrue(result.isSuccessfull);

                Assert.IsTrue(created.comments.Count() == 1);
            }
        }
        public async Task AddComment(AddCommentInput input)
        {
            AuthorizationService.CheckPermission("AddComment", input.IssueId);
            _validationService.Validate(input);

            var currentUser = await _userRepository.GetByIdAsync(SessionService.UserId);

            var issue = await _issueRepository.GetByIdAsync(input.IssueId);

            var comment = issue.AddComment(currentUser, input.Message);
            await _issueRepository.UpdateAsync(issue);

            _userEmailer.AddedIssueComment(currentUser, issue, comment);
        }
        public async Task <ResponseDto> AddCommentAsync(CommentDto comment)
        {
            var input = new AddCommentInput()
            {
                Comment = comment.Message, PhotoId = comment.PhotoId
            };
            var response = await _client.AddCommentAsync(input);

            return(new ResponseDto()
            {
                Message = response.Message,
                Status = response.Status,
            });
        }
Exemple #4
0
        public void AddComment(AddCommentInput input)
        {
            //TODO: Unit of work / transaction management

            AuthorizationService.CheckPermission("AddComment", input.IssueId);
            _validationService.Validate(input);

            var currentUser = _userRepository.Get(SessionService.UserId);
            var issue       = _issueRepository.Get(input.IssueId);

            var comment = issue.AddComment(currentUser, input.Message);

            _userEmailer.AddedIssueComment(currentUser, issue, comment);
        }
Exemple #5
0
        public void InputObject_Parameter_With_Null_Field()
        {
            var expected = "query{addComment(input:{subjectId:\"x\",body:null,clientMutationId:\"1\"}){body}}";

            var input = new AddCommentInput
            {
                Body             = null,
                ClientMutationId = "1",
                SubjectId        = new ID("x"),
            };

            var expression = new Query()
                             .AddComment(input)
                             .Select(x => x.Body);

            var query = expression.Compile();

            Assert.Equal(expected, query.ToString(0));
        }
Exemple #6
0
        public override Task <ResponseMessage> AddComment(AddCommentInput request, ServerCallContext context)
        {
            var comment = new Comment()
            {
                Message = request.Comment
            };
            var photo = new Photo
            {
                Id = request.PhotoId,
            };

            _commentsRepository.CommentPhoto(photo, comment);

            return(Task.FromResult(new ResponseMessage
            {
                Status = "Ok",
                Message = "Comentario agregado",
            }));
        }
Exemple #7
0
        /// <inheritdoc/>
        public async Task <CommentModel> PostComment(HostAddress address, string issueishId, string body)
        {
            var input = new AddCommentInput
            {
                Body      = body,
                SubjectId = new ID(issueishId),
            };

            if (postComment == null)
            {
                postComment = new Mutation()
                              .AddComment(Var(nameof(input)))
                              .CommentEdge
                              .Node
                              .Select(comment => new CommentModel
                {
                    Author = new ActorModel
                    {
                        Login     = comment.Author.Login,
                        AvatarUrl = comment.Author.AvatarUrl(null),
                    },
                    Body       = comment.Body,
                    CreatedAt  = comment.CreatedAt,
                    DatabaseId = comment.DatabaseId.Value,
                    Id         = comment.Id.Value,
                    Url        = comment.Url,
                }).Compile();
            }

            var vars = new Dictionary <string, object>
            {
                { nameof(input), input },
            };

            var graphql = await graphqlFactory.CreateConnection(address).ConfigureAwait(false);

            return(await graphql.Run(postComment, vars).ConfigureAwait(false));
        }
 public async Task <IActionResult> CreateComment([FromBody] AddCommentInput request)
 {
     return(await _dispatcher.DispatchAsync(request));
 }
Exemple #9
0
 public void Add(AddCommentInput input)
 {
     this.InsertFromDto(input);
 }