public IActionResult CreateCategoryAjax(Category category) { if (category.Name != null) { _db.Categories.Add(category); _db.SaveChanges(); } SourceCategoryViewModel model = new SourceCategoryViewModel() { Source = new Source(), Categories = _db.Categories.Where(c => c.Active).ToList() }; return(PartialView("PartialViews/CategoriesPartial", model)); }
public IActionResult DeleteCategoryAjax(int id) { Category category = _db.Categories.FirstOrDefault(c => c.Id == id); if (category != null) { category.Active = false; _db.SaveChanges(); } SourceCategoryViewModel model = new SourceCategoryViewModel() { Source = new Source(), Categories = _db.Categories.Where(c => c.Active).ToList() }; return(PartialView("PartialViews/CategoriesPartial", model)); }