Exemplo n.º 1
0
        public List <DepartmentGroup> GetAllGroupsForDepartment(int departmentId)
        {
            List <DepartmentGroup> departmentGroups = new List <DepartmentGroup>();

            var groups = GetAllGroupsForDepartmentUnlimited(departmentId);

            int limit = 0;

            if (Config.SystemBehaviorConfig.RedirectHomeToLogin)
            {
                limit = int.MaxValue;
            }
            else
            {
                limit = _subscriptionsService.GetCurrentPlanForDepartment(departmentId).GetLimitForTypeAsInt(PlanLimitTypes.Groups);
            }

            int count = groups.Count < limit ? groups.Count : limit;

            // Only return users up to the plans group limit
            for (int i = 0; i < count; i++)
            {
                departmentGroups.Add(groups[i]);
            }

            // Remove all Disabled or Hidden Users
            //foreach (var dg in departmentGroups)
            //{
            //	 dg.Members = (from m in dg.Members
            //				  where !_departmentsService.IsUserDisabled(m.UserId) && !_departmentsService.IsUserHidden(m.UserId)
            //				  select m).ToList();
            //}

            return(departmentGroups);
        }
Exemplo n.º 2
0
        public List <Unit> GetUnitsForDepartment(int departmentId)
        {
            List <Unit> systemUnts = new List <Unit>();
            var         units      = (from unit in _unitsRepository.GetAll()
                                      where unit.DepartmentId == departmentId
                                      select unit).ToList();

            int limit = _subscriptionsService.GetCurrentPlanForDepartment(departmentId).GetLimitForTypeAsInt(PlanLimitTypes.Units);
            int count = units.Count < limit ? units.Count : limit;

            // Only return units up to the plans unit limit
            for (int i = 0; i < count; i++)
            {
                systemUnts.Add(units[i]);
            }

            return(systemUnts);
        }