public LastContent getSuggestion() { LastContent lastContentObj = null; try { DataTable lastContents = new DataTable(); var sql = "SELECT * FROM Suggestion"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); lastContents.Load(command.ExecuteReader()); command.Dispose(); lastContentObj = new LastContent(); for (int i = 0; i < lastContents.Rows.Count; i++) { var productObj = new Pedia(); var type = lastContents.Rows[i]["type"].ToString(); productObj.nid = int.Parse(lastContents.Rows[i]["nid"].ToString()); productObj.picture = lastContents.Rows[i]["picture"].ToString(); productObj.local_picture = lastContents.Rows[i]["local_picture"].ToString(); productObj.title = lastContents.Rows[i]["title"].ToString(); productObj.url = lastContents.Rows[i]["url"].ToString(); if (type == "product_kit") { if (lastContentObj.product_kit == null) { lastContentObj.product_kit = new List <Pedia>(); } lastContentObj.product_kit.Add(productObj); } else if (type == "product") { if (lastContentObj.product == null) { lastContentObj.product = new List <Pedia>(); } lastContentObj.product.Add(productObj); } else { if (lastContentObj.college == null) { lastContentObj.college = new List <Pedia>(); } lastContentObj.college.Add(productObj); } } return(lastContentObj); } catch (Exception e) { return(lastContentObj); } }
public Bookmark getBookmark() { Bookmark bookmarks = null; try { DataTable lastContents = new DataTable(); var sql = "SELECT * FROM Bookmark"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); lastContents.Load(command.ExecuteReader()); command.Dispose(); bookmarks = new Bookmark(); for (int i = 0; i < lastContents.Rows.Count; i++) { var pediaObj = new Pedia(); var type = lastContents.Rows[i]["type"].ToString(); pediaObj.nid = int.Parse(lastContents.Rows[i]["nid"].ToString()); pediaObj.picture = lastContents.Rows[i]["picture"].ToString(); pediaObj.local_picture = lastContents.Rows[i]["local_picture"].ToString(); pediaObj.title = lastContents.Rows[i]["title"].ToString(); pediaObj.url = lastContents.Rows[i]["url"].ToString(); switch (type) { case "article": if (bookmarks.article == null) { bookmarks.article = new List <Pedia>(); } bookmarks.article.Add(pediaObj); break; case "blog": if (bookmarks.blog == null) { bookmarks.blog = new List <Pedia>(); } bookmarks.blog.Add(pediaObj); break; case "college": if (bookmarks.college == null) { bookmarks.college = new List <Pedia>(); } bookmarks.college.Add(pediaObj); break; case "designteam": if (bookmarks.designteam == null) { bookmarks.designteam = new List <Pedia>(); } bookmarks.designteam.Add(pediaObj); break; case "education": if (bookmarks.education == null) { bookmarks.education = new List <Pedia>(); } bookmarks.education.Add(pediaObj); break; case "film": if (bookmarks.film == null) { bookmarks.film = new List <Pedia>(); } bookmarks.film.Add(pediaObj); break; case "gallerynew": if (bookmarks.gallerynew == null) { bookmarks.gallerynew = new List <Pedia>(); } bookmarks.gallerynew.Add(pediaObj); break; case "pedia": if (bookmarks.pedia == null) { bookmarks.pedia = new List <Pedia>(); } bookmarks.pedia.Add(pediaObj); break; case "podcast": if (bookmarks.podcast == null) { bookmarks.podcast = new List <Pedia>(); } bookmarks.podcast.Add(pediaObj); break; case "product": if (bookmarks.product == null) { bookmarks.product = new List <Pedia>(); } bookmarks.product.Add(pediaObj); break; case "product_kit": if (bookmarks.product_kit == null) { bookmarks.product_kit = new List <Pedia>(); } bookmarks.product_kit.Add(pediaObj); break; case "publication": if (bookmarks.publication == null) { bookmarks.publication = new List <Pedia>(); } bookmarks.publication.Add(pediaObj); break; } } return(bookmarks); } catch (Exception e) { return(bookmarks); } }