public bool Delete(int id) { var employee = GetById(id); if (employee is null) { return(false); } dB.Remove(employee); return(true); }
public bool Delete(int id) { var employee = _db.Employees.FirstOrDefault(e => e.Id == id); if (employee is null) { return(false); } _db.Remove(employee); return(true); }
public bool Delete(int id) { var employee = _db.Employees.FirstOrDefault(e => e.Id == id); if (employee is null) { return(false); } //_db.Employees.Remove(employee); //_db.Entry(employee).State = EntityState.Deleted; _db.Remove(employee); return(true); }
public bool Delete(int id) { var employee = _db.Employees .Select(e => new Employee { Id = e.Id }) .FirstOrDefault(e => e.Id == id); if (employee is null) { return(false); } _db.Remove(employee); _db.SaveChanges(); _Logger.LogInformation($"Сотрудник id:{id} удалён"); return(true); }