public List <dItem> readComments(int idd) { SQLiteConnection db = new SQLiteConnection(dbcom); db.CreateTable <comments>(); var table = db.Table <comments>(); var cocc = new getComments(); var commentsList = cocc.getComById(idd, dbcom); if (commentsList.Count == 0) { var url = "http://passenger.dream.mmlab.gr/getDetails/" + idd.ToString(); var client = new RestClient(url); var request = new RestRequest(Method.GET); var response10 = client.Execute <dRootObject>(request); if (response10.Data == null || response10.Data.Items.Count == 0) { var list = new List <dItem>(); var data = new dItem { description = "Δεν υπάρχουν σχόλια", id = 0, source = "no" }; list.Add(data); cocc.fillComments(dbcom, list, table); return(list); } else { cocc.fillComments(dbcom, response10.Data.Items, table); return(response10.Data.Items); } } else { var result = new List <dItem>(); foreach (var s in commentsList) { var data = new dItem { id = s.beach_id, description = s.description, source = s.source }; result.Add(data); } return(result); } }
public List <dItem> readDesc(int idd) { SQLiteConnection db = new SQLiteConnection(dbdesc); db.CreateTable <desc>(); var table = db.Table <desc>(); var ddd = new getDescription(); var desclist = ddd.getDescById(idd, dbdesc); if (desclist.Count() == 0) { var url = "http://passenger.dream.mmlab.gr/getDetails/" + idd.ToString(); var client = new RestClient(url); var request = new RestRequest(Method.GET); var response7 = client.Execute <dRootObject>(request); if (response7.Data == null || response7.Data.Items.Count == 0) { var list = new List <dItem>(); var data = new dItem { description = "Δεν υπάρχει περιγραφή", id = 0, source = "no" }; list.Add(data); ddd.fillTable(dbdesc, list, table); return(list); } else { ddd.fillTable(dbdesc, response7.Data.Items, table); return(response7.Data.Items); } } else { var result = new List <dItem>(); foreach (var s in desclist) { var data = new dItem { id = s.beach_id, description = s.description, source = s.source }; result.Add(data); } return(result); } }