Ejemplo n.º 1
0
        /// <summary>
        /// Changes manager for the specified user
        /// </summary>
        /// <param name="newManagerId">ID of new user's manager</param>
        /// <param name="userId">ID of user that will have their manager changed</param>
        /// <returns>User with reassigned manager</returns>
        /// <exception cref="ValidationFailedException">When manager reassignment does not meet business requirements</exception>
        public User ChangeTeamMember(int newManagerId, int userId)
        {
            var validationInfo = userValidator.ValidataManagerReassignment(newManagerId, userId);

            if (!validationInfo.IsValid)
            {
                throw new ValidationFailedException(validationInfo);
            }

            var userForUpdate = usersDao.SelectByID(userId);

            userForUpdate.ManagerId = newManagerId;

            usersDao.UpdateUser(userForUpdate);

            return(userForUpdate);
        }