public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] CategoryViewModel category) { if (id != category.ID) { return(NotFound()); } if (ModelState.IsValid) { try { var categoryVo = mapper.Map <CategoryVo>(category); await provider.Edit(categoryVo); } catch (DbUpdateConcurrencyException) { if (!provider.Exists(category.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,DeadLineDate,CreationDate,Priority,Status,CategoryID")] TodoItemViewModel todoItem) { if (id != todoItem.ID) { return(NotFound()); } if (ModelState.IsValid) { try { var todoItemVo = mapper.Map <TodoItemVo>(todoItem); await provider.Edit(todoItemVo); } catch (DbUpdateConcurrencyException) { if (!provider.Exists(todoItem.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(categoryProvider.GetEnum(), "ID", "Name", todoItem.CategoryID); return(View(todoItem)); }