Пример #1
0
        public async Task <TodoEntity> UpdateAsync(TodoEntity entity)
        {
            EntityEntry <TodoEntity> updated = _dbSet.Update(entity);
            await _dbContext.SaveChangesAsync();

            return(updated.Entity);
        }
Пример #2
0
        public async Task <TodoEntity> AddAsync(TodoEntity entity)
        {
            EntityEntry <TodoEntity> added = await _dbSet.AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(added.Entity);
        }
Пример #3
0
        public async Task <TodoEntity> RemoveAsync(long id)
        {
            TodoEntity user = await GetByIdAsync(id);

            if (user == null)
            {
                throw new ArgumentNullException(nameof(id), "User not found.");
            }

            _dbSet.Remove(user);
            await _dbContext.SaveChangesAsync();

            return(user);
        }