Esempio n. 1
0
        public async Task ShouldUpdateTodoItem()
        {
            var userId = await RunAsDefaultUserAsync();

            var listId = await SendAsync(new CreateMovieCommand
            {
                Title = "New List"
            });

            var itemId = await SendAsync(new CreateRatingCommand
            {
                ListId = listId,
                Title  = "New Item"
            });

            var command = new UpdateRatingCommand
            {
                Id    = itemId,
                Title = "Updated Item Title"
            };

            await SendAsync(command);

            var item = await FindAsync <TodoItem>(itemId);

            item.Title.Should().Be(command.Title);
            item.LastModifiedBy.Should().NotBeNull();
            item.LastModifiedBy.Should().Be(userId);
            item.LastModified.Should().NotBeNull();
            item.LastModified.Should().BeCloseTo(DateTime.Now, 1000);
        }
Esempio n. 2
0
        public async Task <ActionResult> Update(int id, UpdateRatingCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(NoContent());
        }
Esempio n. 3
0
        public void ShouldRequireValidTodoItemId()
        {
            var command = new UpdateRatingCommand
            {
                Id    = 99,
                Title = "New Title"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Esempio n. 4
0
        public async Task <IActionResult> Update(
            [FromRoute] int ratingId,
            [FromBody] UpdateRatingRequest request)
        {
            var command = new UpdateRatingCommand
            {
                Id     = ratingId,
                UserId = HttpContext.GetUserId()
            };

            mapper.Map(request, command);
            var result = await mediator.Send(command).ConfigureAwait(false);

            return(Ok(new Response <RatingResponse>(result)));
        }
Esempio n. 5
0
 public async Task <IActionResult> UpdateRating([FromBody] UpdateRatingCommand command)
 => Ok(await _mediator.Send(command));