示例#1
0
        public GetClientSecretTokenResponse GetClientSecretToken(GetClientSecretTokenRequest getClientSecretTokenRequest)
        {
            GetClientSecretTokenResponse tokenResponse = new GetClientSecretTokenResponse();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "Login/GetClientSecretToken");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var myContent   = JsonConvert.SerializeObject(getClientSecretTokenRequest);
                    var buffer      = Encoding.UTF8.GetBytes(myContent);
                    var byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    var response = client.PostAsync(client.BaseAddress, byteContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        tokenResponse = JsonConvert.DeserializeObject <GetClientSecretTokenResponse>(responseStream);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(tokenResponse);
        }
        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;

            getAndSaveClientSecrets();

            if (_token != null)
            {
                IsUpdatesAvailable = checkForApplicationUpdates(currentVersion);
                if (!IsUpdatesAvailable)
                {
                    if ((int)App.Current.Properties["CustomerId"] == 0)
                    {
                        await Navigation.PushAsync(new WelcomPage());

                        //MainPage = new NavigationPage(new WelcomPage());
                        //MainPage = new NavigationPage(new enterConfirmationCodePage());
                    }
                    else
                    {
                        await Navigation.PushAsync(new HomePage());

                        //MainPage = new NavigationPage(new HomePage());
                    }
                }
                else
                {
                    //Want to retuen page that reqire the app to update
                    await Navigation.PushAsync(new UpdateApplication());
                }
            }
            else
            {
                //Want to return No network page
                await Navigation.PushAsync(new NoNetwork());
            }
        }
示例#3
0
 public GetClientSecretTokenResponse GetClientSecretToken(GetClientSecretTokenRequest getClientSecretTokenRequest)
 {
     return(loginservice.GetClientSecretToken(getClientSecretTokenRequest));
 }
示例#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);
                    }
                }
            }
        }
        private async void RegiseterNxtBtn_Clicked(object sender, EventArgs e)
        {
            if (!new EmailAddressAttribute().IsValid(emailEntry.Text) || string.IsNullOrEmpty(emailEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a valid email address"));
            }

            else if (string.IsNullOrEmpty(PasswordEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Please enter a valid Password"));
            }
            else if (PasswordEntry.Text.Length < 6)
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Password must be atleast with 6 characters."));
            }
            else if (!(PasswordEntry.Text == ConfirmPasswordEntry.Text))
            {
                await PopupNavigation.Instance.PushAsync(new Error_popup("Passwords do not match. Please re - enter your password"));

                ConfirmPasswordEntry.Text = null;
            }

            else
            {
                ConfirmPasswordEntry.IsPassword = true;
                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        regiseterNxtBtn.IsVisible  = false;
                        NextSpinnerFrame.IsVisible = true;
                        nextSpinner.IsRunning      = true;
                        customerSerach.Email       = emailEntry.Text;
                        customerSerach.Active      = true;
                        await Task.Run(() =>
                        {
                            GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();
                            getClientSecretTokenRequest.ClientId = Constants.ClientId;
                            ApiController apiController          = new ApiController();
                            GetClientSecretTokenResponse clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);

                            GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                            tokenRequest.client_id             = clientSecretTokenResponse.apiConsumerId;
                            tokenRequest.client_secret         = clientSecretTokenResponse.apiConsumerSecret;
                            tokenRequest.grant_type            = "client_credentials";
                            ApiToken apiToken = apiController.GetAccessToken(tokenRequest);



                            if (App.Current.Properties.ContainsKey("currentToken"))
                            {
                                App.Current.Properties["currentToken"] = apiToken.access_token;
                            }
                            else
                            {
                                App.Current.Properties.Add("currentToken", apiToken.access_token);
                            }
                            CustomerController customerController = new CustomerController();
                            try
                            {
                                customerSeachResults = customerController.getCustomerByFilter(customerSerach, apiToken.access_token);
                            }
                            catch (Exception ex)
                            {
                                PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                            }
                        });
                    }
                    finally
                    {
                        busy              = false;
                        customer.Email    = emailEntry.Text;
                        customer.Password = PasswordEntry.Text;
                        customer.ClientId = Constants.ClientId;

                        NextSpinnerFrame.IsVisible = false;
                        nextSpinner.IsRunning      = false;
                        regiseterNxtBtn.IsVisible  = true;

                        if (customerSeachResults != null)
                        {
                            if (customerSeachResults.Count > 0)
                            {
                                bool isExisting = false;
                                foreach (CustomerSeachResult csr in customerSeachResults)
                                {
                                    if (csr.Email.ToLower() == emailEntry.Text.ToLower())
                                    {
                                        isExisting = true;
                                    }
                                }
                                if (isExisting)
                                {
                                    await PopupNavigation.Instance.PushAsync(new Error_popup("Email address already exists.Please log -in or try a different email address."));
                                }
                                else
                                {
                                    await Navigation.PushAsync(new AddPersonalInformationPage(customer));
                                }
                            }
                            else
                            {
                                await Navigation.PushAsync(new AddPersonalInformationPage(customer));
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup("Something went wrong. Please check your Internet connection."));
                        }

                        //if (customerSeachResults.Count == 0)
                        //{

                        //}
                        //else
                        //{
                        //    await PopupNavigation.Instance.PushAsync(new Error_popup("Email already exist. Please use another email address."));
                        //}
                    }
                }
            }
        }
示例#6
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;
                }
            }
        }
        private async void LoginButton_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                errorLabel.Text      = "Please enter a email address";
                errorLabel.IsVisible = true;
            }
            else if (!new EmailAddressAttribute().IsValid(loginEmailAddress.Text))
            {
                errorLabel.Text      = "Email is not in a valid format.Please try again";
                errorLabel.IsVisible = true;
            }
            else if (string.IsNullOrEmpty(loginPassword.Text))
            {
                errorLabel.Text      = "Please enter a valid password";
                errorLabel.IsVisible = true;
            }
            else
            {
                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        LoginButton.IsVisible       = false;
                        loginSpinnerFrame.IsVisible = true;
                        loginSpinner.IsRunning      = true;
                        await Task.Run(() =>
                        {
                            GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();
                            getClientSecretTokenRequest.ClientId = Constants.ClientId;
                            ApiController apiController          = new ApiController();
                            GetClientSecretTokenResponse clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);

                            GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                            tokenRequest.client_id             = clientSecretTokenResponse.apiConsumerId;
                            tokenRequest.client_secret         = clientSecretTokenResponse.apiConsumerSecret;
                            tokenRequest.grant_type            = "client_credentials";
                            ApiToken apiToken = apiController.GetAccessToken(tokenRequest);
                            token             = apiToken.access_token;

                            CustomerLogin loginCustomer = new CustomerLogin();
                            loginCustomer.email         = loginEmailAddress.Text;
                            loginCustomer.Password      = loginPassword.Text;
                            loginCustomer.clientId      = Constants.ClientId;


                            LoginController loginController = new LoginController();
                            cutomerAuthContext = loginController.CheckLogin(loginCustomer, token);
                        });
                    }
                    finally
                    {
                        busy = false;
                        loginSpinner.IsRunning      = false;
                        loginSpinnerFrame.IsVisible = false;

                        LoginButton.IsVisible = true;
                        if (cutomerAuthContext.CustomerId > 0)
                        {
                            Constants.IsRegisteredandNotLogin = false;
                            Constants.cutomerAuthContext      = cutomerAuthContext;
                            if (App.Current.Properties.ContainsKey("currentToken"))
                            {
                                App.Current.Properties["currentToken"] = token;
                            }
                            else
                            {
                                App.Current.Properties.Add("currentToken", token);
                            }

                            if (App.Current.Properties.ContainsKey("CustomerId"))
                            {
                                App.Current.Properties["CustomerId"] = cutomerAuthContext.CustomerId;
                            }
                            else
                            {
                                App.Current.Properties.Add("CustomerId", cutomerAuthContext.CustomerId);
                            }
                            Type type = typeof(WelcomPage);

                            if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 2].GetType() == type)
                            {
                                await Navigation.PushAsync(new HomePage());
                            }
                            else if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 2].GetType() == typeof(OtherInformationPage))
                            {
                                if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 3].GetType() == type)
                                {
                                    await Navigation.PushAsync(new HomePage());
                                }
                                else
                                {
                                    Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                                    await Navigation.PopAsync();
                                }
                            }

                            else
                            {
                                await Navigation.PopAsync();
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup("Log in failed . Please try again"));

                            loginPassword.Text   = null;
                            errorLabel.IsVisible = false;
                        }
                    }
                }
            }
        }
示例#8
0
        private async void LoginButton_Clicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                string emailen = loginEmailAddress.Text.Replace(" ", "");
                loginEmailAddress.Text = emailen;
            }

            if (string.IsNullOrEmpty(loginEmailAddress.Text))
            {
                errorLabel.Text      = "Please enter a email address";
                errorLabel.IsVisible = true;
            }
            else if (!new EmailAddressAttribute().IsValid(loginEmailAddress.Text))
            {
                errorLabel.Text      = "Email is not in a valid format.Please try again";
                errorLabel.IsVisible = true;
            }
            else if (string.IsNullOrEmpty(loginPassword.Text))
            {
                errorLabel.Text      = "Please enter a valid password";
                errorLabel.IsVisible = true;
            }
            else
            {
                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        LoginButton.IsVisible       = false;
                        loginSpinnerFrame.IsVisible = true;
                        loginSpinner.IsRunning      = true;
                        await Task.Run(() =>
                        {
                            GetClientSecretTokenRequest getClientSecretTokenRequest = new GetClientSecretTokenRequest();
                            getClientSecretTokenRequest.ClientId = Constants.ClientId;
                            ApiController apiController          = new ApiController();
                            GetClientSecretTokenResponse clientSecretTokenResponse = apiController.GetClientSecretToken(getClientSecretTokenRequest);

                            GetAccessTokenRequest tokenRequest = new GetAccessTokenRequest();
                            tokenRequest.client_id             = clientSecretTokenResponse.apiConsumerId;
                            tokenRequest.client_secret         = clientSecretTokenResponse.apiConsumerSecret;
                            tokenRequest.grant_type            = "client_credentials";
                            ApiToken apiToken = apiController.GetAccessToken(tokenRequest);
                            token             = apiToken.access_token;

                            CustomerLogin loginCustomer = new CustomerLogin();
                            loginCustomer.email         = loginEmailAddress.Text;
                            loginCustomer.Password      = loginPassword.Text;
                            loginCustomer.clientId      = Constants.ClientId;
                            loginCustomer.ClientTime    = DateTime.Now;


                            LoginController loginController = new LoginController();
                            cutomerAuthContext = loginController.CheckLogin(loginCustomer, token);
                            if (cutomerAuthContext.CustomerId > 0)
                            {
                                portalDetailsMobileRequest.customerId = cutomerAuthContext.CustomerId;
                                updateConstantCustomerDetails(portalDetailsMobileRequest);
                            }
                        });
                    }
                    finally
                    {
                        busy = false;
                        loginSpinner.IsRunning      = false;
                        loginSpinnerFrame.IsVisible = false;

                        LoginButton.IsVisible = true;
                        if (cutomerAuthContext.CustomerId > 0)
                        {
                            Constants.IsRegisteredandNotLogin = false;
                            Constants.cutomerAuthContext      = cutomerAuthContext;
                            if (App.Current.Properties.ContainsKey("currentToken"))
                            {
                                App.Current.Properties["currentToken"] = token;
                            }
                            else
                            {
                                App.Current.Properties.Add("currentToken", token);
                            }


                            if (Constants.customerDetails != null && Constants.customerDetails.IsBlackListed)
                            {
                                await PopupNavigation.Instance.PushAsync(new Error_popup(" Sorry, your account has been blacklisted."));
                            }



                            //if (cutomerAuthContext.IsEmailConfirmed)
                            else if (cutomerAuthContext.IsEmailConfirmed)
                            {
                                if (App.Current.Properties.ContainsKey("CustomerId"))
                                {
                                    App.Current.Properties["CustomerId"] = cutomerAuthContext.CustomerId;
                                }
                                else
                                {
                                    App.Current.Properties.Add("CustomerId", cutomerAuthContext.CustomerId);
                                }

                                Type type = typeof(WelcomPage);

                                //if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 2].GetType() == type)
                                //{
                                //    await Navigation.PushAsync(new HomePage());
                                //}
                                //else if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 2].GetType() == typeof(OtherInformationPage))
                                //{
                                //    if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 3].GetType() == type)
                                //    {
                                //        await Navigation.PushAsync(new HomePage());
                                //    }
                                //    else
                                //    {
                                //        Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                                //        await Navigation.PushAsync(new HomePage());
                                //    }

                                //}

                                //else
                                //{
                                //if (Navigation.NavigationStack.Count < 3)
                                //{
                                //    await Navigation.PushAsync(new HomePage());
                                //}
                                //else
                                //{
                                //    await Navigation.PopAsync();
                                //}
                                if (fromVal == 1)
                                {
                                    await Navigation.PopModalAsync();
                                }
                                else
                                {
                                    await Navigation.PushModalAsync(new HomePage());
                                }

                                //}
                            }
                            else
                            {
                                if (fromVal == 1)
                                {
                                    await Navigation.PushModalAsync(new ConfirmEmailRequest(cutomerAuthContext.CustomerId, MaxVonGrafKftMobileModel.Constants.emailConfirmationType.LogIn, fromVal));
                                }
                                else
                                {
                                    await Navigation.PushModalAsync(new ConfirmEmailRequest(cutomerAuthContext.CustomerId, MaxVonGrafKftMobileModel.Constants.emailConfirmationType.LogIn));
                                }

                                //gobackAsync();
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup("Login failed. Please try again."));

                            loginPassword.Text   = null;
                            errorLabel.IsVisible = 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());
            }
        }
示例#10
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());
            }
        }