Esempio n. 1
0
        public async Task <bool?> Login(string email, string hash)
        {
            IsBusy = true;
            return(await Task.Run(new Func <bool?>(() =>
            {
                try
                {
                    IEnumerable <People> list = _peopleController.GetAllEntries().Result;
                    if (list == null)
                    {
                        ErrorDialog("No user found please register", "login failed");
                        return null;
                    }
                    foreach (People item in list)
                    {
                        if (item.Email?.ToLower() == email?.ToLower())
                        {
                            if (item.PasswordHash != hash)
                            {
                                ErrorDialog("Wrong password", "login failed");
                                return false;
                            }
                            Services.LocalData.SaveLoginInfo(item);

                            IsBusy = false;
                            IsLoggedIn = true;
                            CurrentLoginInfo = item;
                            Reservations.Clear();
                            AvailableReservations.Clear();
                            //Initialize();
                            Toast = "Loading";
                            RecordEvent("Login", "Login detected on device " + ServicesInterfaces.GetDeviceServices()?.GetDeviceName());

                            return true;
                        }
                    }
                    ErrorDialog("No account found please register", "login faild");
                    return null;
                }
                catch (Exception e)
                {
                    ErrorDialog("Please check you network \n" + e.Message, "connection faild");

                    return false;
                }
                finally
                {
                    IsBusy = false;
                }
            })));
        }
Esempio n. 2
0
 private void ErrorDialog(string value, string title = "Error")
 {
     ServicesInterfaces.GetDialogService()?.ShowDialog(title, value);
 }