public async Task <IActionResult> Create([Bind("ID,Name,IsDone,ToDoList")] ToDoItem toDo) { HomeController hc = new HomeController(); ListsViewModel lvm = ListsViewModel.GetLists(toDo.ID, await hc.APIListGet()); ToDoList getList = lvm.ToDoLists.FirstOrDefault(i => i.Name == toDo.ToDoList); toDo.ListID = getList.ID; if (ModelState.IsValid) { await APITaskPost(toDo); return(RedirectToAction("Index")); } return(View(lvm)); }
public async Task <IActionResult> Update(int id, [Bind("ID,Name,IsDone,ToDoList")] ToDoItem toDo) { HomeController hc = new HomeController(); ListsViewModel lvm = ListsViewModel.GetLists(id, await hc.APIListGet()); ToDoList getList = lvm.ToDoLists.FirstOrDefault(i => i.Name == toDo.ToDoList); toDo.ListID = getList.ID; if (ModelState.IsValid) { toDo.ID = id; await APITaskPut(toDo.ID, toDo); return(RedirectToAction("Index", "ToDo")); } return(View(TaskViewModel.GetDetails(id, await hc.APIListGet(), await APItodoGetOne(id)))); }
public async Task <IActionResult> Create() { HomeController hc = new HomeController(); return(View(ListsViewModel.GetLists(0, await hc.APIListGet()))); }