Ejemplo n.º 1
0
        public App()
        {
            apiService        = new ApiService();
            dialogService     = new DialogService();
            navigationService = new NavigationService();
            dataService       = new DataService();

            InitializeComponent();

            var token = dataService.First <TokenResponse>(false);

            if (token != null &&
                token.IsRemembered &&
                token.Expires > DateTime.Now)
            {
                var mainViewModel = MainViewModels.GetInstance();
                mainViewModel.Token      = token;
                mainViewModel.Categories = new CategoriesViewModel();
                navigationService.SetMainPage("MasterView");
            }
            else
            {
                navigationService.SetMainPage("LoginView");
            }
        }
Ejemplo n.º 2
0
        async void Navigate()
        {
            switch (PageName)
            {
            case "LoginView":
                var mainViewModel = MainViewModels.GetInstance();
                mainViewModel.Token.IsRemembered = false;
                dataService.Update(mainViewModel.Token);
                mainViewModel.Login = new LoginViewModel();
                navigationService.SetMainPage(PageName);
                break;

            case "UbicationsView":
                MainViewModels.GetInstance().Ubications =
                    new UbicationsViewModel();
                await navigationService.NavigateOnMaster(PageName);

                break;

            case "SyncView":
                MainViewModels.GetInstance().Sync =
                    new SyncViewModel();
                await navigationService.NavigateOnMaster(PageName);

                break;

            case "MyProfileView":
                MainViewModels.GetInstance().MyProfile =
                    new MyProfileViewModel();
                await navigationService.NavigateOnMaster(PageName);

                break;
            }
        }
Ejemplo n.º 3
0
        async void SelectCategory()
        {
            var mainViewModel = MainViewModels.GetInstance();

            //Mantenemos en memoria la category seleccionada
            mainViewModel.Category = this;
            mainViewModel.Products = new ProductsViewModel(Products);
            await navigationService.NavigateOnMaster("ProductsView");
        }
Ejemplo n.º 4
0
        public App()
        {
            InitializeComponent();

            if (Settings.IsRemembered && string.IsNullOrEmpty(Settings.AccessToken))
            {
                MainViewModels.GetInstance().Products = new ProductsViewModel();
                MainPage = new NavigationPage(new ProductsPage());
            }
            else
            {
                MainViewModels.GetInstance().Login = new LoginViewModel();
                MainPage = new NavigationPage(new LoginPage());
            }
        }
Ejemplo n.º 5
0
        private async void Save()
        {
            string x = DateTime.Now.ToString("yyyy:MM:dd:HH:mm:ss");

            UserDialogs.Instance.ShowLoading("Espere");
            stream?.Seek(0, SeekOrigin.Begin);
            await ServiceWebApi.UpdateUser(App.User, stream, x);

            App.User = await ServiceWebApi.GetUser(App.User.IdUser.Value, x);

            UserDialogs.Instance.HideLoading();
            MainViewModels.GetInstance().Home = new HomeViewModel();
            await App.Current.MainPage.DisplayAlert("Información", "Perfil actualizado", "Aceptar");

            await App.Current.MainPage.Navigation.PopAsync();
        }
Ejemplo n.º 6
0
        public async static void LoginFacebookSuccess(FacebookResponse profile)
        {
            if (profile == null)
            {
                Current.MainPage = new NavigationPage(new LoginView());
                return;
            }

            var apiService    = new ApiService();
            var dialogService = new DialogService();

            var checkConnetion = await apiService.CheckConnection();

            if (!checkConnetion.IsSuccess)
            {
                await dialogService.ShowMessage("Error", checkConnetion.Message);

                return;
            }

            var urlAPI = Application.Current.Resources["URLAPI"].ToString();
            var token  = await apiService.LoginFacebook(
                urlAPI,
                "/api",
                "/Customers/LoginFacebook",
                profile);

            if (token == null)
            {
                await dialogService.ShowMessage(
                    "Error",
                    "Problem ocurred retrieving user information, try latter.");

                Current.MainPage = new NavigationPage(new LoginView());
                return;
            }

            var mainViewModel = MainViewModels.GetInstance();

            mainViewModel.Token      = token;
            mainViewModel.Categories = new CategoriesViewModel();
            Current.MainPage         = new MasterView();
        }
Ejemplo n.º 7
0
 async void Edit()
 {
     MainViewModels.GetInstance().EditProduct = new EditProductViewModel(this);
     await navigationService.NavigateOnMaster("EditProductView");
 }