Ejemplo n.º 1
0
        public static List <TopicViewModel> GetTopicTree()
        {
            var context = new ApplicationDbContext();
            List <TopicViewModel> topics = new List <TopicViewModel>();
            Stack <Topic>         topicQ = new Stack <Topic>();
            var firstLevels = context.Topics.Where(x => x.Level == 0).ToList();

            foreach (Topic top in firstLevels)
            {
                topicQ.Push(top);
            }

            while (topicQ.Count > 0)
            {
                var current = topicQ.Pop();
                topics.Add(ModelConverter.TopicToView(current));
                foreach (var child in current.Childs)
                {
                    topicQ.Push(child);
                }
            }
            return(topics);
        }
Ejemplo n.º 2
0
        public static List <TopicViewModel> GetAllTopicView()
        {
            List <Topic> topics = DBHelper.GetAllTopics();

            return(topics.Select(x => ModelConverter.TopicToView(x)).ToList());
        }
Ejemplo n.º 3
0
        public static TopicViewModel GetTopicView(int id)
        {
            Topic top = DBHelper.GetTopic(id);

            return(ModelConverter.TopicToView(top));
        }