Esempio n. 1
0
        public void Create(
            Employee employee,
            int departmentId,
            int positionId)
        {
            if (employee == null)
            {
                throw new ArgumentNullException(nameof(employee));
            }
            var foundDepartment = _departmentRepo.GetById(departmentId);

            if (foundDepartment == null)
            {
                throw new ArgumentNullException(nameof(foundDepartment));
            }
            employee.Department = foundDepartment;

            var foundPosition = _positionRepo.GetById(positionId);

            if (foundPosition == null)
            {
                throw new ArgumentNullException(nameof(foundPosition));
            }
            employee.Position = foundPosition;

            _repository.Add(employee);
        }
Esempio n. 2
0
        public void Update(
            int id,
            PositionRequest position)
        {
            if (position == null)
            {
                throw new ArgumentNullException(nameof(position));
            }
            var foundposition = _repository.GetById(id);

            if (foundposition == null)
            {
                throw new ArgumentNullException(nameof(foundposition));
            }

            foundposition.ShortName = position.ShortName;
            foundposition.LongName  = position.LongName;
            _repository.Update(foundposition);
        }