private async Task<Dictionary<int, string>> GetNameOfCustomAttributeRulesByTheirIds(
      IEnumerable<CustomAttributeValue> values)
    {
      var ids = values.Select(elem => elem.CustomAttributeRuleId).ToHashSet();
      var dict = new Dictionary<int, string>();

      foreach (var id in ids)
      {
        var rule = await _customAttributeRuleService.Get(id);
        dict.Add(id, rule.Name);
      }

      return dict;
    }
        public async Task <ActionResult <CustomAttributeRuleViewModel> > Get(int id)
        {
            try
            {
                var result = await _service.Get(id);

                return(Ok(await _presenter.Present(result)));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(NotFound());
            }
            catch (Exception)
            {
                return(BadRequest($"Couldn't fetch custom attribute rule with id {id}"));
            }
        }
        public async Task <ParsingRules> Request(ParsingRulesViewModel viewModel)
        {
            var customAttributeRules = new HashSet <GeneralRule>();

            foreach (var viewModelCustomAttributeRuleId in viewModel.CustomAttributeRuleIds)
            {
                var customAttributeRule = await _customAttributeRuleService.Get(viewModelCustomAttributeRuleId);

                customAttributeRules.Add(customAttributeRule);
            }

            var component = await _componentService.Get(viewModel.ComponentId);

            var components = new List <Component>();

            components.Add(component);
            return(new ParsingRules
            {
                Id = viewModel.Id, DateTimeRuleId = viewModel.DateTimeRuleId, MessageRuleId = viewModel.MessageRuleId,
                SeverityRuleId = viewModel.SeverityRuleId, CustomAttributeRules = customAttributeRules, Components = components
            });
        }