Пример #1
0
        public GetClientDetailsForMobileResponse GetClientDetailsForMobile(string token)
        {
            GetClientDetailsForMobileResponse result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CommonMobile/GetClientDetailsForMobile");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    HttpContent httpContent = new StringContent(JsonConvert.SerializeObject(null), Encoding.UTF8);
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");



                    var response = client.PostAsync(client.BaseAddress, httpContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        result = JsonConvert.DeserializeObject <GetClientDetailsForMobileResponse>(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #2
0
        public WelcomPage()
        {
            InitializeComponent();
            var assembly = typeof(WelcomPage);

            getClientDetailsForMobile = null;
            logoImage.Source          = ImageSource.FromResource("MaxVonGrafKftMobile.Assets.logo_high_resolution_white-1.png", assembly);
            if (!App.Current.Properties.ContainsKey("CustomerId"))
            {
                App.Current.Properties.Add("CustomerId", 0);
            }

            var loginTap = new TapGestureRecognizer();

            loginTap.Tapped += async(s, e) =>
            {
                if ((int)App.Current.Properties["CustomerId"] == 0)
                {
                    await Navigation.PushAsync(new LoginPage());
                }
                else
                {
                    IsBusy = false;
                    if (!IsBusy)
                    {
                        IsBusy = true;
                        await HomeBtn.FadeTo(0, 100, Easing.SinInOut);

                        //await loginBtnFrame.FadeTo(0, 100, Easing.SinInOut);
                        try
                        {
                            if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 1].GetType() != typeof(HomePage))
                            {
                                await Navigation.PushAsync(new HomePage());
                            }
                        }
                        finally
                        {
                            IsBusy = false;
                            await HomeBtn.FadeTo(1, 1000);

                            //await loginBtnFrame.FadeTo(1, 1000);
                        }
                    }
                }
            };
            //loginBtnFrame.GestureRecognizers.Add(loginTap);
            HomeBtn.GestureRecognizers.Add(loginTap);
        }
Пример #3
0
        public GetClientDetailsForMobileResponse GetClientDetailsForMobile(string token)
        {
            GetClientDetailsForMobileResponse response = null;

            try

            {
                response = commonService.GetClientDetailsForMobile(token);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }
Пример #4
0
        private void getAndSaveClientSecrets()
        {
            GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();

            getClientSecretTokenRequest.ClientId = Constants.ClientId;
            ApiController apiController = new ApiController();
            GetClientSecretTokenResponse clientSecretTokenResponse = null;

            try
            {
                clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);
            }
            catch (Exception ex)
            {
                PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
            }
            if (clientSecretTokenResponse != null)
            {
                GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                tokenRequest.client_id     = clientSecretTokenResponse.apiConsumerId;
                tokenRequest.client_secret = clientSecretTokenResponse.apiConsumerSecret;
                tokenRequest.grant_type    = "client_credentials";

                try
                {
                    apiToken = apiController.GetAccessToken(tokenRequest);
                }
                catch (Exception ex)
                {
                    apiToken = null;
                }
                if (apiToken != null)
                {
                    _token = apiToken.access_token;
                    CommonController commonController = new CommonController();

                    try
                    {
                        getClientDetailsForMobile = commonController.GetClientDetailsForMobile(_token);
                    }
                    catch (Exception ex)
                    {
                        PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                    }


                    if (getClientDetailsForMobile != null)
                    {
                        if (getClientDetailsForMobile.admin != null)
                        {
                            Constants.admin = getClientDetailsForMobile.admin;
                        }
                    }

                    if (App.Current.Properties.ContainsKey("currentToken"))
                    {
                        App.Current.Properties["currentToken"] = _token;
                    }
                    else
                    {
                        App.Current.Properties.Add("currentToken", _token);
                    }
                }
            }
        }
Пример #5
0
        private async void BooknowBtn_Clicked(object sender, EventArgs e)
        {
            ApiToken apiToken = null;
            bool     busy     = false;

            if (!busy)
            {
                try
                {
                    busy = true;
                    BooknowBtn.IsVisible     = false;
                    bookNowLoader.IsVisible  = true;
                    bookNowSpinner.IsRunning = true;

                    await Task.Run(async() =>
                    {
                        GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();
                        getClientSecretTokenRequest.ClientId = Constants.ClientId;
                        ApiController apiController          = new ApiController();
                        GetClientSecretTokenResponse clientSecretTokenResponse = null;
                        try
                        {
                            clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);
                        }
                        catch (Exception ex)
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                        }
                        if (clientSecretTokenResponse != null)
                        {
                            GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                            tokenRequest.client_id             = clientSecretTokenResponse.apiConsumerId;
                            tokenRequest.client_secret         = clientSecretTokenResponse.apiConsumerSecret;
                            tokenRequest.grant_type            = "client_credentials";

                            try
                            {
                                apiToken = apiController.GetAccessToken(tokenRequest);
                            }
                            catch (Exception ex)
                            {
                                await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                            }
                            if (apiToken != null)
                            {
                                string _token = apiToken.access_token;
                                CommonController commonController = new CommonController();

                                try
                                {
                                    getClientDetailsForMobile = commonController.GetClientDetailsForMobile(_token);
                                }
                                catch (Exception ex)
                                {
                                    await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                                }


                                if (getClientDetailsForMobile != null)
                                {
                                    if (getClientDetailsForMobile.admin != null)
                                    {
                                        Constants.admin = getClientDetailsForMobile.admin;
                                    }
                                }

                                if (App.Current.Properties.ContainsKey("currentToken"))
                                {
                                    App.Current.Properties["currentToken"] = _token;
                                }
                                else
                                {
                                    App.Current.Properties.Add("currentToken", _token);
                                }
                            }
                        }
                    });
                }

                finally
                {
                    if (apiToken != null)
                    {
                        ReservationView reservation = new ReservationView();
                        await Navigation.PushAsync(new VehicleDetailPage(reservation));
                    }

                    busy = false;
                    BooknowBtn.IsVisible     = true;
                    bookNowLoader.IsVisible  = false;
                    bookNowSpinner.IsRunning = false;
                }
            }
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            await Task.Delay(300);

            GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();

            getClientSecretTokenRequest.ClientId = Constants.ClientId;
            ApiController apiController = new ApiController();
            GetClientSecretTokenResponse clientSecretTokenResponse = null;

            try
            {
                clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);
            }
            catch (Exception ex)
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
            }
            if (clientSecretTokenResponse != null)
            {
                GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                tokenRequest.client_id     = clientSecretTokenResponse.apiConsumerId;
                tokenRequest.client_secret = clientSecretTokenResponse.apiConsumerSecret;
                tokenRequest.grant_type    = "client_credentials";

                try
                {
                    apiToken = apiController.GetAccessToken(tokenRequest);
                }
                catch (Exception ex)
                {
                    await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                }
                if (apiToken != null)
                {
                    string           _token           = apiToken.access_token;
                    CommonController commonController = new CommonController();

                    try
                    {
                        getClientDetailsForMobile = commonController.GetClientDetailsForMobile(_token);
                    }
                    catch (Exception ex)
                    {
                        await PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                    }


                    if (getClientDetailsForMobile != null)
                    {
                        if (getClientDetailsForMobile.admin != null)
                        {
                            Constants.admin = getClientDetailsForMobile.admin;
                        }
                    }

                    if (App.Current.Properties.ContainsKey("currentToken"))
                    {
                        App.Current.Properties["currentToken"] = _token;
                    }
                    else
                    {
                        App.Current.Properties.Add("currentToken", _token);
                    }
                }
            }


            if ((int)App.Current.Properties["CustomerId"] == 0)
            {
                await Navigation.PushAsync(new WelcomPage());
            }
            else
            {
                await Navigation.PushAsync(new HomePage());
            }
        }
Пример #7
0
        public App(string pagename, string data)
        {
            Xamarin.Forms.Application.Current.On <Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

            InitializeComponent();

            if (!App.Current.Properties.ContainsKey("CustomerId"))
            {
                App.Current.Properties.Add("CustomerId", 0);
            }

            if ((int)App.Current.Properties["CustomerId"] == 0)
            {
                GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();
                getClientSecretTokenRequest.ClientId = Constants.ClientId;
                ApiController apiController = new ApiController();
                GetClientSecretTokenResponse clientSecretTokenResponse = null;
                try
                {
                    clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);
                }
                catch (Exception ex)
                {
                    PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                }
                if (clientSecretTokenResponse != null)
                {
                    GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                    tokenRequest.client_id     = clientSecretTokenResponse.apiConsumerId;
                    tokenRequest.client_secret = clientSecretTokenResponse.apiConsumerSecret;
                    tokenRequest.grant_type    = "client_credentials";

                    try
                    {
                        apiToken = apiController.GetAccessToken(tokenRequest);
                    }
                    catch (Exception ex)
                    {
                        PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                    }
                    if (apiToken != null)
                    {
                        string           _token           = apiToken.access_token;
                        CommonController commonController = new CommonController();

                        try
                        {
                            getClientDetailsForMobile = commonController.GetClientDetailsForMobile(_token);
                        }
                        catch (Exception ex)
                        {
                            PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                        }


                        if (getClientDetailsForMobile != null)
                        {
                            if (getClientDetailsForMobile.admin != null)
                            {
                                Constants.admin = getClientDetailsForMobile.admin;
                            }
                        }

                        if (App.Current.Properties.ContainsKey("currentToken"))
                        {
                            App.Current.Properties["currentToken"] = _token;
                        }
                        else
                        {
                            App.Current.Properties.Add("currentToken", _token);
                        }
                    }
                }


                if (pagename != null)
                {
                    if (pagename == "ViewReservation")
                    {
                        MainPage = new NavigationPage(new ViewReservation(Convert.ToInt32(data)));
                    }
                }
                else
                {
                    MainPage = new NavigationPage(new WelcomPage());
                }
            }
            else
            {
                MainPage = new NavigationPage(new HomePage());
            }
        }