示例#1
0
 public Login(MainWindowVM mainWindowVM, UserRestClient userRest)
 {
     InitializeComponent();
     mainVM         = mainWindowVM;
     userRestClient = userRest;
     mainVM.ShowButtons();
 }
示例#2
0
        public static RestServiceClientBase GetRestClient(string type)
        {
            RestServiceClientBase restClient = null;

            switch (type)
            {
            case "OrganizationRestClient":
                restClient = new OrganizationRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "PaymentReportsRestClient":
                restClient = new PaymentReportsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "OrdersRestClient":
                restClient = new OrdersRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ReportsRestClient":
                restClient = new ReportsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ContractsRestClient":
                restClient = new ContractsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "PaymentsRestClient":
                restClient = new PaymentsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "UserRestClient":
                restClient = new UserRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "ReferencesRestClient":
                restClient = new ReferencesRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "SiteRestClient":
                restClient = new SiteRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "OrdersDocumentsRestClient":
                restClient = new OrdersDocumentsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "FlightsRestClient":
                restClient = new FlightsRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            case "SystemRestClient":
                restClient = new SystemRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);
                break;

            default:
                throw new Exception("RestClient type was set incorrectly.");
            }
            restClient.ImpersonationToken = new ImpersonationToken(Config.UserLogin, Config.UserPassword);
            return(restClient);
        }
示例#3
0
        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()));
        }
示例#4
0
        private UserRestClient CreateRestClient()
        {
            var restClient = new UserRestClient(Config.Url, Config.SiteSlug, Config.ApiKey);

            restClient.ImpersonationToken = new ImpersonationToken(Config.UserLogin, Config.UserPassword);

            return(restClient);
        }
示例#5
0
        public async void EmailVerified()
        {
            UserRestClient           userRC        = new UserRestClient();
            RestClient <Address>     addressRC     = new RestClient <Address>();
            RestClient <PhoneNumber> phoneNumberRC = new RestClient <PhoneNumber>();

            Address address = new Address()
            {
                Number  = Int32.Parse(Number.Text),
                Street  = Street.Text,
                City    = City.Text,
                State   = State.Text,
                Country = Country.Text,
                ZipCode = Int32.Parse(ZipCode.Text)
            };

            address = await addressRC.PostAsync(address);

            if (address == null)
            {
                return;
            }
            User user = new User()
            {
                Name       = Name.Text.ToLower(),
                LastName   = LastName.Text.ToLower(),
                Email      = Email.Text.ToLower(),
                Password   = Password.Text,
                Address_FK = address.ID
            };

            foreach (StackLayout s in PhoneNumberStackLayouts)
            {
                if ((s.Children[0] as Entry).Text != "")
                {
                    PhoneNumber p = new PhoneNumber()
                    {
                        Number             = (s.Children[0] as Entry).Text,
                        PhoneNumberType_FK = (phoneNumberTypes.ElementAt((s.Children[1] as Picker).SelectedIndex)).ID,
                    };
                    user.PhoneNumbers.Add(p);
                }
            }
            user = await userRC.PostAsync(user);

            if (user != null)
            {
                var page = new MainPage();
                page.SignInAction(user.Email, user.Password);
                App.Current.MainPage = new NavigationPage(page);
            }
            else
            {
                await DisplayAlert("Erreur", "Une erreur s'est produite lors de l'enregistrement des informations!", "Ok");

                return;
            }
        }
示例#6
0
 public Chat(MainWindowVM mainWindow, UserRestClient userRestClient)
 {
     InitializeComponent();
     chatVM                 = new ChatVM(userRestClient.CurrentUser, mainWindow);
     this.DataContext       = chatVM;
     restClient             = userRestClient;
     chatVM.CurrentContacts = userRestClient.GetAllContacts(userRestClient.CurrentUser.Id);
     chatVM.CurrentView     = new ChatList(userRestClient.CurrentUser, chatVM);
     this.mainWindowVM      = mainWindow;
 }
示例#7
0
        public MainWindow()
        {
            userRestClient = new UserRestClient();
            InitializeComponent();
            mainWindowVM = new MainWindowVM(this);
            Login login = new Login(mainWindowVM, userRestClient);

            mainWindowVM.CurrentControl = login;
            this.DataContext            = mainWindowVM;
        }
示例#8
0
        public async void UpdateOrderNotificationNumber()
        {
            UserRestClient userRC = new UserRestClient();

            user = await userRC.GetAsyncById(App.Connected.Id);

            if (user == null)
            {
                return;
            }
            int number = user.Orders.Count(o => !o.SeenUser);

            NorificationsNumber.Source = "_" + (number != 0 ? (number > 9 ? "9plus.png" : number + ".png") : "");
        }
示例#9
0
        private void Click_Login(object sender, RoutedEventArgs e)
        {
            UserRestClient userRestClient = new UserRestClient(-1);

            //usernameTextbox.Text
            //passwordTextbox.Password.ToString()
            if (userRestClient.Login("admin", "admin"))
            {
                mainVM.CurrentControl = new Editor(userRestClient.CurrentUser);
            }
            else
            {
                errorLabel.Content = "Credentials are invalid!";
            }
        }
示例#10
0
        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()));
        }
示例#11
0
        private async void load()
        {
            UserRestClient userRestClient = new UserRestClient();

            user = await userRestClient.GetAsyncById(App.Connected.Id);

            if (user == null)
            {
                return;
            }
            Name.Text        = user.Name;
            LastName.Text    = user.LastName;
            Email.Text       = user.Email;
            Password.Text    = user.Password;
            Address.ClassId  = user.Address_FK.ToString();
            Number.Text      = user.Address.Number.ToString();
            Street.Text      = user.Address.Street;
            City.Text        = user.Address.City;
            ZipCode.Text     = user.Address.ZipCode.ToString();
            State.Text       = user.Address.State;
            Country.Text     = user.Address.Country;
            phoneNumberTypes = await phoneNumberTypeRC.GetAsync();

            if (phoneNumberTypes == null)
            {
                return;
            }
            foreach (var phoneNumber in user.PhoneNumbers)
            {
                StackLayout phoneNumberStackLayout = CreatePhoneNumberStackLayout(phoneNumber);
                PhoneNumberStackLayouts.Add(phoneNumberStackLayout);
            }
            StackLayout lastPhoneNumberStackLayout = CreatePhoneNumberStackLayout(null);

            PhoneNumberStackLayouts.Add(lastPhoneNumberStackLayout);
        }
示例#12
0
        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();
                }
            }
        }
示例#13
0
        public async void EmailVerified()
        {
            await PopupNavigation.PushAsync(new LoadingPopupPage());

            UserRestClient       userRC    = new UserRestClient();
            RestClient <Address> addressRC = new RestClient <Address>();
            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;
            }

            User user = new User()
            {
                ID         = this.user.ID,
                Name       = Name.Text.ToLower(),
                LastName   = LastName.Text.ToLower(),
                Email      = Email.Text.ToLower(),
                Password   = Password.Text,
                Address_FK = address.ID
            };

            if (!(await userRC.PutAsync(user.ID, user)))
            {
                return;
            }
            RestClient <PhoneNumber> phoneNumberRestClient = new RestClient <PhoneNumber>();

            foreach (var removedPhoneNumber in removedPhoneNumbers)
            {
                if (!(await phoneNumberRestClient.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 phoneNumberRestClient.PutAsync(p.ID, p)))
                        {
                            return;
                        }
                    }
                    else
                    {
                        p.User = user;
                        if (await phoneNumberRestClient.PostAsync(p) == null)
                        {
                            return;
                        }
                    }
                }
            }
            await DisplayAlert("Succées", "Votre profil à été mis à jour!", "Ok");

            await PopupNavigation.PopAllAsync();

            await Navigation.PopAsync();
        }
示例#14
0
 public Register(MainWindowVM mainWindowVM, UserRestClient userRestClient)
 {
     InitializeComponent();
     this.mainWindowVM   = mainWindowVM;
     this.userRestClient = userRestClient;
 }