public async void load() { CoreStackLayout.Children.Clear(); NoResultsLabel.IsVisible = false; LoadingLayout.IsVisible = true; Loading.IsRunning = true; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } LoadingLayout.IsVisible = false; Loading.IsRunning = false; if (pastryShop != null && pastryShop.PointOfSales.Count != 0) { NoResultsLabel.IsVisible = false; } else { NoResultsLabel.IsVisible = true; } foreach (PointOfSale p in pastryShop.PointOfSales) { CoreStackLayout.Children.Add(MakePointOfSaleStackLayout(p)); } }
public async void SubmitOnClick(Object sender, EventArgs e) { if (starIndex != 0) { PastryShop pastryShopTemp = new PastryShop() { ID = pastryShop.ID, Name = pastryShop.Name, Email = pastryShop.Email, Password = pastryShop.Password, Address_FK = pastryShop.Address_FK, ProfilePic = pastryShop.ProfilePic, CoverPic = pastryShop.CoverPic, PriceRange_FK = pastryShop.PriceRange_FK, LongDesc = pastryShop.LongDesc, ShortDesc = pastryShop.ShortDesc, NumberOfRatings = ++pastryShop.NumberOfRatings, RatingSum = pastryShop.RatingSum + starIndex, }; var x = pastryShopTemp; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); if (!(await pastryShopRC.PutAsync(pastryShop.ID, pastryShopTemp))) { ; } Load(true); ResetToolbar(); } else { ReactionLabel.Text = "Select a star!"; } }
private async void ComfirmTapped(object sender, EventArgs e) { if (string.IsNullOrEmpty(Email.Text)) { return; } if (!App.isValidEmail(Email.Text.ToLower())) { await DisplayAlert("Erreur", "Adresse email invalide", "Ok"); return; } Email.IsEnabled = false; ComfirmLabel.IsEnabled = false; ComfirmLabel.TextColor = Color.DarkGray; Indicator.IsVisible = true; Indicator.IsRunning = true; var userRC = new UserRestClient(); var pastryShopRC = new PastryShopRestClient(); if ((await userRC.GetAsyncByEmail(Email.Text.ToLower()) == null) && (await pastryShopRC.GetAsyncByEmail(Email.Text.ToLower()) == null)) { await DisplayAlert("Erreur", "Utilisateur inexistant!", "Ok"); await PopupNavigation.PopAsync(); return; } await PopupNavigation.PopAsync(); await PopupNavigation.PushAsync(new PasswordResetCodeVerification(Email.Text.ToLower())); }
public async void Reload() { PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } Load(); }
public async void UpdateOrderNotificationNumber() { PastryShopRestClient pastryShopRestClient = new PastryShopRestClient(); pastryShop = await pastryShopRestClient.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } int number = pastryShop.Orders.Count(o => !o.SeenPastryShop); NorificationsNumber.Source = "_" + (number != 0 ? (number > 9 ? "9plus.png" : number + ".png") : ""); }
public async void Load(bool reload) { if (reload) { var pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } } CoreStackLayout.Children.Clear(); pastryShop.PointOfSales.ToList().ForEach(p => CoreStackLayout.Children.Add(MakePointOfSaleStackLayout(p))); }
private async void Apply(object sender, EventArgs e) { if (!newSelectedCategories.Any() && !toRemoveCategories.Any()) { await PopupNavigation.PopAsync(); return; } if (!allSelectedCategories.Any()) { await DisplayAlert("Erreur", "Au moins une catégorie doit être selectionné!", "Ok"); return; } await PopupNavigation.PushAsync(new LoadingPopupPage()); pastryShop.Categories.ToList().ForEach(c => c.PastryShops.Clear()); newSelectedCategories.ForEach(c => c.PastryShops.Clear()); PastryShop p = new PastryShop() { ID = pastryShop.ID, Name = pastryShop.Name, Email = pastryShop.Email, Password = pastryShop.Password, ShortDesc = pastryShop.ShortDesc, LongDesc = pastryShop.LongDesc, CoverPic = pastryShop.CoverPic, ProfilePic = pastryShop.ProfilePic, PriceRange_FK = pastryShop.PriceRange_FK, Address_FK = pastryShop.Address_FK, NumberOfRatings = pastryShop.NumberOfRatings, RatingSum = pastryShop.RatingSum, Categories = pastryShop.Categories }; toRemoveCategories.ForEach(rc => p.Categories.Remove(p.Categories.FirstOrDefault(c => c.ID == rc.ID))); newSelectedCategories.ForEach(sc => p.Categories.Add(sc)); var pastryShopRC = new PastryShopRestClient(); if (await pastryShopRC.PutAsyncCategories(p.ID, p)) { await DisplayAlert("Succées", "Liste de catégories mise à jours!", "Ok"); editProfileInfo.UpdateParent = true; editProfileInfo.load(); await PopupNavigation.PopAsync(); } }
public async void Load(bool reloadParentval) { this.reloadParent = reloadParentval; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(App.Connected.Id); if (pastryShop == null) { return; } ContentLayout.Children.Clear(); foreach (var pastryShopDeleveryMethod in pastryShop.PastryShopDeleveryMethods) { ContentLayout.Children.Add(MakeDeleveryMethodLayout(pastryShopDeleveryMethod)); } }
public async void ConfirmBt_Clicked(object sender, EventArgs e) { if (!await valid()) { return; } UserRestClient userRC = new UserRestClient(); PastryShopRestClient pastryShopRC = new PastryShopRestClient(); if ((await userRC.GetAsyncByEmail(Email.Text.ToLower()) != null) || (await pastryShopRC.GetAsyncByEmail(Email.Text.ToLower()) != null)) { await DisplayAlert("Erreur", "Cette adresse email est déjà utilisée!", "Ok"); Email.Text = ""; return; } await PopupNavigation.PushAsync(new EmailVerificationPopupPage(this, Email.Text.ToLower())); }
public async void load() { PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(App.Connected.Id); if (pastryShop == null) { return; } phoneNumberTypes = await phoneNumberTypeRC.GetAsync(); priceRanges = await priceRangeTypeRC.GetAsync(); if (phoneNumberTypes == null || priceRanges == null) { return; } PriceRange.ItemsSource = priceRanges; Name.Text = pastryShop.Name; Email.Text = pastryShop.Email; Password.Text = pastryShop.Password; ShortDesc.Text = pastryShop.ShortDesc; LongDesc.Text = pastryShop.LongDesc; LongDesc.TextColor = Color.Black; PriceRange.SelectedIndex = priceRanges.IndexOf(priceRanges.FirstOrDefault(pr => pr.ID == pastryShop.PriceRange_FK)); Address.ClassId = pastryShop.Address_FK.ToString(); Number.Text = pastryShop.Address.Number.ToString(); Street.Text = pastryShop.Address.Street; City.Text = pastryShop.Address.City; ZipCode.Text = pastryShop.Address.ZipCode.ToString(); State.Text = pastryShop.Address.State; Country.Text = pastryShop.Address.Country; foreach (var phoneNumber in pastryShop.PhoneNumbers) { StackLayout phoneNumberStackLayout = CreatePhoneNumberStackLayout(phoneNumber); PhoneNumberStackLayouts.Add(phoneNumberStackLayout); } StackLayout lastPhoneNumberStackLayout = CreatePhoneNumberStackLayout(null); PhoneNumberStackLayouts.Add(lastPhoneNumberStackLayout); }
public async void load() { NoResultsLabel.IsVisible = false; Liste.ItemsSource = null; LoadingLayout.IsVisible = true; Loading.IsRunning = true; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } if (pastryShop.Products.Count == 0) { NoResultsLabel.IsVisible = true; } LoadingLayout.IsVisible = false; Loading.IsRunning = false; Liste.ItemsSource = pastryShop.Products; }
private async void DeleteBt_Clicked(object sender, EventArgs e) { if (pastryShop.Orders.Any(o => (o.Status_FK != 5 && o.Status_FK != 3))) { await DisplayAlert("Erreur", "Impossible de supprimer votre compte, une ou plusieurs commandes ne sont pas encore réglées!", "Ok"); return; } await DisplayAlert("Confirmation", "Etes vous sure de vouloire supprimer votre compte?", "Oui", "Annuler"); var pastryShopRC = new PastryShopRestClient(); if (await pastryShopRC.DeleteAsync(pastryShop.ID)) { await DisplayAlert("Succées", "Votre Compte a été supprimer.\n", "Ok"); App.Logout(); } }
public async void load(bool reload) { if (reload) { ListLayout.IsVisible = false; LoadingLayout.IsVisible = true; Loading.IsRunning = true; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); if (pastryShop == null) { return; } Loading.IsRunning = false; LoadingLayout.IsVisible = false; } displayedProducts.Clear(); pastryShop.Products.OrderBy(p => p.Name).ToList().ForEach(p => displayedProducts.Add(p)); selectedSortType.SortTypeIndex = 0; selectedSortType.IsAsc = true; selectedPriceRange.MaxPriceRange = maxPriceRange.MaxPriceRange = pastryShop.Products.Max(p => p.Price); selectedPriceRange.MinPriceRange = maxPriceRange.MinPriceRange = pastryShop.Products.Min(p => p.Price); }
private async void NextBt_Clicked(object sender, EventArgs e) { List <PastryShopDeleveryMethod> PSdeleveryMethods = new List <PastryShopDeleveryMethod>(); foreach (deleveryMethodLocal delevery in localDeleveryMethods) { if (delevery.selectedPayments.Count != 0) { PastryShopDeleveryMethod psdm = PSdeleveryMethods.FirstOrDefault(p => p.DeleveryMethod_FK == delevery.selectedDeleveryMethod.ID); if (psdm == null) { psdm = new PastryShopDeleveryMethod() { DeleveryDelay_FK = delevery.selectedDeleveryDelay.ID, DeleveryMethod_FK = delevery.selectedDeleveryMethod.ID, }; PSdeleveryMethods.Add(psdm); } foreach (Payment payment in delevery.selectedPayments) { PastryDeleveryPayment newPDP = new PastryDeleveryPayment { Payment_FK = payment.ID, PastryShopDeleveryMethod_FK = psdm.ID }; if (psdm.PastryDeleveryPayments.FirstOrDefault(x => x.Payment_FK == newPDP.Payment_FK) == null) { psdm.PastryDeleveryPayments.Add(newPDP); } } } } if (PSdeleveryMethods.Count == 0) { await DisplayAlert("Erreur", "Au moins une methode de livraison avec une methode de payment doit être fournit!", "Ok!"); return; } if (categorySwitchs.Count == 0) { await DisplayAlert("Erreur", "Au moins une catégorie doit être séléctionné!", "Ok!"); return; } else { foreach (int i in categorySwitchs) { pastry.Categories.Add(categoryList.FirstOrDefault(c => c.ID == i)); } } RestClient <Address> addressRC = new RestClient <Address>(); pastry.Address = await addressRC.PostAsync(pastry.Address); if (pastry.Address != null) { pastry.Address_FK = pastry.Address.ID; pastry.Address = null; PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastry = await pastryShopRC.PostAsync(pastry); if (pastry == null) { await DisplayAlert("Erreur", "Erreur lors de l'enregistrement des informations!", "Ok"); return; } else { RestClient <PastryDeleveryPayment> pastryDeleveryPaymentRC = new RestClient <PastryDeleveryPayment>(); foreach (PastryShopDeleveryMethod pastryShopDM in PSdeleveryMethods) { pastryShopDM.PastryShop_FK = pastry.ID; List <PastryDeleveryPayment> pastryDeleveryPayments = pastryShopDM.PastryDeleveryPayments.ToList(); pastryShopDM.PastryDeleveryPayments.Clear(); RestClient <PastryShopDeleveryMethod> pastryShopDeleveryMethodRC = new RestClient <PastryShopDeleveryMethod>(); PastryShopDeleveryMethod PSDM = await pastryShopDeleveryMethodRC.PostAsync(pastryShopDM); if (PSDM == null) { return; } foreach (PastryDeleveryPayment p in pastryDeleveryPayments) { //p.PastryShopDeleveryMethods.Add(pastryShopDM); p.PastryShopDeleveryMethod_FK = PSDM.ID; if (await pastryDeleveryPaymentRC.PostAsync(p) == null) { return; } } } await Navigation.PushAsync(new PastryShopEnteringMenu(pastry)); } } }
public async void SignInAction(string email, string password) { isLoading(true); UserRestClient userRC = new UserRestClient(); PastryShopRestClient pastryShopRC = new PastryShopRestClient(); User u; try { u = await userRC.GetAsyncByEmailAndPass(email, password); } catch (ConnectionLostException e) { isLoading(false); return; } if (u != null) { Connected connected = new Connected(); connected.type = typeof(User).Name; connected.Id = u.ID; connected.Email = u.Email; connected.Password = u.Password; App.Connected = connected; isLoading(false); Email.Text = ""; Password.Text = ""; //App.Current.MainPage = new UserMasterDetailPage(u); //switch (Device.RuntimePlatform) //{ // case Device.iOS: // App.Current.MainPage = new UserMasterDetailPage(u); // break; // case Device.Android: // App.Current.MainPage = new NavigationPage(new UserMasterDetailPage(u)); // break; // case Device.WinPhone: // case Device.Windows: // App.Current.MainPage = new NavigationPage(new UserMasterDetailPage(u)); // break; // default: // App.Current.MainPage = new NavigationPage(new UserMasterDetailPage(u)); // break; //} App.setMainPage(new UserMasterDetailPage(u)); } else { PastryShop p; try { p = await pastryShopRC.GetAsyncByEmailAndPass(email, password); } catch (ConnectionLostException e) { isLoading(false); return; } if (p != null) { Connected connected = new Connected(); connected.type = typeof(PastryShop).Name; connected.Id = p.ID; connected.Email = p.Email; connected.Password = p.Password; App.Connected = connected; isLoading(false); Email.Text = ""; Password.Text = ""; //App.Current.MainPage = new PastryShopMasterDetailPage(p); //switch (Device.RuntimePlatform) //{ // case Device.iOS: // App.Current.MainPage = new PastryShopMasterDetailPage(p); // break; // case Device.Android: // App.Current.MainPage = new NavigationPage(new PastryShopMasterDetailPage(p)); // break; // case Device.WinPhone: // case Device.Windows: // App.Current.MainPage = new NavigationPage(new PastryShopMasterDetailPage(p)); // break; // default: // App.Current.MainPage = new NavigationPage(new PastryShopMasterDetailPage(p)); // break; //} App.setMainPage(new PastryShopMasterDetailPage(p)); } else { isLoading(false); await DisplayAlert("Erreur", "Utilisateur inexistant", "OK"); Email.Focus(); } } }
public async void EmailVerified() { UpdateBt.IsEnabled = false; await PopupNavigation.PushAsync(new LoadingPopupPage()); PastryShopRestClient pastryShopRC = new PastryShopRestClient(); RestClient <Address> addressRC = new RestClient <Address>(); RestClient <PhoneNumber> phoneNumberRC = new RestClient <PhoneNumber>(); Address address = new Address() { ID = Int32.Parse(Address.ClassId), Number = Int32.Parse(Number.Text), Street = Street.Text, City = City.Text, State = State.Text, Country = Country.Text, ZipCode = Int32.Parse(ZipCode.Text) }; if (!(await addressRC.PutAsync(address.ID, address))) { return; } if (_mediaFileProfile != null) { string newURL = await Upload(_mediaFileProfile); if (!string.IsNullOrEmpty(newURL) && (await Delete(pastryShop.ProfilePic))) { pastryShop.ProfilePic = newURL; } } if (_mediaFileCover != null) { string newURL = await Upload(_mediaFileProfile); if (!string.IsNullOrEmpty(newURL) && (await Delete(pastryShop.CoverPic))) { pastryShop.CoverPic = newURL; } } PastryShop newPastryShop = new PastryShop() { ID = pastryShop.ID, Name = Name.Text, Email = Email.Text.ToLower(), Password = Password.Text, Address_FK = address.ID, LongDesc = LongDesc.Text, ShortDesc = ShortDesc.Text, PriceRange_FK = priceRanges.ElementAt(PriceRange.SelectedIndex).ID, NumberOfRatings = pastryShop.NumberOfRatings, RatingSum = pastryShop.RatingSum, ProfilePic = pastryShop.ProfilePic, CoverPic = pastryShop.CoverPic, }; if (!(await pastryShopRC.PutAsync(newPastryShop.ID, newPastryShop))) { return; } foreach (var removedPhoneNumber in removedPhoneNumbers) { if (!(await phoneNumberRC.DeleteAsync(removedPhoneNumber.ID))) { return; } } foreach (var phoneNumberStackLayout in PhoneNumberStackLayouts) { Entry phoneNumberEntry = (phoneNumberStackLayout.Children[0] as Entry); if (phoneNumberEntry.Text != "") { PhoneNumber p = new PhoneNumber() { Number = phoneNumberEntry.Text, PhoneNumberType_FK = (phoneNumberTypes.ElementAt((phoneNumberStackLayout.Children[1] as Picker).SelectedIndex)).ID, }; if (phoneNumberEntry.ClassId != "") { int phoneNumberID = Int32.Parse(phoneNumberEntry.ClassId); p.ID = phoneNumberID; if (!(await phoneNumberRC.PutAsync(p.ID, p))) { return; } } else { p.PastryShop = newPastryShop; if (await phoneNumberRC.PostAsync(p) == null) { return; } } } } await DisplayAlert("Succées", "Votre profil à été mis à jour!", "Ok"); await PopupNavigation.PopAsync(); UpdateParent = true; await Navigation.PopAsync(); }
private async void Load(bool reload) { if (reload) { PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(App.Connected.Id); if (pastryShop == null) { return; } } Rating.Text = pastryShop.Rating.ToString(); NumberOfReviews.Text = "(" + pastryShop.NumberOfRatings.ToString() + " avis)"; Cover.Source = pastryShop.CoverPic; ProfilImage.Source = pastryShop.ProfilePic; PastryName.Text = pastryShop.Name; Address.Text = pastryShop.Address.ToString(); Desc.Text = pastryShop.LongDesc; Email.Text = pastryShop.Email; PriceRange.Text = pastryShop.PriceRange.MinPriceRange + "-" + pastryShop.PriceRange.MaxPriceRange; PhoneNumbersLayout.Children.Clear(); foreach (PhoneNumber phone in pastryShop.PhoneNumbers) { Grid grid = new Grid() { RowDefinitions = { new RowDefinition() { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) } } }; grid.Children.Add(new Label() { Text = phone.Number, TextColor = Color.Black, FontSize = 18 }, 0, 0); grid.Children.Add(new Label() { Text = phone.PhoneNumberType.Type, TextColor = Color.Black, FontSize = 18 }, 1, 0); PhoneNumbersLayout.Children.Add(grid); } CategoriesLayout.Children.Clear(); foreach (var category in pastryShop.Categories) { CategoriesLayout.Children.Add(new Label() { Text = category.CategoryName, TextColor = Color.Black, FontSize = 18 }); } DeleveryMethodsLayout.Children.Clear(); float height = 0; foreach (var pastryShopDeleveryMethod in pastryShop.PastryShopDeleveryMethods) { height += 50; StackLayout paymentLayout = new StackLayout(); foreach (var pastryDeleveryPayment in pastryShopDeleveryMethod.PastryDeleveryPayments) { height += 40; paymentLayout.Children.Add(new Label() { Text = pastryDeleveryPayment.Payment.PaymentMethod, TextColor = Color.Black, FontSize = 15 }); } DeleveryMethodsLayout.Children.Add(new StackLayout() { Children = { new StackLayout() { Orientation = StackOrientation.Horizontal, Spacing = 20, Children = { new Label() { Text = "- " + pastryShopDeleveryMethod.DeleveryMethod.DeleveryType, TextColor = Color.Black, FontSize = 18 }, new StackLayout() { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.End, Children = { new Label() { Text = "Delais:", TextColor = Color.Black, FontSize = 15, FontAttributes = FontAttributes.Bold }, new Label() { Text = pastryShopDeleveryMethod.DeleveryDelay.ToString(), TextColor = Color.Black, FontSize = 15 } } } } }, new StackLayout() { Padding = new Thickness(30, 0, 0, 0), Orientation = StackOrientation.Horizontal, Children = { new Label() { Text = "Payment:", TextColor = Color.Black, FontSize = 15, FontAttributes = FontAttributes.Bold }, paymentLayout } } } }); } DeleveryMethodsLayout.HeightRequest = height; }
protected async override void OnAppearing() { PastryShopRestClient pastryShopRC = new PastryShopRestClient(); pastryShop = await pastryShopRC.GetAsyncById(pastryShop.ID); }