Example #1
0
        private async Task InitializeAsync()
        {
            try
            {
                var isExist = await CredentialsService.DoCredentialsExist();

                if (isExist)
                {
                    var account = await CredentialsService.GetAccount();

                    var data = JsonConvert.DeserializeObject <Member>(account.Properties["Member"]);
                    App.LoginResponse = data;

                    if (App.LoginResponse == null)
                    {
                        LoginResponse = new Models.LoginResponse.Member();
                        TrainerData   = new Models.LoginResponse.Member();
                        await CredentialsService.DeleteCredentials();

                        MainPage = new HanselmanNavigationPage(new Views.SelectionPage());

                        return;
                    }

                    if (App.LoginResponse.Email == null)
                    {
                        LoginResponse = new Models.LoginResponse.Member();
                        TrainerData   = new Models.LoginResponse.Member();
                        await CredentialsService.DeleteCredentials();

                        MainPage = new HanselmanNavigationPage(new Views.SelectionPage());

                        return;
                    }

                    App.SelectedView = account.Properties["UserType"];
                    if (account.Properties.ContainsKey("FacebookUser"))
                    {
                        var fbData = JsonConvert.DeserializeObject <FacebookUser>(account.Properties["FacebookUser"]);
                        App.FacebookUser = fbData;
                    }
                    if (account.Properties.ContainsKey("InstagramUser"))
                    {
                        var instaData = JsonConvert.DeserializeObject <InstagramUser>(account.Properties["InstagramUser"]);
                        App.InstagramUser = instaData;
                    }
                    //if (account.Properties.ContainsKey("InstgramMedia"))
                    //{
                    //    var instaMedia = JsonConvert.DeserializeObject<InstagramMedia>(account.Properties["InstgramMedia"]);
                    //    App.InstagramMedia = instaMedia;
                    //}
                    MainPage = new NavigationPage(new RootPage(App.SelectedView));
                }
                else
                {
                    LoginResponse = new Models.LoginResponse.Member();
                    TrainerData   = new Models.LoginResponse.Member();
                }
            }
            catch (Exception ex)
            {
                await CredentialsService.DeleteCredentials();

                MainPage = new HanselmanNavigationPage(new Views.SelectionPage());
            }
        }
Example #2
0
        public App()
        {
            try
            {
                InitializeComponent();
                var ignore = new CircleTransformation();
                FlowListView.Init();

                TodoManager = new TodoItemManager(new HTTPService());

                DatabaseManager = new Service.DatabaseManager(new DatabaseService());

                MainPage = new HanselmanNavigationPage(new Views.SelectionPage());


                var isExist = CredentialsService.DoCredentialsExist();
                if (isExist)
                {
                    var account = CredentialsService.GetAccount();
                    var data    = JsonConvert.DeserializeObject <Member>(account.Properties["Member"]);
                    App.LoginResponse = data;

                    if (App.LoginResponse == null)
                    {
                        LoginResponse = new Models.LoginResponse.Member();
                        TrainerData   = new Models.LoginResponse.Member();
                        CredentialsService.DeleteCredentials();
                        MainPage = new HanselmanNavigationPage(new Views.SelectionPage());

                        return;
                    }

                    if (App.LoginResponse.Email.Equals(null))
                    {
                        CredentialsService.DeleteCredentials();
                    }

                    App.SelectedView = account.Properties["UserType"];
                    if (account.Properties.ContainsKey("FacebookUser"))
                    {
                        var fbData = JsonConvert.DeserializeObject <FacebookUser>(account.Properties["FacebookUser"]);
                        App.FacebookUser = fbData;
                    }
                    if (account.Properties.ContainsKey("InstagramUser"))
                    {
                        var instaData = JsonConvert.DeserializeObject <InstagramUser>(account.Properties["InstagramUser"]);
                        App.InstagramUser = instaData;
                    }
                    //if (account.Properties.ContainsKey("InstgramMedia"))
                    //{
                    //    var instaMedia = JsonConvert.DeserializeObject<InstagramMedia>(account.Properties["InstgramMedia"]);
                    //    App.InstagramMedia = instaMedia;
                    //}
                    MainPage = new NavigationPage(new RootPage(App.SelectedView));
                }
                else
                {
                    LoginResponse = new Models.LoginResponse.Member();
                    TrainerData   = new Models.LoginResponse.Member();
                }

                //FacebookProfile = new Models.FacebookProfile();
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                CredentialsService.DeleteCredentials();
                MainPage = new HanselmanNavigationPage(new Views.SelectionPage());
            }
        }