Пример #1
0
        public void Update(Task task)
        {
            DbEntityEntry entry = _context.Entry(task);

            if (entry.State == EntityState.Detached)
            {
                _dbSet.Attach(task);
            }
            entry.State = EntityState.Modified;
            _context.SaveChanges();
        }
Пример #2
0
        public void Add(Task task)
        {
            DbEntityEntry entry = _context.Entry(task);

            if (entry.State != EntityState.Detached)
            {
                entry.State = EntityState.Added;
            }
            else
            {
                _dbSet.Add(task);
                _context.SaveChanges();
            }
        }
Пример #3
0
        public void Delete(Task task)
        {
            DbEntityEntry entry = _context.Entry(task);

            if (entry.State != EntityState.Deleted)
            {
                entry.State = EntityState.Deleted;
            }
            else
            {
                _dbSet.Attach(task);
                _dbSet.Remove(task);
                _context.SaveChanges();
            }
        }
Пример #4
0
 public void Delete(Task task)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 public void Add(Task task)
 {
     Context.Add(task);
 }