public async Task CreateAsync(T model, bool saved = true) { _db.Set <T>().Add(model); if (saved) { await _db.SaveChangesAsync(); } }
public async Task <IActionResult> AddCategory(Category category) { if (category.CategoryID == 0) { await _content.AddAsync(category); } else { _content.Update(category); } await _content.SaveChangesAsync(); return(RedirectToAction(nameof(Category))); }