public async Task WhenCreate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var supplier = await _create.Supplier
                           .BuildAsync();

            var comment = new SupplierComment
            {
                Id         = Guid.NewGuid(),
                SupplierId = supplier.Id,
                Value      = "Test".WithGuid()
            };

            await _supplierCommentsClient.CreateAsync(comment, headers);

            var request = new SupplierCommentGetPagedListRequest
            {
                SupplierId = supplier.Id
            };

            var createdComment = (await _supplierCommentsClient.GetPagedListAsync(request, headers)).Comments.First();

            Assert.NotNull(createdComment);
            Assert.Equal(comment.SupplierId, createdComment.SupplierId);
            Assert.True(!createdComment.CommentatorUserId.IsEmpty());
            Assert.Equal(comment.Value, createdComment.Value);
            Assert.True(createdComment.CreateDateTime.IsMoreThanMinValue());
        }
 public Task CreateAsync(
     SupplierComment comment,
     Dictionary <string, string> headers = default,
     CancellationToken ct = default)
 {
     return(_factory.PostAsync(_host + "/Suppliers/Comments/v1/Create", null, comment, headers, ct));
 }
        public async Task <ActionResult> Create(SupplierComment comment, CancellationToken ct = default)
        {
            var supplier = await _suppliersService.GetAsync(comment.SupplierId, false, ct);

            return(await ActionIfAllowed(
                       () => _supplierCommentsService.CreateAsync(_userContext.UserId, comment, ct),
                       Roles.Suppliers,
                       supplier.AccountId));
        }
 public SupplierCommentBuilder(
     IDefaultRequestHeadersService defaultRequestHeadersService,
     ISupplierCommentsClient customerCommentsClient)
 {
     _customerCommentsClient       = customerCommentsClient;
     _defaultRequestHeadersService = defaultRequestHeadersService;
     _comment = new SupplierComment
     {
         Id    = Guid.NewGuid(),
         Value = "Test".WithGuid()
     };
 }
        public async Task CreateAsync(Guid userId, SupplierComment comment, CancellationToken ct)
        {
            var newComment = new SupplierComment
            {
                Id                = Guid.NewGuid(),
                SupplierId        = comment.SupplierId,
                CommentatorUserId = userId,
                Value             = comment.Value,
                CreateDateTime    = DateTime.UtcNow
            };

            await _storage.AddAsync(newComment, ct);

            await _storage.SaveChangesAsync(ct);
        }