Пример #1
0
 public async Task UpdateAsync(TEntityDTO entity)
 {
     using (var _dbContext = new FondoContext(_contextOptions))
     {
         _dbContext.Set <TEntity>().Update(_mapper.Map <TEntityDTO, TEntity>(entity));
         await _dbContext.SaveChangesAsync();
     }
 }
Пример #2
0
        public async Task DeleteAsync(int id)
        {
            using (var _dbContext = new FondoContext(_contextOptions))
            {
                var entity = await GetByIdAsync(id);

                if (null == entity)
                {
                    throw new Exception("Element not found, can't delete");
                }
                _dbContext.Set <TEntity>().Remove(_mapper.Map <TEntityDTO, TEntity>(entity));
                await _dbContext.SaveChangesAsync();
            }
        }