Exemplo n.º 1
0
        public async Task <ActionResult <string> > Post([FromBody] InputComment value)
        {
            Document document = await _documentClient.CreateDocumentAsync(
                UriFactory.CreateDocumentCollectionUri(_dbName, _collectionName),
                value);

            return(Ok(document.Id));
        }
Exemplo n.º 2
0
        public Task SaveCommentAsync(int blogPostId, InputComment comment)
        {
            var storedComment = new StoredComment()
            {
                Name         = comment.Name,
                EmailAddress = comment.EmailAddress,
                Body         = comment.Body,
                Timestamp    = this.time.UtcNow
            };

            return(this.repo.SaveCommentAsync(blogPostId, storedComment));
        }
        protected override void Execute(NativeActivityContext context)
        {
            var taskCanceledWithComment = new TaskCanceledWithCommentEntry()
            {
                Id          = Guid.NewGuid(),
                Caption     = Caption.Get(context),
                QueueName   = QueueName.Get(context),
                TextComment = InputComment.Get(context),
            };

            var db = context.GetExtension <Db>();

            db.TaskCanceledWithComment.Add(taskCanceledWithComment);

            TaskCanceledId.Set(context, taskCanceledWithComment.Id);
        }
Exemplo n.º 4
0
        public async Task SaveCommentTest()
        {
            // arrange

            const int blogPostId = 1;

            var fixedDateTime   = new DateTime(2018, 4, 29, 18, 28, 33, DateTimeKind.Utc);
            var mockRepo        = new Mock <ICommentRepository>(MockBehavior.Strict);
            var mockTimeService = new Mock <ITimeService>(MockBehavior.Strict);

            mockRepo.Setup(x => x.SaveCommentAsync(blogPostId, It.IsAny <StoredComment>()))
            .Returns(Task.CompletedTask);
            mockTimeService.Setup(x => x.UtcNow)
            .Returns(fixedDateTime);

            var grain = new BlogPostGrain(mockRepo.Object, mockTimeService.Object);

            const string name         = "George";
            const string emailAddress = "*****@*****.**";
            const string body         = "I'm hungry!";

            var comment = new InputComment()
            {
                Name         = name,
                EmailAddress = emailAddress,
                Body         = body
            };

            // act

            await grain.SaveCommentAsync(blogPostId, comment);

            // assert

            mockRepo.Verify(x => x.SaveCommentAsync(blogPostId, It.Is <StoredComment>(
                                                        c => c.Name == name &&
                                                        c.EmailAddress == emailAddress &&
                                                        c.Body == body &&
                                                        c.Timestamp == fixedDateTime
                                                        )));
        }
 public async Task Put(int blogPostId, InputComment comment)
 {
     var grain = this.orleansClient.GetGrain <IBlogPostGrain>(blogPostId);
     await grain.SaveCommentAsync(blogPostId, comment);
 }