示例#1
0
        public IEnumerable <PageData> GetPagesData(String _DbPath)
        {
            IEnumerable <PageData> pagesData = null;
            //using (var db = new LiteDatabase(_DbPath + DB_NAME))
            //{
            var db = LiteDBProjectRepository.getDb(_DbPath + DB_NAME);

            pagesData =
                db.GetCollection <PageData>(PAGES_DATA)
                .FindAll();
            //}
            return(pagesData);
        }
示例#2
0
        public PageData SavePageData(PageData _pageData, String _DbPath)
        {
            //using (var db = new LiteDatabase(_DbPath + DB_NAME))
            //{
            var db        = LiteDBProjectRepository.getDb(_DbPath + DB_NAME);
            var pagesData =
                db.GetCollection <PageData>(PAGES_DATA);

            pagesData.Insert(_pageData);
            pagesData.EnsureIndex(pd => pd.id);
            //}
            return(_pageData);
        }
示例#3
0
        public PageData GetPageDataById(int _id, String _DbPath)
        {
            PageData pageData = null;

            //using (var db = new LiteDatabase(_DbPath + DB_NAME))
            //{
            var db        = LiteDBProjectRepository.getDb(_DbPath + DB_NAME);
            var pagesData =
                db.GetCollection <PageData>(PAGES_DATA);

            pageData = pagesData.FindById(_id);
            //}
            return(pageData);
        }
示例#4
0
        public PageData UpdatePageDataById(int _id, String _title, String _content, String _DbPath)
        {
            PageData pageData = null;
            //using (var db = new LiteDatabase(_DbPath + DB_NAME))
            //{
            var db        = LiteDBProjectRepository.getDb(_DbPath + DB_NAME);
            var pagesData =
                db.GetCollection <PageData>(PAGES_DATA);

            pageData = pagesData.FindById(_id);
            if (pageData != null)
            {
                pageData.title   = _title;
                pageData.content = _content;
                pagesData.Update(pageData);
                pagesData.EnsureIndex(pd => pd.id);
            }
            //}
            return(pageData);
        }
示例#5
0
        public PageData GetPageDataBySection(String _section, String _DbPath)
        {
            PageData pageData = null;
            var      db       = LiteDBProjectRepository.getDb(_DbPath + DB_NAME);
            //using (var db = new LiteDatabase(_DbPath + DB_NAME))
            //{
            var pagesData =
                db.GetCollection <PageData>(PAGES_DATA);

            pageData =
                pagesData.Find(pd => (pd.section.Equals(_section)))
                .Select(
                    pd =>
                    new PageData
            {
                title     = pd.title
                , content = pd.content
            }
                    )
                .FirstOrDefault();
            //}
            return(pageData);
        }