Пример #1
0
        /// <summary>
        /// Determines if a user is valid within the limits of the current departments plan and that
        /// standard conditions are met (i.e. the user is not disabled)
        /// </summary>
        /// <param name="userId">UserId to check</param>
        /// <returns>True if the user is in a valid state, otherwise false</returns>
        public bool IsUserValidWithinLimits(string userId, int departmentId)
        {
            if (_departmentsService.IsUserDisabled(userId, departmentId))
            {
                return(false);
            }

            var department = _departmentsService.GetDepartmentById(departmentId);

            if (department == null)
            {
                return(false);
            }

            var users = _departmentsService.GetAllUsersForDepartmentUnlimitedMinusDisabled(department.DepartmentId);

            // This was .All and was failing with an array of 1, but seemed to work other times.
            if (!users.Any(x => x.Id == userId))
            {
                return(false);
            }

            return(true);
        }