async Task <UserResponseResult> IUserRestService.Authentication(Dictionary <string, string> credential)
        {
            UserResponseResult userResponseResult = new UserResponseResult();

            Credential userInfo = new Credential();

            userInfo.username = credential["Username"];
            userInfo.password = credential["Password"];

            var url = Constants.host + "/api/user/authentication";
            var uri = new Uri(url);

            try
            {
                var json    = JsonConvert.SerializeObject(userInfo);
                var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;
                response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    userResponseResult = JsonConvert.DeserializeObject <UserResponseResult>(result);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }

            return(userResponseResult);
        }
        public Login()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            lblHost.Text      = Constants.host.Replace("http://", "") + "( " + Constants.Version + " )";
            btnLogin.Clicked += async(s, e) =>
            {
                if (!string.IsNullOrEmpty(etyUsername.Text) && !string.IsNullOrEmpty(etyPassword.Text))
                {
                    Dictionary <string, string> credential = new Dictionary <string, string>();
                    credential.Add("Username", etyUsername.Text);
                    credential.Add("Password", etyPassword.Text);

                    IsBusy = true;
                    UserResponseResult userResponseResult = await App.UserManager.Authentication(credential);

                    if (userResponseResult.Success == false)
                    {
                        await DisplayAlert(AppResources.LoginFailed, userResponseResult.Error, AppResources.OK);

                        IsBusy = false;
                        return;
                    }

                    App.mUser     = userResponseResult.Result;
                    App.mRoleUser = userResponseResult.RoleUser;

                    App.mIsUserAllowToEnroll = false;
                    foreach (RoleUser roleUser in App.mRoleUser)
                    {
                        if (roleUser.RoleID == (int)Enumerations.Role.VIPCPMUser || roleUser.RoleID == (int)Enumerations.Role.Guest)
                        {
                            App.mIsUserAllowToEnroll = true;
                        }
                    }

                    if (userResponseResult.Result != null && userResponseResult.Result.Name != null)
                    {
                        Constants.Username   = etyUsername.Text;
                        App.Current.MainPage = new MenuPage();
                        await Navigation.PopAsync(true);
                    }
                    else
                    {
                        await DisplayAlert(AppResources.LoginFailed, AppResources.IncorrectCredential, AppResources.OK);

                        IsBusy = false;
                    }
                }
                else
                {
                    IsBusy = false;
                    await DisplayAlert(AppResources.UsernameAndPasswordRequired, AppResources.PleaseCheckInternatConnection, AppResources.OK);
                }
            };
        }