private async Task GetTrackMap(string trackShortName) { if (!String.IsNullOrEmpty(trackShortName)) { TrackMapInfo = await _trackMapRepo.GetTrackMapInfoAsync(trackShortName); } }
private async Task SaveTrackMap() { if (String.IsNullOrEmpty(_trackName)) { return; } try { var model = await _trackMapRepo.GetTrackMapInfoAsync(_trackName); if (model == null) { model = new TrackMapInfo() { Latitude = _telemetryCenterX, Longitude = _telemetryCenterY, TrackName = _trackName, Zoom = _mapZoom, Size = new Size(640, 640) }; model.Url = _mapService.GetMapUri((float)model.Latitude, (float)model.Longitude, model.Zoom); } else { model.Latitude = _telemetryCenterX; model.Longitude = _telemetryCenterY; model.TrackName = _trackName; model.Zoom = _mapZoom; model.Size = new Size(640, 640); model.Url = _mapService.GetMapUri((float)model.Latitude, (float)model.Longitude, model.Zoom); } model = await _trackMapRepo.SaveTrackMapInfoAsync(model); await _trackMapRepo.SaveChangesAsync(); var trackImageBytes = await _mapService.GetMapAsync((float)model.Latitude, (float)model.Longitude, model.Zoom); var trackImage = _mapService.GetImageFromBytes(trackImageBytes); await _trackMapRepo.SaveTrackMapImageAsync(trackImage, model.Id); await _trackMapRepo.SaveChangesAsync(); MessageBox.Show("Track map info saved"); } catch (Exception ex) { ExceptionHandler(ex); } }