public MDPageViewModel(INavigation Navigation) : base(Navigation) { menuItems = new List <HomeMenuItem> { new HomeMenuItem { Id = MenuItemType.AnnounceList, Title = MyAppRessources.ItemMenu1, Icon = "IconMenu1", IsEnable = true }, new HomeMenuItem { Id = MenuItemType.AnnounceDeposit, Title = MyAppRessources.ItemMenu2, Icon = "IconMenu2", IsEnable = true }, new HomeMenuItem { Id = MenuItemType.Messages, Title = MyAppRessources.ItemMenu3, Icon = "IconMenu3", IsEnable = true } }; LogoutCommand = new Command(ExecuteLogoutCommand); if (Settings.IsUserConnected) { Task.Factory.StartNew(async() => { TitouisListingWebServices client = new TitouisListingWebServices(); var user = await client.APIV2_GetMyAccount(); UserName = user.Email; Settings.UserID = user.Id.Oid; //Fake, no image in the API UserImage = ImageSource.FromUri(new Uri("http://www.sefairepayer.com/images/profils-debiteur/profil-irreductible.png")); }); } }
private async Task ExecuteLoginCommand() { if (IsBusy) { return; } IsBusy = true; try { // if (!String.IsNullOrWhiteSpace(Login) && !String.IsNullOrWhiteSpace(Password)) { Settings.Login = Login; Settings.Pwd = Password; Settings.TokenAPI = String.Empty; TitouisListingWebServices client = new TitouisListingWebServices(); var result = await client.APIV2_AuthenticateUser(); if (result) { ErrorMessage = ""; ((TitouisApp)Application.Current).DisplayHome(); } else { ErrorMessage = MyAppRessources.LoginPage_LblError_Unknown; } } else { ErrorMessage = MyAppRessources.LoginPage_LblError_Uncomplete; } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExecuteSubmitCommand() { IsBusy = true; try { double price = 0; if (!String.IsNullOrWhiteSpace(Titre) && !String.IsNullOrWhiteSpace(Description) && !String.IsNullOrWhiteSpace(Prix) && Double.TryParse(Prix, out price)) { Product product = new Product(); product.Name = Titre; product.Description = Description; product.Price = price; TitouisListingWebServices client = new TitouisListingWebServices(); var result = await client.APIV2_PostAnnounce(product); if (result) { //Post OK, on revient à l'écran précédent ErrorMessage = ""; await NavigationService.PopAsync(); } else { ErrorMessage = "Erreur, veuillez ressayer !"; } } else { ErrorMessage = "Les renseignement ne sont pas corrects, veuillez vérifier votre saisie."; } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task <Product[]> GetItemsAsync(bool forceRefresh = false) { TitouisListingWebServices WSclient = new TitouisListingWebServices(); return(await WSclient.APIV2_GetAnnounces()); }
public async Task <Product> GetItemAsync(string id) { TitouisListingWebServices WSclient = new TitouisListingWebServices(); return(await WSclient.APIV2_GetAnnounce(id)); }