public async Task <ActionResult> Edit(int id) { var currentCateogry = await _categoryRepository.GetByIdAsync(id); var viewModel = new UpdateCategoryViewMode { CategoryId = id, Name = currentCateogry.Name, Description = currentCateogry.Description }; return(View(viewModel)); }
public async Task <ActionResult> Edit(UpdateCategoryViewMode category) { if (ModelState.IsValid) { var currentCategory = await _categoryRepository.GetByIdAsync(category.CategoryId); currentCategory.Name = category.Name; currentCategory.Description = category.Description; await _categoryRepository.Update(currentCategory); return(RedirectToAction("Index")); } return(RedirectToAction("Edit", "Category", new{ Id = category.CategoryId })); }