Exemplo n.º 1
0
        public IActionResult Eliminar(int id)
        {
            var productos = _context.Productos.FirstOrDefault(x => x.id == id);

            _context.Remove(productos);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public void DeleteAll()
        {
            var persons = _context.Persons.Where(p => true).ToList();

            foreach (var person in persons)
            {
                var entity = _context.Persons.Find(person.PersonId);
                _context.Remove(entity);
            }

            _context.SaveChanges();
        }
Exemplo n.º 3
0
        public async Task DeleteAllAsync()
        {
            var employees = await _context.Employees.Where(e => true).ToListAsync();

            List <Task <Employee> > tasks = new List <Task <Employee> >();

            foreach (var employee in employees)
            {
                tasks.Add(_context.Employees.FindAsync(employee.EmployeeId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task DeleteAllAsync()
        {
            var customers = await _context.Customers.Where(e => true).ToListAsync();

            List <Task <Customer> > tasks = new List <Task <Customer> >();

            foreach (var customer in customers)
            {
                tasks.Add(_context.Customers.FindAsync(customer.CustomerId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
Exemplo n.º 5
0
        public async Task DeleteAllAsync()
        {
            var Appointments = await _context.Appointments.Where(e => true).ToListAsync();

            List <Task <Appointment> > tasks = new List <Task <Appointment> >();

            foreach (var Appointment in Appointments)
            {
                tasks.Add(_context.Appointments.FindAsync(Appointment.AppointmentId));
            }
            var entities = await Task.WhenAll(tasks);

            foreach (var entity in entities)
            {
                _context.Remove(entity);
            }

            await _context.SaveChangesAsync();
        }
Exemplo n.º 6
0
 public EntityEntry <TEntity> Remove <TEntity>(TEntity entity) where TEntity : class, IBaseEntity
 {
     return(_context.Remove(entity));
 }
Exemplo n.º 7
0
 public void Delete(Student student)
 {
     _context.Remove(student);
 }