private void AddFrag_ProductHandler(object sender, OnCreateProductEvent e)
        {
            var          client   = new RestClient("http://10.0.2.2:60408");
            RestReader   reader   = new RestReader();
            RestInserter inserter = new RestInserter();



            //  Toast.MakeText(this, "Userprices might be null " + userPrices.Length, ToastLength.Short).Show();

            Prices price = new Prices
            {
                Id           = CurrentUserSignedInId,
                ProductId    = (userPrices.Length == 0) ? 0 : userPrices[userPrices.Length - 1].ProductId + 1,
                Name         = e.Name,
                Price        = e.Price,
                Picture      = "none",
                IdNavigation = null,
                Ingredients  = null
            };

            try
            {
                inserter.InsertPrice(price, client, CurrentUserSignedInId);
            }

            catch (Exception)
            {
                Toast.MakeText(this.ApplicationContext, "Exception at insertion attempt! (activity)", ToastLength.Short).Show();
            }
        }
Example #2
0
        public async Task ReadDataFromNBP()
        {
            var reader = new RestReader();
            var ret    = await reader.ReadDataAsync <NBPCurrencyResponse>(_url);

            Assert.That(ret, Is.Not.Null);
            Assert.That(ret.Code.ToLower(), Is.EqualTo("EUR".ToLower()));
        }
        public void TestGetPropertyList()
        {
            if (bSkipMe)
            {
                Assert.IsTrue(true);
                EnqueueTestComplete();
                return;
            }

            RestReader md = new RestReader();

            string[] urls = new string[1];
            urls[0]     = GetUrl("hd_ui_treeview_access");
            md.OnEvent += (sender, e) =>
            {
                try
                {
                    switch (e.status)
                    {
                    case DownloadStatus.CompleteOne_Success:
                        //// element
                        //Dictionary<string, string> l = mp.GetPropertyList(e.data, "hd_ui_treeview_access", "name");
                        //Assert.IsTrue(l != null);
                        //Assert.IsTrue(l.Count == 4);
                        //Assert.IsTrue(l["2"] == "test2");

                        //// element.attribute
                        //Dictionary<string, string> l2 = mp.GetPropertyList(e.data, "hd_ui_treeview_access", "role.identifier");
                        //Assert.IsTrue(l2 != null);
                        //Assert.IsTrue(l2.Count == 4);
                        //Assert.IsTrue(l2["2"] == "HDTestRoleA");

                        //// negative test
                        //Dictionary<string, string> l3 = mp.GetPropertyList(e.data, "hd_ui_treeview_access", "role.identifier.id");
                        //Assert.IsTrue(l3 == null);

                        break;

                    case DownloadStatus.CompleteAll_Success:
                        EnqueueTestComplete();
                        break;

                    default:
                        Assert.Fail("error msg:" + e.data);
                        EnqueueTestComplete();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Assert.Fail(ex.Message);
                }
            };
            md.Start(urls, 3, 5, "a");
        }
        private async void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var        client = new RestClient("http://10.0.2.2:60408");
            RestReader reader = new RestReader();

            Toast.MakeText(this, "Loading. . ." + CurrentUserId, ToastLength.Short).Show();
            Prices[] prices = await reader.GetPrices(client, ListedUsers[e.Position].Id);

            var    intent           = new Intent(this, typeof(BarContent));
            string serializedPrices = JsonConvert.SerializeObject(prices);

            intent.PutExtra("priceString", serializedPrices);


            intent.PutExtra("userId", CurrentUserId);
            StartActivity(intent);
        }
        public async void OptionsList_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            switch (e.Position)
            {
            case 0:
            {
                //Add product
                var        client = new RestClient("http://10.0.2.2:60408");
                RestReader reader = new RestReader();
                userPrices = await reader.GetPrices(client);

                AddProductFrag addFrag = new AddProductFrag(CurrentUserSignedInId);

                addFrag.ProductHandler += AddFrag_ProductHandler;
                FragmentTransaction transaction = FragmentManager.BeginTransaction();
                addFrag.Show(transaction, "CreateProductFrag");

                break;
            }

            case 1:
            {
                //Delete product
                var        client = new RestClient("http://10.0.2.2:60408");
                RestReader reader = new RestReader();
                userPrices = await reader.GetPrices(client, CurrentUserSignedInId);

                EditProductFrag     deleteFrag  = new EditProductFrag(userPrices);
                FragmentTransaction transaction = FragmentManager.BeginTransaction();
                deleteFrag.Show(transaction, "CreateProductFrag");

                break;
            }

            case 2:
            {
                //Delete profile

                Toast.MakeText(this.ApplicationContext, "Delete Profile - To be implemented!", ToastLength.Short).Show();
                break;
            }
            }
        }
Example #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);

            SetContentView(Resource.Layout.Main);

            usernameEdit   = FindViewById <EditText>(Resource.Id.userNameTextEdit);
            passwordEdit   = FindViewById <EditText>(Resource.Id.passwordTextEdit);
            signIn         = FindViewById <Button>(Resource.Id.signInButton);
            createProfile  = FindViewById <Button>(Resource.Id.createProfileButton);
            signInGuest    = FindViewById <Button>(Resource.Id.signInAsGuestButton);
            bar            = FindViewById <ProgressBar>(Resource.Id.loadingBarMain);
            bar.Visibility = Android.Views.ViewStates.Invisible;

            reader   = new RestReader();
            inserter = new RestInserter();

            signIn.Click        += SignIn_Click;
            createProfile.Click += CreateProfileClick;
            signInGuest.Click   += SignInGuest_Click;
        }