Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
0
 public async Task <ActionResult <Locale> > CreateLocale(
     [FromServices] ILocaleService localeService,
     [FromBody] CreateOrUpdateLocaleCommand command)
 {
     return(await localeService.CreateLocale(command));
 }