예제 #1
0
        private async void OnDeletePinFromList(PinViewModel pin)
        {
            var userAnsver = await _pageDialogService.DisplayAlertAsync("Delete", "Do you want delete pin?", "Yes", "No");

            if (userAnsver)
            {
                _pinModelService.DeletePin(pin.ToPinModel());
                var newList = _pinModelService.GetAllPins();
                Pins = new ObservableCollection <PinViewModel>(newList.Select(x => x.ToPinViewModel()));
            }
        }
예제 #2
0
        private async void OnSavePin()
        {
            if (_editPin == null)
            {
                var newPin = new PinModel
                {
                    Description = PinDescription,
                    Latitude    = double.Parse(PinLatitude),
                    Longitude   = double.Parse(PinLongitude),
                    PinName     = PinName,
                    Categories  = SelectedCategories.Name,
                    UserId      = _authorization.GetUserId,
                    FavoritPin  = "ic_like_gray"
                };

                _pinModelService.AddPin(newPin);
                var parametrs = new NavigationParameters();
                parametrs.Add(nameof(PinModel), newPin);

                await NavigationService.GoBackAsync(parametrs);
            }
            else
            {
                _editPin.PinDescription = PinDescription;
                _editPin.PinLatitude    = double.Parse(PinLatitude);
                _editPin.PinLongitude   = double.Parse(PinLongitude);
                _editPin.PinName        = PinName;
                _editPin.PinCategories  = SelectedCategories.Name;
                _editPin.UserId         = _authorization.GetUserId;

                _pinModelService.AddPin(_editPin.ToPinModel());
                var parametrs = new NavigationParameters();
                parametrs.Add(nameof(PinModel), _editPin);

                await NavigationService.GoBackAsync(parametrs);
            }
        }