public virtual void Delete(T entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            dbSet.Remove(entity);
            context.SaveChanges();
        }
Exemple #2
0
        public override void Insert(Task entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            // Attach existing customer to context to prevent EF from trying to insert a new customer
            if (entity.Customer != null)
            {
                context.Attach(entity.Customer);
            }

            context.Tasks.Add(entity);
            context.SaveChanges();
        }