Exemplo n.º 1
0
        private async Task FetchApplicationDataAsync()
        {
            var webService = new OrlenWebService();
            var data       = await webService.GetBusStopsAsync(AppPropertiesService.GetToken());

            foreach (var item in data)
            {
                DbService.InserBusStop(item);
            }
            //var salon = await DataService.GetSalonAsync();
            //DbService.InsertSalon(salon);
            //var clients = await DataService.GetClientsAsync();
            //foreach (var item in clients)
            //{
            //    DbService.InsertClient(item);
            //}
        }
Exemplo n.º 2
0
        private async Task Login(User user)
        {
            if (!await AskForPermissionAsync())
            {
                return;
            }
            if (string.IsNullOrEmpty(user.Login) || string.IsNullOrEmpty(user.Password))
            {
                if (string.IsNullOrEmpty(user.Login))
                {
                    Device.BeginInvokeOnMainThread(() => MessagingCenter.Send <string>("OrlenLogin", "wrongLogin"));
                }
                if (string.IsNullOrEmpty(user.Password))
                {
                    Device.BeginInvokeOnMainThread(() => MessagingCenter.Send <string>("OrlenLogin", "wrongPassword"));
                }
                return;
            }

            Device.BeginInvokeOnMainThread(() => MessagingCenter.Send <string>("OrlenLogin", "animateStart"));

            Busy = true;

            WebStatusData webstatus = new WebStatusData();

            if (user != null)
            {
                webstatus = await LoginService.LoginAsync(user);
            }
            if (webstatus != null)
            {
                if (!string.IsNullOrEmpty(webstatus.Token))
                {
                    AppPropertiesService.SetToken(webstatus.Token);
                }
            }
            else
            {
                Device.BeginInvokeOnMainThread(() => MessagingCenter.Send <string, string>("OrlenLogin", "scalePromptUp", "Zły login lub hasło"));
                Busy = false;
                return;
            }
            //await Task.Delay(4000);
            await FetchApplicationDataAsync();

            await NavService.NavigateToViewModel <TimetablePageViewModel>(false);

            //if (webstatus.Status.Equals(Status.OK))
            //{
            //    AppPropertiesService.SetUserProperties(webstatus.Token, webstatus.Client_id, webstatus.User_id);
            //    UserDataService.SaveUserData(user.Login, user.Password);
            //    DataService = new EkajetDataService(webstatus.Token, webstatus.User_id, webstatus.Client_id);
            //    await NavService.NavigateToViewModelMasterDetail<MainPageViewModel>(false, Variables.Variables.CALENDAR);
            //    DependencyService.Get<IMessage>().LongAlert(string.Format("Witaj {0}", UserDataService.GetUserLogin()));


            //}
            //else
            //{
            //    if (webstatus.Errcode.Equals("10008") || webstatus.Errcode.Equals("10006"))
            //    {
            //        Device.BeginInvokeOnMainThread(() => MessagingCenter.Send<string, string>("OrlenLogin", "scalePromptUp", "Zły login lub hasło"));
            //        return;
            //    }
            //    else
            //    {
            //        Device.BeginInvokeOnMainThread(() => MessagingCenter.Send<string, string>("OrlenLogin", "scalePromptUp", "Nieznany bład"));
            //        return;
            //    }
            //}


            //Busy = false;
            //Device.BeginInvokeOnMainThread(() => MessagingCenter.Send("OrlenLogin", "animateStop"));
        }