示例#1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (!activityIndicator.IsRunning)
            {
                var command = new CreateOrUpdatePositionCommand()
                {
                    ZoneId = zone.Id,
                    Name   = name.Text
                };
                try
                {
                    activityIndicator.IsRunning = true;
                    await positionsService.CreatePosition(command);

                    await localeProvider.RefreshLocale();

                    activityIndicator.IsRunning = false;
                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {
                    await DisplayAlert(AppResources.Error, ex.Message, "OK");

                    activityIndicator.IsRunning = false;
                }
                finally
                {
                    activityIndicator.IsRunning = false;
                }
            }
        }
示例#2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var command = new CreateOrUpdateZoneCommand()
            {
                LocaleId    = localeProvider.Locale !.Id,
                Name        = name.Text,
                Description = description.Text,
                Floor       = Convert.ToInt32(floor.Text)
            };

            if (!activityIndicator.IsRunning)
            {
                try
                {
                    activityIndicator.IsRunning = true;
                    await zonesService.CreateZone(command);

                    await localeProvider.RefreshLocale();

                    activityIndicator.IsRunning = false;
                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {
                    activityIndicator.IsRunning = false;
                    await DisplayAlert(AppResources.Error, ex.Message, "OK");
                }
            }
        }
    }
示例#3
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (!activityIndicator.IsRunning)
            {
                activityIndicator.IsRunning = true;
                try
                {
                    var coordinates = await Xamarin.Essentials.Geolocation.GetLocationAsync();

                    var command = new CreateOrUpdateLocaleCommand()
                    {
                        Name        = name.Text,
                        Description = description.Text,
                        Latitude    = coordinates.Latitude,
                        Longitude   = coordinates.Longitude
                    };
                    await localesService.CreateLocale(command);

                    await localeProvider.RefreshLocale();

                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {
                    await DisplayAlert(AppResources.Error, ex.Message, "OK");

                    activityIndicator.IsRunning = false;
                }
                finally
                {
                    activityIndicator.IsRunning = false;
                }
            }
        }