private List <LabelValue> GetVariables(Guid subjectId)
        {
            var filters = _filterService.FindMany(filter => filter.SubjectId == subjectId)
                          .Select(filter =>
                                  new LabelValue(
                                      string.IsNullOrWhiteSpace(filter.Hint) ? filter.Label : $"{filter.Label} - {filter.Hint}",
                                      filter.Name))
                          .ToList();

            var indicators = _indicatorService.GetIndicators(subjectId)
                             .Select(indicator => new LabelValue(indicator.Label, indicator.Name));

            return(filters.Concat(indicators)
                   .OrderBy(labelValue => labelValue.Value)
                   .ToList());
        }
Exemplo n.º 2
0
        public ActionResult Add(IndicatorGroupAddModel addIndicatorGroup)
        {
            var IndicatorGroup = Mapper.Map <IndicatorGroupAddModel, IndicatorGroup>(addIndicatorGroup);

            if (addIndicatorGroup.IndicatorSelect != null)
            {
                IndicatorGroup.Indicators = _indicatorService.GetIndicators(i => addIndicatorGroup.IndicatorSelect.Contains(i.IndicatorID)).ToList();
            }
            if (ModelState.IsValid)
            {
                _indicatorGroupService.CreateIndicatorGroup(IndicatorGroup);
                this.AddStatus(StatusType.SUCCESS, "Успешно добавлен!");
                return(RedirectToAction("Index"));
            }
            return(null);
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            var indicatorViewModel = new IndicatorViewModel();
            var indicators         = _indicatorService.GetIndicators();
            var indicatorsDetails  = Mapper.Map <IEnumerable <Indicator>, IEnumerable <IndicatorFormModel> >(indicators);
            var calculationTypes   = _calculationTypeService.GetCalculationsTypeWithIndicator();

            foreach (var indicator in indicatorsDetails)
            {
                indicator.CalculationTypes = calculationTypes.Where(ct => ct.Indicator != null &&
                                                                    ct.Indicator.IndicatorID == indicator.IndicatorID)
                                             .Select(ct => new SelectListItem
                {
                    Value    = ct.CalculationTypeID.ToString(),
                    Text     = ct.UnitName,
                    Selected = ct.Indicator == null ? false : ct.Indicator.IndicatorID == indicator.IndicatorID
                });
            }
            indicatorViewModel.Indicators            = indicatorsDetails;
            indicatorViewModel.CalculationTypeSelect = Mapper.Map <IEnumerable <CalculationType>, IEnumerable <CalculationTypeSelect> >
                                                           (calculationTypes.Where(ct => ct.Indicator == null)).ToList();
            return(View(indicatorViewModel));
        }
        private IEnumerable <IndicatorMetaViewModel> GetIndicators(SubjectMetaQueryContext query)
        {
            var indicators = _indicatorService.GetIndicators(query.SubjectId, query.Indicators);

            return(BuildIndicatorViewModels(indicators));
        }