1
0

Add button to add a new task to the to-do list.

This commit is contained in:
Kevin Matsubara 2025-03-26 18:25:54 +01:00
parent 1fbdcdcd7c
commit dde2d3c20d

View File

@ -2,7 +2,10 @@
<h3>To-do list</h3> <h3>To-do list</h3>
<p>List of tasks that must be done for server management.</p> <p>List of tasks that must be done for server management.</p>
<hr/>
<br/>
<button type="button" class="btn btn-primary" @onclick="AddTask">Add Task</button>
<br/>
@if (items != null && items.Count > 0) @if (items != null && items.Count > 0)
{ {
<ul> <ul>
@ -18,4 +21,9 @@
@code { @code {
private List<ToDoItem> items = ToDoItemsRepository.GetItems(); private List<ToDoItem> items = ToDoItemsRepository.GetItems();
private void AddTask()
{
ToDoItemsRepository.AddItem(new ToDoItem { Name = "New Task"} );
items = ToDoItemsRepository.GetItems();
}
} }