示例#1
0
        private void GetChildDocs(List <Doc> allDocs, List <DocReview> allReviews, GetSkillupsData data, int docId)
        {
            var childDocs = allDocs.Where(d => d.ParentDocID == docId).ToList();

            data.SkillupDocs.AddRange(childDocs);

            foreach (var child in childDocs)
            {
                data.SkillupDocReviews.AddRange(allReviews.Where(r => r.DocID == child.DocID));
                GetChildDocs(allDocs, allReviews, data, child.DocID);
            }
        }
示例#2
0
        public Result GetSkillupsSummary(int tagId)
        {
            var result      = new Result();
            var getSkillups = new GetSkillupsData();

            try
            {
                using (var dblocal = new LiteDatabase(dbPath))
                {
                    //get docs, tags and reviews
                    var docsTable        = dblocal.GetCollection <Doc>("Docs").FindAll().ToList();
                    var docsTagsTable    = dblocal.GetCollection <DocsTag>("DocsTags").FindAll().ToList();
                    var docsReviewsTable = dblocal.GetCollection <DocReview>("DocReviews").FindAll().ToList();

                    getSkillups.SkillupDocs = (from docsList in docsTable
                                               join tagsList in docsTagsTable
                                               on docsList.DocID equals tagsList.DocID
                                               where tagsList.TagID == tagId
                                               select docsList).ToList();

                    getSkillups.SkillupDocReviews = (from docList in getSkillups.SkillupDocs
                                                     join reviewList in docsReviewsTable
                                                     on docList.DocID equals reviewList.DocID
                                                     select reviewList).ToList();

                    result.Data    = getSkillups;
                    result.Success = true;

                    ////Get CSS skill doctag (css skill parent doc id)
                    //var skillDocs = docsTagsTable.ToList().Where(dt => dt.TagID == tagId);
                    //if (skillDocs.Count() > 0)
                    //{
                    //    var skillDoc = skillDocs.First();

                    //    //Get data from children
                    //    var childDocs = new List<Doc>();
                    //    GetChildDocs(docsTable.ToList(), docsReviewsTable.ToList(), getSkillups, skillDoc.DocID);

                    //}
                }
            }
            catch (System.Exception ex)
            {
                result.Data = ex;
            }

            return(result);
        }