public void UpdateFortInformations(FortDetailsOutProto fort) { using (var context = new RocketMapContext()) { String query = "INSERT INTO pokestop (pokestop_id, enabled, latitude, longitude, last_modified, " + "last_updated, name, image) " + "VALUES (\"{0}\", {1}, {2}, {3}, \"{4}\", \"{5}\", {6}, {7}) " + "ON DUPLICATE KEY UPDATE last_updated=VALUES(last_updated), lure_expiration=VALUES(lure_expiration), " + "latitude=VALUES(latitude), longitude=VALUES(longitude), name=VALUES(name)," + "image = IF(VALUES(image) IS NOT NULL AND VALUES(image) <> '', VALUES(image), image)"; try { query = String.Format(query, fort.Id, 1, fort.Latitude, fort.Longitude, ToMySQLDateTime(DateTime.UtcNow), ToMySQLDateTime(DateTime.UtcNow), fort.Name != null ? $"\"{MySQLEscape(fort.Name)}\"" : "NULL", fort.ImageUrl.Count > 0 ? $"\"{MySQLEscape(fort.ImageUrl[0])}\"" : "NULL"); context.Database.ExecuteSqlRaw(query); } catch (Exception e) { Log.Information(e.Message); Log.Information(e.StackTrace); Log.Information($"Object: {JsonSerializer.Serialize(fort)} \n Query: {query}"); } } }
public void AddDetails(FortDetailsOutProto fortDetails) { Id = fortDetails.Id; Latitude = fortDetails.Latitude; Longitude = fortDetails.Longitude; if (string.Compare(Name, fortDetails.Name, true) != 0) { // HasChanges = true; Name = fortDetails.Name; } if (fortDetails.ImageUrl.Count > 0) { var url = fortDetails.ImageUrl.FirstOrDefault(); // Check if url changed if (string.Compare(Url, url, true) != 0) { // HasChanges = true Url = url; } } Updated = DateTime.UtcNow.ToTotalSeconds(); }