コード例 #1
0
ファイル: RuleTypesController.cs プロジェクト: Morebis-GIT/CI
        /// <summary>
        /// Updates autopilot rules according to the rules repository changes
        /// </summary>
        /// <param name="ruleTypeId"></param>
        /// <param name="newRules"></param>
        /// <param name="deletedRules"></param>
        private void UpdateAutopilotRulesRepository(int ruleTypeId, IReadOnlyCollection <int> newRules, IReadOnlyCollection <int> deletedRules)
        {
            var flexibilityLevels = _flexibilityLevelRepository.GetAll().ToList();

            // delete autopilot rules
            if (deletedRules != null && deletedRules.Any())
            {
                var autopilotRulesToDelete = _autopilotRuleRepository.GetAll()
                                             .Where(rt => rt.RuleTypeId == ruleTypeId && deletedRules.Contains(rt.RuleId)).ToList();

                if (autopilotRulesToDelete.Any())
                {
                    _autopilotRuleRepository.Delete(autopilotRulesToDelete.Select(r => r.Id));
                }
            }

            // add new autopilot rules
            if (newRules != null && newRules.Any())
            {
                foreach (var ruleId in newRules)
                {
                    foreach (var flexibilityLevel in flexibilityLevels)
                    {
                        var autopilotRule = AutopilotRule.Create(flexibilityLevel.Id, ruleId, ruleTypeId);
                        _autopilotRuleRepository.Add(autopilotRule);
                    }
                }
            }

            _autopilotRuleRepository.SaveChanges();
        }
コード例 #2
0
 public IEnumerable <FlexibilityLevelModel> GetAll()
 {
     return(_mapper.Map <List <FlexibilityLevelModel> >(_flexibilityLevelRepository.GetAll().OrderBy(x => x.SortIndex)));
 }
コード例 #3
0
 public IEnumerable <FlexibilityLevel> GetAll() => _repository.GetAll();