예제 #1
0
        private async void ButtonClicked(object s, EventArgs a)
        {
            if (loading)
            {
                return;
            }
            var x = loc.Text; var x1 = name.Text; var x2 = email.Text; var x3 = phone.Text;

            loading = true;
            if (file == null)
            {
                DisplayAlert("Fel", "Välj en ikon!", "Avbryt");
                loading = false;
                return;
            }
            if (x != null && x1 != null && x2 != null && x3 != null)
            {
                an.IsVisible = true;
                an.Play();
                var list = await App.GetPositions(x);

                if (list.Count == 1)
                {
                    _a.Address = await App.GetAddress(list[0]);

                    _a.SName = x1; _a.Email = x2; _a.Phone = x3; _a.Login = true;
                    await DBActions.EditAdmin(_a);

                    var aicon = new AdminIcon {
                        ID = _a.ID, Image = App.ImageToByte(file)
                    };
                    if (hadAdminIcon)
                    {
                        await DBActions.EditAdminIcon(aicon);
                    }
                    else
                    {
                        await DBActions.AddAdminIcon(aicon);
                    }
                    await App.ReloadPins();

                    an.IsVisible = false;
                    an.Pause();
                    Navigation.PushAsync(new MapPage(_a));
                    App.RemovePage(this);
                    return;
                }
            }
            an.IsVisible = false;
            an.Pause();
            loading = false;
            await DisplayAlert("Fel", "Ange en giltig adress!", "Avbryt");
        }