Пример #1
0
        public async Task <bool> AddAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }
            try
            {
                await _context.AddAsync(entity);

                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}");
            }
        }
 public async Task <int> CompleteAsync()
 {
     return(await _efDemoContext.SaveChangesAsync());
 }
Пример #3
0
 public Task <int> SaveAsync()
 {
     return(_context.SaveChangesAsync());
 }