Пример #1
0
        /// <summary>
        /// Changes restrictions for every member in team (excluding manager)
        /// </summary>
        /// <param name="userRestrictions">New user restrictions</param>
        /// <param name="managerId">ID of manager whose team will have restrictions changed</param>
        /// <exception cref="EntityNotFoundException">When user with <paramref name="managerId"/> ID is not found</exception>
        public void ChangeTeamRestrictions(UserRestrictions userRestrictions, int managerId)
        {
            User teamManager = usersDao.SelectByID(managerId);

            if (teamManager == null)
            {
                throw new EntityNotFoundException($"User with ID {managerId} was not found", typeof(User));
            }

            usersDao.UpdateTeamRestrictions(userRestrictions, managerId);
        }
Пример #2
0
        /// <summary>
        /// Calls data access to update user's restrictions
        /// </summary>
        /// <param name="userRestrictions">Modified user restrictions</param>
        /// <param name="userId">ID to lookup a user and modify</param>
        /// <returns>User instance with updated restrictions</returns>
        /// <exception cref="EntityNotFoundException">When user with ID <paramref name="userId"/> is not found</exception>
        public User ChangeRestrictions(UserRestrictions userRestrictions, int userId)
        {
            User userToUpdate = usersDao.SelectByID(userId);

            if (userToUpdate == null)
            {
                throw new EntityNotFoundException($"User with ID {userId} was not found", typeof(User));
            }

            userToUpdate.ConsecLimit  = userRestrictions.ConsecLimit;
            userToUpdate.MonthlyLimit = userRestrictions.MonthlyLimit;
            userToUpdate.YearlyLimit  = userRestrictions.YearlyLimit;
            userToUpdate.QuarterLimit = userRestrictions.QuarterLimit;

            usersDao.UpdateUser(userToUpdate);
            return(userToUpdate);
        }