Esempio n. 1
0
        public async Task <List <Unit> > GetUnitsForDepartmentAsync(int departmentId)
        {
            List <Unit> systemUnts = new List <Unit>();
            var         units      = (await _unitsRepository.GetAllUnitsByDepartmentIdAsync(departmentId)).ToList();

            int limit = (await _subscriptionsService.GetCurrentPlanForDepartmentAsync(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++)
            {
                units[i].Roles = await GetRolesForUnitAsync(units[i].UnitId);

                systemUnts.Add(units[i]);
            }

            return(systemUnts);
        }