using Microsoft.AspNetCore.Mvc; using todoaspnet.Models; namespace todoaspnet.Controllers { public class ToDoController : Controller { public static List Todos=new List(); public IActionResult Index() { return View(Todos); } public IActionResult Create() { return View(); } [HttpPost] public IActionResult Create(TodoModel model) { if(ModelState.IsValid) { Todos.Add(model); return RedirectToAction("Index"); } return View(Todos); } public IActionResult Delete(int id) { var todo = Todos.Find(a => a.ToDoId== id); if (todo == null) { return NotFound(); } Todos.RemoveAll(a => a.ToDoId== id); return RedirectToAction("Index"); } } }