Skip to content

Commit

Permalink
Clear console after completing an item
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetseckin committed Nov 15, 2019
1 parent b532e3e commit 0ec91f0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Todo.CLI/Handlers/CompleteCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static ICommandHandler Create(IServiceProvider serviceProvider)
var todoItemRepository = (ITodoItemRepository)serviceProvider.GetService(typeof(ITodoItemRepository));
if (!string.IsNullOrEmpty(itemId))
{
await todoItemRepository.CompleteAsync(new TodoItem() { Id = itemId });
await CompleteItem(todoItemRepository, new TodoItem { Id = itemId });
}
else
{
Expand All @@ -30,10 +30,15 @@ public static ICommandHandler Create(IServiceProvider serviceProvider)
var selectedItem = Question
.List("Which item would you like to complete?", items)
.Prompt();
await todoItemRepository.CompleteAsync(selectedItem);
await CompleteItem(todoItemRepository, selectedItem);
}
});
}

private static async Task CompleteItem(ITodoItemRepository todoItemRepository, TodoItem selectedItem)
{
await todoItemRepository.CompleteAsync(selectedItem);
Console.Clear();
}
}
}

0 comments on commit 0ec91f0

Please sign in to comment.