private string BuildSingleVesselQuery(VesselAisUpdateModel existingVessel, VesselUpdateModel update) { StringBuilder vesselQuerySb = new StringBuilder(); vesselQuerySb.Append("UPDATE dbo.Vessels SET IMO = '" + update.IMO + "'"); if (existingVessel.Mmsi == 0) { if (update.MMSI.HasValue) { vesselQuerySb.Append(" , MMSI = '" + update.MMSI + "'"); } } if (update.AISLatestActivity.HasValue) { vesselQuerySb.Append(" , AISLatestActivity = '" + update.AISLatestActivity.Value.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"); } if (update.ETA.HasValue) { vesselQuerySb.Append(" , ETA = '" + update.ETA.Value.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"); } if (update.Course.HasValue) { vesselQuerySb.Append(" , Course = '" + update.Course.Value.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "'"); } if (update.Lat.HasValue) { vesselQuerySb.Append(" , Lat = '" + update.Lat.Value.ToString("0.0000", System.Globalization.CultureInfo.InvariantCulture) + "'"); } if (update.Lon.HasValue) { vesselQuerySb.Append(" , Lon = '" + update.Lon.Value.ToString("0.0000", System.Globalization.CultureInfo.InvariantCulture) + "'"); } if (update.Speed.HasValue) { vesselQuerySb.Append(" , Speed = '" + update.Speed.Value.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "'"); if ((existingVessel.SpeedMax < update.Speed || existingVessel.SpeedMax == null) && update.Speed != 0) { vesselQuerySb.Append(" , SpeedMax = '" + update.Speed.Value.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "'"); } } if (update.Draught.HasValue) { vesselQuerySb.Append(" , Draught = '" + update.Draught.Value.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "'"); if ((existingVessel.DraughtMax < update.Draught || existingVessel.DraughtMax == null) && update.Draught != 0) { vesselQuerySb.Append(" , DraughtMax = '" + update.Draught.Value.ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "'"); } } if (!string.IsNullOrEmpty(update.AISStatus)) { vesselQuerySb.Append(" , AISStatus = '" + _stringParser.MakeFirstCharactersToUpper(update.AISStatus) + "'"); } if (!string.IsNullOrEmpty(update.Destination)) { vesselQuerySb.Append(" , Destination = '" + _stringParser.MakeFirstCharactersToUpper(update.Destination) + "'"); } if (!string.IsNullOrEmpty(update.GeographicalArea)) { vesselQuerySb.Append(" , GeographicalArea = '" + update.GeographicalArea + "'"); } if (!string.IsNullOrEmpty(update.CurrnetPortLocode)) { vesselQuerySb.Append(" , CurrnetPortLocode = '" + update.CurrnetPortLocode + "'"); } vesselQuerySb.Append(" WHERE VesselId = " + existingVessel.VesselId + "; "); vesselQuerySb.AppendLine(); return(vesselQuerySb.ToString()); }