Beispiel #1
0
 public async Task CreateAsync(T model, bool saved = true)
 {
     _db.Set <T>().Add(model);
     if (saved)
     {
         await _db.SaveChangesAsync();
     }
 }
Beispiel #2
0
        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)));
        }