public StandardVocabOutput ListFlat()
        {
            var result = new StandardVocabOutput();
            var hazards = _context.Hazards
                .Include(x => x.Parent)
                .OrderBy(x => x.Value);

            foreach(var haz in hazards)
            {
                var stdVocabItem = new StandardVocabItem();
                stdVocabItem.Id = haz.Id.ToString();
                stdVocabItem.Value = haz.Value;

                if (haz.Parent != null)
                {
                    stdVocabItem.AdditionalData.Add(new KeyValuePair<string, string>("ParentId", haz.Parent.Id.ToString()));
                }

                result.Items.Add(stdVocabItem);
            }

            return result;
        }
示例#2
0
        public StandardVocabOutput ListFlat()
        {
            var result  = new StandardVocabOutput();
            var sectors = _context.Sectors
                          .Include(x => x.Parent)
                          .OrderBy(x => x.Value);

            foreach (var sec in sectors)
            {
                var stdVocabItem = new StandardVocabItem();
                stdVocabItem.Id    = sec.Id.ToString();
                stdVocabItem.Value = sec.Value;

                if (sec.Parent != null)
                {
                    stdVocabItem.AdditionalData.Add(new KeyValuePair <string, string>("ParentId", sec.Parent.Id.ToString()));
                }

                result.Items.Add(stdVocabItem);
            }

            return(result);
        }