Beispiel #1
0
        private async Task FoodMarkerOnDelete(int foodMarkerId)
        {
            BottomSheetVC.HideBottomSheet(View.Frame.GetMaxY());

            FoodMarkerService foodMarkerService = new FoodMarkerService();
            bool isSuccess = await foodMarkerService.DeleteFoodMarker(foodMarkerId);

            if (!isSuccess)
            {
                UIImageView errorView = new UIImageView();
                errorView.Image = UIImage.FromBundle("ErrorScreen");
                double side = (View.Frame.Width * 2.0 / 3.0);
                errorView.Frame  = new CoreGraphics.CGRect(0, 0, side, side);
                errorView.Center = View.Center;
                View.AddSubview(errorView);
                View.BringSubviewToFront(errorView);
                NSTimer.CreateScheduledTimer(3.0, delegate
                {
                    errorView.RemoveFromSuperview();
                });
                return;
            }
            if (_foodMarkerAnnotationDict.ContainsKey(foodMarkerId))
            {
                MapView.RemoveAnnotation(_foodMarkerAnnotationDict[foodMarkerId]);
            }
        }
Beispiel #2
0
        private async Task AppendToFoodMarkerAnnotations()
        {
            FoodMarkerService foodMarkerService = new FoodMarkerService();

            foodMarkerService.OnFail += OnLogout;


            IEnumerable <FoodMarker> foodMarkers = await foodMarkerService.GetAllFoodMarkerPositions();

            AnnotationService annotationService = new AnnotationService();

            foreach (FoodMarker marker in foodMarkers)
            {
                var imageMetas = await foodMarkerService.GetFoodMarkerPhotos(marker.FoodMarkerId);

                marker.FoodMarkerPhotos = imageMetas;
                FoodMarkerAnnotation annotation = annotationService.LoadAnnotations(marker);
                MapView.AddAnnotation(annotation);
                _foodMarkerAnnotationDict.Add(marker.FoodMarkerId, annotation);
            }
        }
Beispiel #3
0
        private async void OkButtonPressed()
        {
            PostFoodMarkerOkButton.Hidden = true;
            PostFoodMarkerOkButton.Image  = UIImage.FromBundle("CheckButtonPressed");
            _activityIndicatorView.StartAnimating();
            try
            {
                var images = _mediaPickerService.GetMediaFromPending();
                if (images == null || images.Count == 0)
                {
                    NotCorrect();
                    return;
                }
                var foodMarker = new FoodMarker()
                {
                    FoodName       = PostFoodMarkerName.Text,
                    CategoryName   = PostFoodMarkerCategory.Text,
                    Comment        = PostFoodMarkerComment.Text,
                    RestaurantName = PostFoodMarkerRestaurant.Text
                };

                string rating = PostFoodMarkerRating.Text;
                foodMarker.Rating = (String.IsNullOrWhiteSpace(rating)? -1 : Convert.ToInt32(rating));


                double            lat     = _locationManager.Location.Coordinate.Latitude;
                double            lng     = _locationManager.Location.Coordinate.Longitude;
                FoodMarkerService service = new FoodMarkerService();

                bool isSaved = await service.SaveFoodMarker(foodMarker, lat, lng);

                if (!isSaved)
                {
                    NotCorrect();
                    return;
                }

                if (images != null && images.Count != 0)
                {
                    var imageMetas = await service.SavePhotos(foodMarker.FoodMarkerId, _mediaPickerService.GetMediaFromPending());

                    foodMarker.FoodMarkerPhotos = imageMetas;
                    _mediaPickerService.ClearPending();
                }

                if (OnSaveSuccess != null)
                {
                    OnSaveSuccess((object)foodMarker, new EventArgs());
                }
                CloseButtonPressed();
            }
            catch
            {
                _activityIndicatorView.StopAnimating();
                UIImageView errorView = new UIImageView();
                errorView.Image = UIImage.FromBundle("ErrorScreen");
                double side = (View.Frame.Width * 2.0 / 3.0);
                errorView.Frame  = new CoreGraphics.CGRect(0, 0, side, side);
                errorView.Center = View.Center;
                View.AddSubview(errorView);
                View.BringSubviewToFront(errorView);
                NSTimer.CreateScheduledTimer(3.0, delegate
                {
                    errorView.RemoveFromSuperview();
                });
                PostFoodMarkerOkButton.Hidden = false;
            }
        }