public static List <TPHTable> CombineData(List <TphInfo> infos) { List <TPHTable> newData = new List <TPHTable>(); var data = (from s in db.Table <TPHTable>() select s).ToList(); foreach (TphInfo info in infos) { TPHTable row = new TPHTable(); row.ID = 0; row.Estate = info.Estate; row.Afdeling = info.Afdeling; row.Block = info.Block; row.TPH = info.TPH; row.Active = info.Active; row.Remarks = string.Empty; if (info.UpdatedDate.HasValue) { row.Latitude = info.Latitude; row.Longitude = info.Longitude; row.Remarks = info.Remarks; row.UpdatedDate = info.UpdatedDate; row.IsSent = true; } newData.Add(row); } return(newData); }
public static void UpdateTph(TPHTable model) { try { var tph = (from s in db.Table <TPHTable>() where s.Estate == model.Estate && s.Afdeling == model.Afdeling && s.Block == model.Block && s.TPH == model.TPH select s).FirstOrDefault(); if (tph != null) { if (model.Latitude == tph.Latitude && model.Longitude == tph.Longitude && model.Remarks == tph.Remarks) { return; } var temp = tph; temp.Latitude = model.Latitude; temp.Longitude = model.Longitude; temp.Remarks = model.Remarks; temp.UpdatedDate = DateTime.Now; temp.IsSent = false; db.Update(temp); } } catch { } }