Example #1
0
        public async Task <int> DeleteAsync(UserCategory userCategory)
        {
            _context.Remove(userCategory);
            int removed = await _context.SaveChangesAsync();

            return(removed);
        }
Example #2
0
        public async Task <bool> DeletePostAsync(int id)
        {
            var entity = await _context.Posts.FindAsync(id);

            if (entity == null)
            {
                throw new Exception("Could not find post");
            }

            _context.Remove(entity);

            var success = await _context.SaveChangesAsync() > 0;

            if (success)
            {
                return(true);
            }

            throw new Exception("Problem saving changes");
        }
Example #3
0
 public async Task RemoveAsync(TEntity entity)
 {
     _context.Remove(entity);
     await _context.SaveChangesAsync();
 }
Example #4
0
 public async Task Delete(T entity)
 {
     using var context = new BlogAppContext();
     context.Remove(entity);
     await context.SaveChangesAsync();
 }