private async void FindProduct() { product = await PolaClient.FindProduct(barcode); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ProgressBar.IsIndeterminate = false; if (product == null) { TitleTextBlock.Text = "Brak informacji"; return; } if (product.PlScore != null) { ProgressBar.Value = (int)product.PlScore; } TitleTextBlock.Text = product.Name; TitleTextBlock.Opacity = 1; //TitleTextBlock.Text = "Nieznany produkt (dotknij, aby zgłosić)"; //TitleTextBlock.Text = "Brak informacji"; switch (product.CardType) { case CardType.White: RootGrid.Background = PolaBrushes.ProductVerifiedBackground; ProgressBar.Background = PolaBrushes.ProductVerifiedProgressBarBackground; break; case CardType.Grey: RootGrid.Background = PolaBrushes.ProductNotVerifiedBackground; ProgressBar.Background = PolaBrushes.ProductNotVerifiedProgressBarBackground; break; } }); }
private async Task SendReport() { ProgressLayer.Visibility = Visibility.Visible; ProgressRing.IsActive = true; ProgressMessageTextBlock.Text = "Wysyłanie raportu"; BottomAppBar.Visibility = Visibility.Collapsed; try { Model.Json.Report report = new Model.Json.Report(DescriptionTextBlock.Text, photos.Count, (product != null && product.Id != null) ? (long)product.Id : 0); ReportResponse reportResponse = await PolaClient.CreateReport(report); if (photos.Count > 0 && reportResponse.SignedRequests.Length > 0) { int count = Math.Min(photos.Count, reportResponse.SignedRequests.Length); for (int i = 0; i < count; i++) { var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ProgressMessageTextBlock.Text = string.Format("Wysyłanie zdjęć {0} z {1}", i + 1, photos.Count); }); ReportPhoto photo = photos[i]; string uploadUri = reportResponse.SignedRequests[i][0]; if (photo.Bitmap != null) { await PolaClient.UploadImage(uploadUri, photo.Bitmap); } } } ProgressRing.IsActive = false; ProgressMessageTextBlock.Text = string.Empty; if (product != null) { product.IsReported = true; } MessageDialog dialog = new MessageDialog("Twoje zgłoszenie zostało wysłane i będzie rozpatrzone przez naszą redakcję.", "Pola"); dialog.Commands.Add(new UICommand("ok") { Id = 0, }); dialog.CancelCommandIndex = 0; dialog.DefaultCommandIndex = 0; await dialog.ShowAsync(); Frame.GoBack(); } catch { if (Frame.CurrentSourcePageType == typeof(Report)) { ProgressLayer.Visibility = Visibility.Collapsed; ProgressRing.IsActive = false; MessageDialog dialog = new MessageDialog("Wystąpił błąd podczas wysyłania raportu. Spróbuj ponownie później.", "Błąd"); var ignore = dialog.ShowAsync(); BottomAppBar.Visibility = Visibility.Visible; } } }