public bool Delete(int id)
        {
            var employee = GetById(id);

            if (employee is null)
            {
                return(false);
            }
            dB.Remove(employee);

            return(true);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }