public void Edit(CategoryEditServiceModel model) { var category = this.data .Categories .FirstOrDefault(c => c.Id == model.Id); category.Name = model.Name; category.Description = model.Description; this.data.Categories.Update(category); this.data.SaveChanges(); }
public IActionResult Edit(EditCategoryViewModel model) { if (!this.ModelState.IsValid) { return(RedirectToAction("Error", "Home")); } var serviceModel = new CategoryEditServiceModel { Name = model.Name, Description = model.Description }; this.categoryService.Edit(serviceModel); return(this.RedirectToAction("All", "Categories")); }