private async Task GetStationDetails() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await ApiCalls.GetStationDetails(); if (RequestResult.success) { StationDetails = RequestResult.data; ContentVisible = true; RefreshBtnVisible = false; } else { ContentVisible = false; RefreshBtnVisible = true; AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
public async Task GetPrixTypesJsonData() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await AppHelper.ReadFromJson <ObservableCollection <PrixTypeForm> >("Assets.MockedData.PriceTypes.json"); if (RequestResult.success) { PrixTypes = RequestResult.data; } else { AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); await Application.Current.MainPage.Navigation.PopAsync(); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
public async Task GetJsonData() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await AppHelper.ReadFromJson <StationModel>("Assets.MockedData.StationDetails.json"); if (RequestResult.success) { StationDetails = RequestResult.data; ContentVisible = true; RefreshBtnVisible = false; } else { ContentVisible = false; RefreshBtnVisible = true; AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
private async Task GetPrixTypes() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await ApiCalls.GetPrixTypes(); if (RequestResult.success) { PrixTypes = RequestResult.data; } else { AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); await Application.Current.MainPage.Navigation.PopAsync(); } } catch (Exception) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
public async Task GetStatutsJsonData() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await AppHelper.ReadFromJson <ObservableCollection <StatutModel> >("Assets.MockedData.StatutList.json", Encoding.UTF7); if (RequestResult.success) { StatutList = RequestResult.data; ContentVisible = true; RefreshBtnVisible = false; } else { if (StationDemandes.Count <= 0) { ContentVisible = false; RefreshBtnVisible = true; } AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
public async Task GetDemandesJsonData() { try { AppHelper.ALoadingShow("Chargement..."); var RequestResult = await AppHelper.ReadFromJson <ObservableCollection <DemandeModel> >("Assets.MockedData.StationHistorique.json"); if (RequestResult.success) { //StationDemandes = RequestResult.data; foreach (var item in RequestResult.data) { StationDemandes.Add(item); } ContentVisible = true; RefreshBtnVisible = false; } else { if (StationDemandes.Count <= 0) { ContentVisible = false; RefreshBtnVisible = true; } AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
private async void Login_Clicked(object sender, EventArgs e) { Application.Current.MainPage = new NavigationPage(new Home()); return; try { LoginInputs = new LoginModel { UserName = UserName.Text, Password = Password.Text }; if (Helpers.AppHelper.IsLoginValid(LoginInputs)) { #region Web Service Call with activity indicator AppHelper.ALoadingShow("Connexion..."); var loginResult = await ApiCalls.Login(LoginInputs); #endregion #region web service response is null or error if (!string.IsNullOrWhiteSpace(loginResult?.Error)) { if (!string.IsNullOrWhiteSpace(loginResult?.ErrorDescription)) { //AppHelper.AToast(loginResult?.ErrorDescription); return; await App.Current.MainPage.DisplayAlert("Erreur de login", loginResult?.ErrorDescription, "ok"); return; } if (!string.IsNullOrWhiteSpace(loginResult?.Error)) { //AppHelper.AToast(loginResult?.Error); return; await App.Current.MainPage.DisplayAlert("Erreur de login", loginResult?.Error, "ok"); return; } } #endregion #region is generated token valid //var isTokenValid = Helperino.AAreInputsNullOrEmpty(new string[] { loginResult.AccessToken }); if (string.IsNullOrWhiteSpace(loginResult?.AccessToken) || string.IsNullOrEmpty(loginResult?.AccessToken)) { await App.Current.MainPage.DisplayAlert("Erreur de login", $"Invalid token", "ok"); return; } #endregion #region Fill user settings info //AppSettings.RefreshToken = loginResult.RefreshToken; AppSettings.AccessToken = loginResult.AccessToken; AppSettings.UserId = loginResult.UserId; AppSettings.ValidUntil = DateTime.Now.AddSeconds(loginResult.ExpiresIn).ToString(); AppSettings.FullName = loginResult.FullName; AppSettings.UserRoles = loginResult.UserRoles; AppSettings.Email = loginResult.email; AppSettings.Phone = loginResult.phone; #endregion #region Set isLoggedIn variable to true & go to homepage AppSettings.isLoggedIn = true; Application.Current.MainPage = new NavigationPage(new Home()); #endregion } } catch (Exception ex) { //await App.Current.MainPage.DisplayAlert("Erreur de login", ex.Message, "ok"); await App.Current.MainPage.DisplayAlert("Erreur de login", Assets.Strings.ErreurMessage, "ok"); } finally { AppHelper.ALoadingHide(); } //Application.Current.MainPage = new NavigationPage(new Home()); }
private async Task OnSubmitForm() { // Date Format to send 2020-12-04 15:10 try { if (PrixTypes.Count == 0) { return; } bool _priceValidation = false; foreach (var prix in PrixTypes) { if (!(string.IsNullOrEmpty(prix.montant) || double.Parse(prix.montant) == 0)) { _priceValidation = true; break; } } if (!_priceValidation) { AppHelper.ASnack(message: Assets.Strings.ErreurEmptyPriceMessage, type: SnackType.Warning); return; } if (!DateInput.HasValue) { AppHelper.ASnack(message: Assets.Strings.ErreurDateApplicationEmpty, type: SnackType.Warning); return; } AppHelper.ALoadingShow("Chargement..."); DateTime FinalApplicationDateTime = new DateTime(((DateTime)DateInput).Year, ((DateTime)DateInput).Month, ((DateTime)DateInput).Day, TimeInput.Hours, TimeInput.Minutes, TimeInput.Seconds); DemandeInputs.dateapplication = FinalApplicationDateTime; foreach (var prix in PrixTypes) { if (prix?.montant != null) { DemandeInputs.demandePrix.Add(new PrixTypeItem { prixType_id = prix.id, montant = double.Parse(prix.montant) }); } } // Post Demande to API //var RequestResult = await ApiCalls.SaveNewDemande(DemandeInputs); // Get data from Local JSON var RequestResult = await AppHelper.ReadFromJson <DemandeModel>("Assets.MockedData.AddNewDemandeResponse.json"); if (RequestResult.success) { //string jsonString = JsonConvert.SerializeObject(RequestResult.data, Formatting.Indented); //await Application.Current.MainPage.DisplayAlert("Data", jsonString, "Ok"); AppHelper.ASnack(message: RequestResult.message, type: SnackType.Success); await Application.Current.MainPage.Navigation.PopAsync(); } else { AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
private async Task GetFilteredDemandes(FilterStationDemandesModel FilterStationDemandes, int page) { try { //if ( // FilterStationDemandes.StartDate == default && // FilterStationDemandes.EndDate == default && // string.IsNullOrEmpty(FilterStationDemandes?.StatutId)) //{ // return; //} //if (FilterStationDemandes?.StartDate == null && FilterStationDemandes?.EndDate == null && string.IsNullOrEmpty(FilterStationDemandes?.StatutId)) if (page < _filterLastPage || _filterLastPage == 0) { AppHelper.ALoadingShow("Chargement..."); var RequestResult = new RESTServiceResponse <PaginateDemandeModel>(); if (Offset != 0) { RequestResult = await ApiCalls.FilterStationDemandes(page, FilterStationDemandes, Offset); } else { RequestResult = await ApiCalls.FilterStationDemandes(page, filterStationDemandes : FilterStationDemandes); } if (RequestResult.success) { _filterCurentPage = RequestResult.data.current_page; _filterLastPage = RequestResult.data.last_page; if (_filterCurentPage == 1) { StationDemandes.Clear(); } if (RequestResult.data.data.Count == 0) { RefreshBtnVisible = true; ContentVisible = false; } else { foreach (var item in RequestResult.data.data) { StationDemandes.Add(item); } ContentVisible = true; RefreshBtnVisible = false; } _filterCurentPage++; } else { if (StationDemandes.Count <= 0) { ContentVisible = false; RefreshBtnVisible = true; } AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } else { AppHelper.ASnack(message: Assets.Strings.NoMoreResultMessage, type: SnackType.Info); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }
private async Task GetDemandes(int page) { try { if (page < _lastPage || _lastPage == 0) { AppHelper.ALoadingShow("Chargement..."); var RequestResult = new RESTServiceResponse <PaginateDemandeModel>(); if (Offset != 0) { RequestResult = await ApiCalls.GetStationDemandes(page, Offset); } else { RequestResult = await ApiCalls.GetStationDemandes(page); } if (RequestResult.success) { _curentPage = RequestResult.data.current_page; _lastPage = RequestResult.data.last_page; if (RequestResult.data.data.Count == 0) { RefreshBtnVisible = true; ContentVisible = false; } else { foreach (var item in RequestResult.data.data) { StationDemandes.Add(item); } ContentVisible = true; RefreshBtnVisible = false; } } else { if (StationDemandes.Count <= 0) { ContentVisible = false; RefreshBtnVisible = true; } AppHelper.ASnack(message: RequestResult.message, type: SnackType.Error); } } else { AppHelper.ASnack(message: Assets.Strings.NoMoreResultMessage, type: SnackType.Info); } } catch (Exception ex) { AppHelper.ASnack(message: Assets.Strings.ErreurMessage, type: SnackType.Error); } finally { AppHelper.ALoadingHide(); } }