public async Task ShouldUpdateTodoItem()
        {
            var userId = await RunAsDefaultUserAsync();

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

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

            var command = new UpdateTodoItemDetailCommand
            {
                Id       = itemId,
                ListId   = listId,
                Note     = "This is the note.",
                Priority = PriorityLevel.High
            };

            await SendAsync(command);

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

            item.ListId.Should().Be(command.ListId);
            item.Note.Should().Be(command.Note);
            item.Priority.Should().Be(command.Priority);
            item.LastModifiedBy.Should().NotBeNull();
            item.LastModifiedBy.Should().Be(userId);
            item.LastModified.Should().NotBeNull();
            item.LastModified.Should().BeCloseTo(DateTime.Now, 10000);
        }
        public async Task ShouldUpdateTodoItemDetail()
        {
            var categoryId = await SendAsync(new CreateTodoCategoryCommand
            {
                CategoryTitle = "Belajar"
            });

            var itemId = await SendAsync(new CreateTodoItemCommand
            {
                CategoryId    = categoryId,
                ActivityTitle = "Belajar Sejarah"
            });

            var command = new UpdateTodoItemDetailCommand()
            {
                Id         = itemId,
                CategoryId = categoryId,
                Note       = "Ini note ubah detail ya",
                Priority   = PriorityLevel.Medium
            };

            await SendAsync(command);

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

            item.Should().NotBeNull();
            item.CategoryId.Should().Be(command.CategoryId);
            item.Note.Should().Be(command.Note);
            item.Priority.Should().Be(command.Priority);
        }
        public void ShouldBeRealId()
        {
            var command = new UpdateTodoItemDetailCommand {
                Id = 99
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
        public async Task <ActionResult> UpdateItemDetails(int id, UpdateTodoItemDetailCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }
            await Mediator.Send(command);

            return(NoContent());
        }
 public Task UpdateTodoItemDetails(UpdateTodoItemDetailCommand command) =>
 this.PutJson("api/TodoItems/UpdateItemDetails", command);
예제 #6
0
        public async Task <ActionResult> UpdateItemDetails(UpdateTodoItemDetailCommand command)
        {
            await Mediator.Send(command);

            return(NoContent());
        }