private void ExecuteTapCommand(object parameter)
 {
     if (parameter is Car car)
     {
         DialogService.DisplayAlertAsync("Tap works", $"Long tapped on {car.Name}", "OK");
     }
 }
Example #2
0
        public async void Rent()
        {
            bool confirmed = await DialogService.DisplayAlertAsync("Alert", "Are you sure you want to rent this car?", "Yes", "No");

            if (!confirmed)
            {
                return;
            }
            NewReservation.ReservationTypeId = SelectedReservationType.Id;
            NewReservation.StartDate         = SelectedRange.StartDate;
            NewReservation.EndDate           = SelectedRange.EndDate;
            HttpResponseMessage registerCarResponse = await ApiService.PostReservationAsync(NewReservation);

            if (registerCarResponse.IsSuccessStatusCode)
            {
                string responseContent = await registerCarResponse.Content.ReadAsStringAsync();

                Response submitResponse = JsonConvert.DeserializeObject <Response>(responseContent);
                await DialogService.DisplayAlertAsync($"{submitResponse.Status}", $"{submitResponse.Message}", "OK");

                await NavigationService.NavigateAsync(Config.HomeTabbedPageNavigation);
            }
            else
            {
                string responseContent = await registerCarResponse.Content.ReadAsStringAsync();

                Response submitResponse = JsonConvert.DeserializeObject <Response>(responseContent);
                await DialogService.DisplayAlertAsync($"{submitResponse.Status}", $"{submitResponse.Message}", "OK");
            }
        }
Example #3
0
 private async void SelecionarVeiculo(RetornoVeiculosMotorista veiculo)
 {
     CrossSettings.Current.Set("VeiculoSelecionado", veiculo);
     try
     {
         UserDialogs.Instance.ShowLoading("Carregando...");
         using (var response = await IniciarCliente(true).GetAsync("motorista/selecionarVeiculo/" + MotoristaLogado.codigo + "/" + veiculo.codVeiculo))
         {
             if (response.IsSuccessStatusCode)
             {
                 await NavigationService.NavigateAsync("//NavigationPage/Home");
             }
             else
             {
                 await DialogService.DisplayAlertAsync("Aviso", response.Content.ReadAsStringAsync().Result, "OK");
             }
         }
     }
     catch (AccessViolationException e)
     {
         await DialogService.DisplayAlertAsync("Aviso", e.Message, "OK");
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
         await DialogService.DisplayAlertAsync("Aviso", "Falha ao selecionar veículo", "OK");
     }
     finally
     {
         UserDialogs.Instance.HideLoading();
     }
 }
        private async Task DownloadListAsync(string listType)
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    this._travelList = await this._travelService.GetTravelAlertsAsync(listType);

                    foreach (var item in _travelList)
                    {
                        this.MainListViewModel.ItemsSource.Add(new MainListItem()
                        {
                            Id              = item.Id,
                            Title           = item.Headline,
                            PublicationDate = item.Sent.ToString("yyyy-MM-dd")
                        });
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("無法連線", "請開啟網路", "OK");
                }
            }
            catch (Exception ex)
            {
                await DialogService.DisplayAlertAsync("發生錯誤", ex.Message, "OK");
            }
        }
Example #5
0
        void InitCommands()
        {
            Save = new Command(async() =>
            {
                if (!string.IsNullOrEmpty(Model.Text))
                {
                    if (!string.IsNullOrEmpty(Model.FilePath))
                    {
                        File.WriteAllText(Model.FilePath, Model.Text);
                    }
                    else
                    {
                        var _fileName = Path.Combine(_folderPath, $"{Guid.NewGuid()}_AppNotes.txt");
                        File.WriteAllText(_fileName, Model.Text);
                    }

                    await GoBackAsync();
                }
                else
                {
                    await DialogService.DisplayAlertAsync("Advertencia", "Debe de ingresar texto a la nota", "Aceptar");
                }
            });

            Cancel = new Command(async() =>
            {
                await GoBackAsync();
            });
        }
        private async void Login()
        {
            try
            {
                ActivityIndicatorTitle = "Logging In. Please wait.";
                IsBusy = true;

                User userObject = PrismApplicationBase.Current.Container.Resolve(typeof(User)) as User;

                userObject.UserID   = _userId;
                userObject.Password = _password;
                userObject.UserName = await FirebaseService.GetUserNameAsync(_userId);

                if (!string.IsNullOrEmpty(await FirebaseService.LoginAsync(userObject)))
                {
                    await NavigationService.NavigateAsync("MainPage");
                }
                else
                {
                    await DialogService.DisplayAlertAsync("Log in failed !", "Incorrect ID or password. Please try again.", "OK");
                }
            }

            finally
            {
                IsBusy = false;
            }
        }
        public async void SaveProduct()
        {
            string messages = "";

            if (Product.ItemsUsed == null || (Product.ItemsUsed != null && Product.ItemsUsed.Count == 0))
            {
                messages += "Add an Item\n";
            }
            if (string.IsNullOrEmpty(Product.Name))
            {
                messages += "Enter the Name of the Product";
            }
            if (!string.IsNullOrEmpty(messages))
            {
                await DialogService.DisplayAlertAsync("Alert", messages, "Ok");

                return;
            }

            int add = await App.DbHelper.SaveProduct(Product);

            foreach (var item in Product.ItemsUsed)
            {
                if (item.Quantity > 0)
                {
                    item.ProductId = Product.Id;
                    await App.DbHelper.SaveItemUsed(item);
                }
            }
            Xamarin.Forms.MessagingCenter.Send <Product>(Product, "added");
            setNewProduct();
        }
Example #8
0
        public async void AddCar()
        {
            bool isAuthorized = await AuthorizationService.Authorize();

            if (!isAuthorized)
            {
                return;
            }
            NewCar.OwnerId    = CurrentUserId.UserId;
            NewCar.BrandId    = SelectedBrand.Id;
            NewCar.CategoryId = SelectedCategory.Id;
            NewCar.FuelTypeId = SelectedFuelType.Id;
            HttpResponseMessage registerCarResponse = await ApiService.PostCarAsync(NewCar);

            if (registerCarResponse.IsSuccessStatusCode)
            {
                string responseContent = await registerCarResponse.Content.ReadAsStringAsync();

                Response submitResponse = JsonConvert.DeserializeObject <Response>(responseContent);
                await DialogService.DisplayAlertAsync($"{submitResponse.Status}", $"{submitResponse.Message}", "OK");

                await NavigationService.NavigateAsync(Config.HomeTabbedPageNavigation);
            }
            else
            {
                string responseContent = await registerCarResponse.Content.ReadAsStringAsync();

                Response submitResponse = JsonConvert.DeserializeObject <Response>(responseContent);
                await DialogService.DisplayAlertAsync($"{submitResponse.Status}", $"{submitResponse.Message}", "OK");
            }
        }
        public async void RestoreDb()
        {
            bool res = await DialogService.DisplayAlertAsync("Confirm", "Restoring the previous data will replace all your current data.\n Do you wish to continue?", "Yes", "No");

            if (res)
            {
                FileData file = null;
                try
                {
                    file = await Plugin.FilePicker.CrossFilePicker.Current.PickFile();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                if (file == null)
                {
                    return;
                }

                IsBusy = true;
                List <byte> dataArray = new List <byte>(file.DataArray);
                await UnZipDb(dataArray, file.FileName);

                //Stream s = file.GetStream();
                //UnZipDb(s);
            }
        }
        private async void SubmitRequestCommandExecuteAsync()
        {
            IsBusy = true;
            CreateCustomerResponse response = await _backendApiService.SubmitCreateCustomerRequest(Request);

            IsBusy = false;

            if (response == null)
            {
                await DialogService.DisplayAlertAsync("Forbindelse", "Du har ikke forbindelse til internettet", "OK");
            }
            else if (response.WasUnsuccessfull())
            {
                await DialogService.DisplayAlertAsync("Ukendt fejl", "Din bruger kunne ikke oprettes", "OK");
            }
            else
            {
                if (response.Body != null)
                {
                    _sessionService.Update(response.Body.token, new Customer(response.Body.customer));
                }

                await NavigationService.NavigateAsync("/" + nameof(CustomerMasterDetailPage) + "/" + nameof(NavigationPage) + "/" + nameof(RidesPage));
            }
        }
Example #11
0
        async void ExecuteAccionSiguienteIC()
        {
            try
            {
                string msj = ValidarCampos();
                if (msj != "")
                {
                    await DialogService.DisplayAlertAsync(Constantes.MSJ_VALIDACION, msj, Constantes.MSJ_BOTON_OK);
                }
                else
                {
                    NavigationParameters navParametros = GetNavigationParameters();

                    navParametros.Add("Monto", Monto);
                    navParametros.Add("NumCelular", NumCelular);
                    navParametros.Add("NomOperador", OperadorSelected.Nombre);
                    navParametros.Add("Operador", OperadorSelected);
                    navParametros.Add(Constantes.pageOrigen, Constantes.pageRecargaCelular);
                    navParametros.Add("Moneda", CatalogoService.BuscarMonedaPorCodigo("PEN"));

                    Application.Current.Properties["strTipoTransf"]       = "0";
                    Application.Current.Properties["strOrigenMisCuentas"] = false;
                    Application.Current.Properties["strPageOrigen"]       = Constantes.pageRecargaCelular;
                    await NavigationService.NavigateAsync(Constantes.pageCtaCargo, navParametros);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Example #12
0
        protected override async void NaviDetailPageAsync()
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    var item = await this._newsService.GetDiseaseFeedAsync(this.MainListViewModel.SelectedItem.Id);

                    var title = "傳染病說明";

                    var ps = new NavigationParameters {
                        { "SelectedItem", item }
                    };

                    await NavigationService.NavigateAsync(new Uri($"NewsDetailPage?Title={title}", UriKind.Relative), ps);
                }
                else
                {
                    await DialogService.DisplayAlertAsync("無法連線", "請開啟網路", "OK");
                }
            }
            catch (Exception ex)
            {
                await DialogService.DisplayAlertAsync("發生錯誤", ex.Message, "OK");
            }

            this.MainListViewModel.SelectedItem = null;
        }
Example #13
0
        public async void CreateUser()
        {
            User user = new User()
            {
                Name = this.Name, Password = this.Password
            };

            try
            {
                UserDialogs.Instance.ShowLoading("Loading...");
                bool useWCF = Preferences.Get("UseWCF", false);
                if (!useWCF)
                {
                    var resp = await App.SQLiteDb.SaveUserAsync(user);

                    if (resp == 1)
                    {
                        await DialogService.DisplayAlertAsync("Success", "User saved", "OK");
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("Warning", "Something went wrong", "OK");
                    }
                }
                else
                {
                    var client = new HttpClient
                    {
                        Timeout     = TimeSpan.FromMilliseconds(15000),
                        BaseAddress = new Uri(GetUrlBase())
                    };

                    var json    = JsonConvert.SerializeObject(user);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    using (var response = await client.PostAsync("SaveUser", content))
                    {
                        if (response != null)
                        {
                            if (response.IsSuccessStatusCode)
                            {
                                var respStr = await response.Content.ReadAsStringAsync();

                                await DialogService.DisplayAlertAsync("Success", "User saved", "OK");
                            }
                            else
                            {
                                await DialogService.DisplayAlertAsync("Warning", "Connection Failed", "OK");
                            }
                        }
                    }
                }
            }catch (Exception e)
            {
                await DialogService.DisplayAlertAsync("Warning", "Something went wrong", "OK");
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Example #14
0
        private async void SearchAction()
        {
            try
            {
                using (var cliente = IniciarClient())
                {
                    UserDialogs.Instance.ShowLoading("Carregando...");
                    var resposta = await cliente.GetStringAsync("/processo-api/v1/processo/" + NumeroProcesso);

                    var processoResponse = JsonConvert.DeserializeObject <ProcessoResponse>(resposta);
                    if (processoResponse != null)
                    {
                        var param = new NavigationParameters();
                        param.Add("ProcessoResponse", processoResponse);
                        await NavigationService.NavigateAsync("ProcessoPage", param);
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("Resultado", "Nenhum processo encontrado!", "Ok");
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
        public async void SaveParty()
        {
            bool confirm = await DialogService.DisplayAlertAsync("Confirm", "Do you want to save?", "Yes", "No");

            if (confirm)
            {
                string messages = "";
                if (string.IsNullOrEmpty(Party.Name))
                {
                    messages += "Name is a required field";
                }
                if (Party.ProfitPercent == 0)
                {
                    messages += "Profit Percent is a required field";
                }
                if (!string.IsNullOrEmpty(messages))
                {
                    await DialogService.DisplayAlertAsync("Alert", messages, "Ok");

                    return;
                }
                int add = await App.DbHelper.SaveParty(Party);

                await DialogService.DisplayAlertAsync("Success", "Party added Successfully", "Ok");

                Xamarin.Forms.MessagingCenter.Send <Party>(Party, "added");
                await NavigationService.GoBackAsync();
            }
        }
        private async void Button_Clicked()
        {
            if (!string.IsNullOrEmpty(FavortieColor.ToString()))
            {
                _pref.FavoriteColor = FavortieColor;
                _colorIsSet         = true;
            }
            else
            {
                await DialogService.DisplayAlertAsync("", "Please enter input to color entry", "OK");
            }

            if (!string.IsNullOrEmpty(FavoriteBand))
            {
                _pref.FavoriteBand = FavoriteBand;
                _bandIsSet         = true;
            }
            else
            {
                await DialogService.DisplayAlertAsync("", "Please enter input to band entry", "OK");
            }

            if (_colorIsSet && _bandIsSet)
            {
                await NavigationService.NavigateAsync(nameof(MainPage));

                EventAggregator.GetEvent <MessageSentEvent>().Publish(_pref);
            }
        }
        private async void LoginAction()
        {
            try
            {
                using (var cliente = IniciarClient())
                {
                    UserDialogs.Instance.ShowLoading("Carregando...");
                    var conteudoJson = JsonConvert.SerializeObject(new LoginAdvogado(Oab, Letra, Uf, Senha));
                    var conteudo     = new StringContent(conteudoJson, Encoding.UTF8, "application/json");

                    var resposta = await cliente.PostAsync("/processo-api/login/advogado", conteudo);

                    if (resposta.IsSuccessStatusCode)
                    {
                        var respString = resposta.Content.ReadAsStringAsync().Result;
                        var param      = new NavigationParameters();
                        param.Add("NomeAdvogado", respString);
                        await NavigationService.NavigateAsync("/MenuPage/Navigation/MainPage", param);
                    }
                    else
                    {
                        await DialogService.DisplayAlertAsync("Resultado", resposta.Content.ReadAsStringAsync().Result, "Ok");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("IOException message: {0}", e.Message);
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
        private async void Button_Clicked()
        {
            bool loggedIn = false;

            Settings.RememberMe = _rememberMe;

            if (_rememberMe)
            {
                Settings.Username = _username;

                if (Settings.Password == Settings.DefaultPassword)
                {
                    Settings.Password = _password;
                }
            }
            else
            {
                Settings.Username = _username;
                if (Settings.Password == _password)
                {
                    Settings.Password = Settings.DefaultPassword;
                    loggedIn          = true;
                }
                Settings.Username = string.Empty;
            }

            if (loggedIn || (Settings.Password == _password))
            {
                await NavigationMethod.NavigateAsync(nameof(Home));
            }
            else
            {
                await DialogService.DisplayAlertAsync("Alert", "Invalid Password", "OK");
            }
        }
Example #19
0
        private async void ItemProcSelecionadoAction(ProcessoInfo itemProcSelecionado)
        {
            try
            {
                using (var cliente = IniciarClient())
                {
                    UserDialogs.Instance.ShowLoading("Carregando...");
                    if ("Fases".Equals(itemProcSelecionado.Descricao))
                    {
                        if (itemProcSelecionado.Quantidade > 0)
                        {
                            var resposta = await cliente.GetStringAsync("/processo-api/v1/fase/"
                                                                        + itemProcSelecionado.NumProcesso);

                            var faseResponse = JsonConvert.DeserializeObject <FaseResponse>(resposta);
                            var param        = new NavigationParameters();
                            param.Add("FaseResponse", faseResponse);
                            await NavigationService.NavigateAsync("FasesPage", param);
                        }
                        else
                        {
                            await DialogService.DisplayAlertAsync("Resultado", "Nenhuma fase encontrada!", "Ok");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Example #20
0
        //protected async System.Threading.Tasks.Task LoadDatabase(string path)
        //{
        //    //var cruiseFileType = CruiseDAL.DAL.ExtrapolateCruiseFileType(path);
        //    //if (cruiseFileType.HasFlag(CruiseDAL.CruiseFileType.Cruise))
        //    //{
        //    //    Analytics.TrackEvent("Error::::LoadCruiseFile|Invalid File Path", new Dictionary<string, string>() { { "FilePath", path } });
        //    //    return;
        //    //}

        //    try
        //    {
        //        var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Storage);

        //        if (status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
        //        {
        //            if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Plugin.Permissions.Abstractions.Permission.Storage))
        //            {
        //                await DialogService.DisplayAlertAsync("Request Access To Storage", "FScruiser needs access to files on device", "OK");
        //            }

        //            var requestResults = await CrossPermissions.Current.RequestPermissionsAsync(Plugin.Permissions.Abstractions.Permission.Storage);
        //            status = requestResults.GetValueOrDefault(Plugin.Permissions.Abstractions.Permission.Storage);
        //        }

        //        if (status == Plugin.Permissions.Abstractions.PermissionStatus.Granted)
        //        {
        //            try
        //            {
        //                if (System.IO.Path.GetExtension(path).ToLowerInvariant() == ".cruise")
        //                {
        //                    var convertedPath = Migrator.GetConvertedPath(path);

        //                    // if converted file already exists let the user know that we
        //                    // are just going to open it instead of the file they selected
        //                    // otherwise convert the .cruise file and open the convered .crz3 file
        //                    if (System.IO.File.Exists(convertedPath) == true)
        //                    {
        //                        await DialogService.DisplayAlertAsync("Message",
        //                            $"Opening {convertedPath}",
        //                            "OK");
        //                    }
        //                    else
        //                    {
        //                        try
        //                        {
        //                            Migrator.MigrateFromV2ToV3(path, convertedPath);
        //                        }
        //                        catch(Exception e)
        //                        {
        //                            LogAndShowExceptionAsync("File Error", "Unable to Migrate File", e
        //                                , new Dictionary<string, string>(){ { "FileName", path } })
        //                                .FireAndForget();
        //                            return;
        //                        }

        //                        var fileName = System.IO.Path.GetFileName(path);
        //                        await DialogService.DisplayAlertAsync("Message",
        //                            $"Your cruise file has been updated and the file {fileName} has been created",
        //                            "OK");
        //                    }

        //                    path = convertedPath;
        //                }

        //                DataserviceProvider.OpenDatabase(path);
        //                path = DataserviceProvider.DatabasePath;

        //                Properties.SetValue("cruise_path", path);

        //                //var sampleInfoDS = DataserviceProvider.GetDataservice<ISampleInfoDataservice>();
        //                //if (sampleInfoDS.HasSampleStates() == false
        //                //    && sampleInfoDS.HasSampleStateEnvy()
        //                //    && await DialogService2.AskYesNoAsync("This file doesn't have any samplers associated with this device. Would you to continue by copying a state from another device?", "Copy samplers from another device?"))
        //                //{
        //                //    await NavigationService.NavigateAsync("/Main/Navigation/CuttingUnits/SampleStateManagmentOther");
        //                //}
        //                //else
        //                //{
        //                //    await NavigationService.NavigateAsync("/Main/Navigation/CuttingUnits");
        //                //}

        //                await NavigationService.NavigateAsync("/Main/Navigation/CuttingUnits");

        //                MessagingCenter.Send<object, string>(this, Messages.CRUISE_FILE_OPENED, path);
        //            }
        //            catch (FileNotFoundException ex)
        //            {
        //                LogAndShowExceptionAsync("File Error", "File Not Found",
        //                    ex, new Dictionary<string, string> { { "FilePath", path } })
        //                    .FireAndForget();
        //            }
        //            catch (Exception ex)
        //            {
        //                 LogAndShowExceptionAsync("File Error", "File Could Not Be Opended",
        //                     ex, new Dictionary<string, string> { { "FilePath", path } })
        //                    .FireAndForget();
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LogException("permissions", "request permissions error in method LoadCruiseFileAsync", ex);
        //    }
        //}

        //protected void ReloadNavigation()
        //{
        //    var navPath = Properties.GetValueOrDefault(CURRENT_NAV_PATH) as string;

        //    if(navPath != null && !navPath.EndsWith("CuttingUnits"))
        //    {
        //        var navParams = Properties.GetValueOrDefault(CURRENT_NAV_PARAMS) as string;

        //        NavigationService.NavigateAsync(navPath, new NavigationParameters(navParams));
        //    }
        //}

        protected override async void OnStart()
        {
            // Handle when your app starts

            var isFirstRun = Properties.GetValueOrDefault <bool>("isFirstLaunch", true);

            if (isFirstRun)
            {
                var enableDiagnostics = await DialogService.DisplayAlertAsync("", $"FScruiser can automaticly send dianostics and crash reports.{Environment.NewLine}{Environment.NewLine} " +
                                                                              $"This feature is optional, however, it helps us to create a better experience.{Environment.NewLine}{Environment.NewLine}" +
                                                                              $"Would you like to enable this feature?{Environment.NewLine}{Environment.NewLine}" +
                                                                              "You can also change this option in the settings page.", "Enable", "No Thanks");

                Settings.EnableAnalitics = Settings.EnableCrashReports = enableDiagnostics;

                Properties.SetValue("isFirstLaunch", false);
            }

            //var cruise_path = _cruisePath ?? Properties.GetValueOrDefault("cruise_path") as string;

            //if (!string.IsNullOrEmpty(cruise_path))
            //{
            //    await LoadDatabase(cruise_path);
            //}
        }
        public async void DeleteCar(Car car)
        {
            bool confirmed = await DialogService.DisplayAlertAsync("Alert", "Are you sure you want to delete this car?", "Yes", "No");

            if (!confirmed)
            {
                return;
            }
            await AuthorizationService.Authorize();

            HttpResponseMessage carsRequest = await ApiService.DeleteMyCarAsync(car.CarId);

            if (carsRequest.IsSuccessStatusCode)
            {
                string responseContent = await carsRequest.Content.ReadAsStringAsync();

                Response = JsonConvert.DeserializeObject <Response>(responseContent);
                await DialogService.DisplayAlertAsync($"{Response.Status}", $"{Response.Message}", "OK");

                Refresh();
            }
            else
            {
                await DialogService.DisplayAlertAsync("Error", "Could not delete car", "OK");
            }
        }
Example #22
0
        private async void ValidaTempoEspera()
        {
            // if (CrossSettings.Current.Contains("dataRecebimentoChamada"))
            //  {
            // int tempoEspera = chamada.tempoParaResposta;//CrossSettings.Current.Get<string>("tempoEsperaAceitacao");
            //DateTime dtRecebimento = CrossSettings.Current.Get<DateTime>("dataRecebimentoChamada");
            var tempoAtual         = DateTime.Now;
            var tempoAtualAjustado = tempoAtual.Subtract(TimeSpan.FromSeconds(chamada.tempoParaResposta));

            if (tempoAtualAjustado > chamada.dataRecebimento)
            {
                CrossSettings.Current.Remove("tempoEsperaAceitacao");
                CrossSettings.Current.Remove("dataRecebimentoChamada");
                CrossSettings.Current.Remove("ChamadaParaResposta");
                _expirouTempo  = true;
                MostraContador = false;
                TextoContador  = "Tempo limite esgotado!";
                await DialogService.DisplayAlertAsync("Aviso", "Tempo limite para resposta expirado", "OK");
            }
            else
            {
                _contador          = new Timer();
                _contador.Interval = 1000;
                _contador.Elapsed += OnTimedEvent;
                _contador.Enabled  = true;
                MostraContador     = true;
                TextoContador      = "Tempo Restante: ";
                _segundosRestantes = Convert.ToInt32((chamada.dataRecebimento - tempoAtualAjustado).TotalSeconds);
                _expirouTempo      = false;
            }
            // }
        }
        public async void SaveItemAsync()
        {
            bool confirm = await DialogService.DisplayAlertAsync("Confirm", "Do you want to save?", "Yes", "No");

            if (confirm)
            {
                string messages = "";
                if (string.IsNullOrEmpty(Item.Name))
                {
                    messages += "Enter name of the Item.\n";
                }
                if (Item.Rate == 0)
                {
                    messages += "Enter a valid rate.\n";
                }
                if (string.IsNullOrEmpty(Item.Unit))
                {
                    messages += "Choose a Unit.";
                }
                if (!string.IsNullOrEmpty(messages))
                {
                    await DialogService.DisplayAlertAsync("Alert", messages, "Ok");

                    return;
                }
                await App.DbHelper.SaveItem(Item);

                //await DialogService.DisplayAlertAsync("Success", "Item edited SuccessFully", "Ok");
                Xamarin.Forms.MessagingCenter.Send <Item>(Item, "added");
                await NavigationService.GoBackAsync();
            }
        }
        private async Task DownloadListAsync(string listType)
        {
            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    this._newsList = await this._newsService.GetRssReedsAsync(listType);

                    foreach (var feed in _newsList)
                    {
                        this.MainListViewModel.ItemsSource.Add(new MainListItem()
                        {
                            Id              = feed.Guid,
                            Title           = feed.Title,
                            PublicationDate = feed.PublicationDate.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                    }
                }
                else
                {
                    await DialogService.DisplayAlertAsync("無法連線", "請開啟網路", "OK");
                }
            }
            catch (Exception ex)
            {
                await DialogService.DisplayAlertAsync("發生錯誤", ex.Message, "OK");
            }
        }
        async Task ClearData()
        {
            try
            {
                IncrementPendingRequestCount();

                // remove goal
                if (!await DataService.RemoveGoal())
                {
                    await DialogService.DisplayAlertAsync("Error", "An error occurred removing the goal", Constants.Strings.Generic_OK);

                    return;
                }

                // remove all weight entries
                var allEntries = await DataService.GetAllWeightEntries();

                foreach (var entry in allEntries)
                {
                    await DataService.RemoveWeightEntryForDate(entry.Date);
                }
            }
            finally
            {
                DecrementPendingRequestCount();
            }
        }
Example #26
0
 protected void DisplayAlert(string title, string message, string button = "OK")
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         await DialogService.DisplayAlertAsync(title, message, button);
     });
 }
Example #27
0
        private async void socialGoogleApiCall()
        {
            {
                try
                {
                    UserDialogs.Instance.ShowLoading(null, MaskType.None);
                    HttpClient client = new HttpClient();
                    client.Timeout = TimeSpan.FromMinutes(5);

                    var formContent = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("email", GoogleUser.Email),
                        new KeyValuePair <string, string>("socialmedia_id", GoogleUser.id),
                        new KeyValuePair <string, string>("social_type", socialType),
                        new KeyValuePair <string, string>("first_name", GoogleUser.first_name),
                        new KeyValuePair <string, string>("last_name", GoogleUser.last_name),
                    });
                    try
                    {
                        var result = await client.PostAsync(Links.SocialLogin, formContent);

                        if ((int)result.StatusCode == 200)
                        {
                            var jsonString = result.Content.ReadAsStringAsync().Result;
                            User = JsonConvert.DeserializeObject <UserModel>(jsonString);
                            Settings.FullName = User.full_name;
                            _googleManager.Logout();
                            UserDialogs.Instance.HideLoading();
                            if (User.has_business)
                            {
                                Settings.UserID = User.business_id;
                                Application.Current.Properties["UserLogin"] = true;
                                await NavigationService.NavigateAsync(new Uri("http://www.testapp.com/Home", UriKind.Absolute));
                            }
                            else
                            {
                                await DialogService.DisplayAlertAsync("", "You don't have business with us, please register here - > https://dev.spotimist.com/spotimist/get-listed/", "OK");
                            }
                        }

                        else
                        {
                            UserDialogs.Instance.HideLoading();
                            await DialogService.DisplayAlertAsync("", "Server error, Please contact support team", "OK");
                        }
                    }

                    finally
                    {
                        client.Dispose();
                    }
                }
                catch (Exception)
                {
                    UserDialogs.Instance.HideLoading();
                    await DialogService.DisplayAlertAsync("", "Network issue please try once again", "OK");
                }
            }
        }
Example #28
0
 protected async Task HandleError(Exception ex)
 {
     await DialogService.DisplayAlertAsync(
         "Lỗi",
         "Đã có lỗi trong quá trình xử lý. Vui lòng liên hệ nhà quản trị.",
         "Đóng"
         );
 }
Example #29
0
        private void ShowTeamCommandExecute()
        {
            string teamMessage = "Desenvolvedor: Humberto Machado\n\n" +
                                 "Testadores:\nRaquel Machado\nRafael Marques\nHugo Machado\n\n" +
                                 "Página do Projeto: https://github.com/linck/ezra-xamarin";

            DialogService.DisplayAlertAsync("Equipe", teamMessage, "Fechar");
        }
        public async void Cancel()
        {
            bool confirm = await DialogService.DisplayAlertAsync("Confirm", "Do you want to cancel?", "Yes", "No");

            if (confirm)
            {
                await NavigationService.GoBackAsync();
            }
        }