Ejemplo n.º 1
0
        public IActionResult RegPoz([FromQuery] int?regid)
        {
            if (regid == null)
            {
                return(NotFound());
            }

            var regpoz = new RegPozViewModel()
            {
                FormId = regid.Value
            };

            var data = _dapperService.SelectList <EditableFeatureView, object>("[dbo].[EditableFeature_GetFeaturesByFormId]", new { formId = regid });

            if (data != null && data.Count() > 0)
            {
                //Selectin whole view from DB to able to extract classifier values as seperate lists for each feature
                regpoz.FeatureList = data.GroupBy(x => new { x.FormId, x.FeatureId, x.FeatureName, x.FeatureClassifierId })
                                     .Select(x => new FeatureViewModel
                {
                    FeatureId         = x.Key.FeatureId,
                    FeatureName       = x.Key.FeatureName,
                    FeatureValue      = x.Key.FeatureClassifierId,
                    FeatureClassifier = x.Select(y => new Classifier     // should be mai classifier, but don't work with Syncfusion Grid
                    {
                        ClassifierTypeId = y.ClassifierTypeId,
                        Id    = y.ClassifierId,
                        Value = y.ClassifierValue
                    })
                })
                                     .ToList();

                regpoz.DropDowns = _dapperService.SelectList <Classifier, object>("[dbo].[Classifier_GetAll]", null).Select(x => new DropDown {
                    Text = x.Value, FeatureValue = x.Id
                }).ToList();
            }

            return(View(regpoz));
        }