Exemple #1
0
        private async void Submit()
        {
            IsBusy = true;

            try
            {
                if (ImageFile != null)
                {
                    var locator = CrossGeolocator.Current;
                    locator.DesiredAccuracy = 50;
                    Position position = await locator.GetPositionAsync(timeoutMilliseconds : 10000);

                    byte[] resizedImage = await _imageService.CompressImageAsync(GetByteArray(ImageFile.GetStream()));

                    _response = await _dataService.PostClueResponse(ClueId, position.Latitude, position.Longitude, resizedImage, _response?.Version);

                    if (_response != null)
                    {
                        await _navigationService.GoBackAsync();
                    }
                }
            }
            catch (Exception)
            {
                IsBusy = false;
                await RefreshClue();

                await _messageDialogService.ShowAsync("Submit Error", "There was some error. Try Again.");
            }

            IsBusy = false;
        }
Exemple #2
0
        private async Task RefreshClue()
        {
            try
            {
                IsBusy = true;

                var clues = await _dataService.GetCluesForTeamAsync(_settingsService.RaceId);

                var clue = clues.FirstOrDefault(c => c.Id == ClueId);

                if (clue.HasResponse())
                {
                    _response = await _dataService.GetClueResponse(ClueId);

                    if (_response != null)
                    {
                        HasResponse = true;
                        ImageUrl    = _response.Data;
                    }
                }

                if (!HasResponse || IsChanged)
                {
                    if (ImageFile != null)
                    {
                        ImageUrl = ImageSource.FromStream(() => ImageFile.GetStream());
                    }
                }

                NotifyOfPropertyChange(() => CanSubmit);

                IsBusy = false;
            }
            catch
            {
                await _messageDialogService.ShowAsync("Something went wrong", "Couldn't get the details for this clue. Try again?");
            }
        }