Пример #1
0
        public List <Node> Fill(IList <WorkoutPlanDTO> plans)
        {
            Dictionary <TrainingType, Node> mainNodes = new Dictionary <TrainingType, Node>();

            foreach (TrainingType diff in Enum.GetValues(typeof(TrainingType)))
            {
                Node item = new Node(diff.ToString());
                mainNodes.Add(diff, item);
            }

            foreach (WorkoutPlanDTO planDto in plans)
            {
                var item = TrainingPlansTree.CreateNode(planDto);
                mainNodes[planDto.TrainingType].Nodes.Add(item);
            }
            return(mainNodes.Values.ToList());
        }
Пример #2
0
        public List <Node> Fill(IList <WorkoutPlanDTO> plans)
        {
            Dictionary <string, Node> mainNodes = new Dictionary <string, Node>();


            foreach (WorkoutPlanDTO planDto in plans)
            {
                Node mainNode = null;
                if (!mainNodes.ContainsKey(planDto.Author))
                {
                    mainNode = new Node(planDto.Author);
                    mainNodes.Add(planDto.Author, mainNode);
                }
                else
                {
                    mainNode = mainNodes[planDto.Author];
                }
                var item = TrainingPlansTree.CreateNode(planDto);
                mainNode.Nodes.Add(item);
            }
            return(mainNodes.Values.ToList());
        }