Example #1
0
        private async void LoginButton_Clicked(object sender, EventArgs e)
        {
            App.ShowLoading(true);

            if (!string.IsNullOrEmpty(Entry_Username.Text) && !string.IsNullOrEmpty(Entry_Password.Text))
            {
                ValidateUserClient client = new ValidateUserClient();
                var request = new LoginRequest {
                    UserName = Entry_Username.Text, Password = Entry_Password.Text
                };

                var vLoginResult = await client.GetDataAsync(request);

                if (vLoginResult.IsSuccessful)
                {
                    DependencyService.Get <Abstraction.DependencyServices.ISharedPreferences>().SaveString(App.ActualUserDBKey,
                                                                                                           JsonConvert.SerializeObject(vLoginResult.UserInformation));
                    DependencyService.Get <Abstraction.DependencyServices.ISharedPreferences>().SaveString(App.ActualUserConfigurationDBKey,
                                                                                                           JsonConvert.SerializeObject(vLoginResult.UserConfiguration));
                    DependencyService.Get <Abstraction.DependencyServices.ISharedPreferences>().SaveString(App.ActualSSOTDBKey,
                                                                                                           JsonConvert.SerializeObject(vLoginResult.SSOT));
                    App.ActualUser = vLoginResult.UserInformation;
                    App.ActualUserConfiguration = vLoginResult.UserConfiguration;
                    App.SSOT = vLoginResult.SSOT;
                    await App.RootPage.ChangePage(new MasterDetail.MasterPageItem {
                        TargetType = MasterDetail.PageType.BillList
                    });

                    await Navigation.PopModalAsync();

                    App.ShowLoading(false);
                    return;
                }
                else
                {
                    await DisplayAlert("", vLoginResult.UserMessage, "Ok");
                }
            }
            else
            {
                App.ShowLoading(false);
                await Toasts.ToastRunner.ShowErrorToast("Sistema", "Debe llenar los campos vacĂ­os");
            }



            App.ShowLoading(false);
        }
Example #2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            /*DependencyService.Get<IMailService>().SendMail("Prueba", "Esto es una prueba",
             *  new List<string>() { "*****@*****.**" });*/
            App.ShowLoading(true);
            try
            {
                ValidateUserClient client = new ValidateUserClient();
                var request = new LoginRequest {
                    UserName = "******", Password = "******"
                };

                var result = await client.GetDataAsync(request, "http://192.168.1.104:8081");

                /*var billList = await DynamoDBManager.GetInstance().GetItemsAsync<Model.Bill>();
                 * foreach (var bill in billList)
                 * {
                 *  bill.UserId = 302680516;
                 *  await DynamoDBManager.GetInstance().SaveAsync<Model.Bill>(bill);
                 * }
                 * var clientList = await DynamoDBManager.GetInstance().GetItemsAsync<Model.Client>();
                 * foreach (var client in clientList)
                 * {
                 *  client.UserId = 302680516;
                 *  await DynamoDBManager.GetInstance().SaveAsync<Model.Client>(client);
                 * }
                 * var productList = await DynamoDBManager.GetInstance().GetItemsAsync<Model.Product>();
                 * foreach (var product in productList)
                 * {
                 *  product.UserId = 302680516;
                 *  await DynamoDBManager.GetInstance().SaveAsync<Model.Product>(product);
                 * }*/
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                throw;
            }
            App.ShowLoading(false);
        }