Esempio n. 1
0
        public async Task AddReport(Report report, ReportPhoto photo)
        {
            await _context.ReportPhotos.AddAsync(photo);

            report.ReportPhoto = photo;
            await _context.Reports.AddAsync(report);

            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task <Report> AddReport(ReportResource report, User user)
        {
            var status = await _reportRepository.GetReportStatus(1); // 1 - в обработке

            byte[]      photo          = Convert.FromBase64String(report.ReportPhoto);
            ReportPhoto newReportPhoto = new ReportPhoto
            {
                Photo = photo
            };
            Report newReport = new Report
            {
                Description  = report.Description,
                Latitude     = report.Latitude,
                Longitude    = report.Longitude,
                RegionName   = await GetLocationRegion(report.Latitude, report.Longitude),
                User         = user,
                ReportStatus = status,
                ReportType   = report.ReportType
            };

            await _reportRepository.AddReport(newReport, newReportPhoto);

            return(newReport);
        }
Esempio n. 3
0
 public PhotoTemplate(ReportPhoto model)
 {
     Model = model;
 }
        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;
                }
            }
        }