private static void TodoEventHandler(object sender, EventArgs e) { if (e.GetType() == typeof(TodoItemCreatedArgs)) { var args = e as TodoItemCreatedArgs; if (args != null) { _todoService.CreateTodo(new TodoItem(args.Id, args.Title, args.IsCompleted)); } } else if (e.GetType() == typeof(TodoItemCompletedArgs)) { var args = e as TodoItemCompletedArgs; _todoService.CompleteTodo(args.Id); } else if (e.GetType() == typeof(TodoItemDeletedArgs)) { var args = e as TodoItemDeletedArgs; _todoService.DeleteTodo(args.Id); } else { _logger.LogInformation("Todo EventHandler called"); } }
public async Task <IActionResult> Complete(int id, string username) { await todoService.CompleteTodo(id); return(RedirectToAction(nameof(TodoController.Todo), "Todo", new { username })); }