public IActionResult Eliminar(int id) { var productos = _context.Productos.FirstOrDefault(x => x.id == id); _context.Remove(productos); _context.SaveChanges(); return(RedirectToAction("Index")); }
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(); }
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(); }
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(); }
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(); }
public EntityEntry <TEntity> Remove <TEntity>(TEntity entity) where TEntity : class, IBaseEntity { return(_context.Remove(entity)); }
public void Delete(Student student) { _context.Remove(student); }