Ejemplo n.º 1
0
        async void OnOptionItemSelected(object sender, OptionItemEventArgs e)
        {
            if (e.Item.TitleFormatted.ToString() == "Save")
            {
                SearchObject searchObject = new SearchObject();
                searchObject.SearchLocation = location;
                searchObject.Category = SubCategory.Value != null ? new KeyValuePair<object, object>(SubCategory.Value, SubCategory.Key) : new KeyValuePair<object, object>(category.Key, category.Value);
                searchObject.SearchItems = this.SearchItems;
                searchObject.Conditions = this.Conditions;
                searchObject.MaxListings = this.MaxListings;
                searchObject.PostedDate = this.WeeksOld;

                string serialized = JsonConvert.SerializeObject(searchObject);
                await MainActivity.databaseConnection.AddNewSearchAsync(location.Url, serialized);

                Console.WriteLine(MainActivity.databaseConnection.StatusMessage);

                if (MainActivity.databaseConnection.StatusCode == Models.codes.ok)
                {
                    Toast.MakeText(context, "Search Saved!", ToastLength.Short).Show();
                }
                else
                {
                    var message = string.Format("Oops, something went wrong{0}Please try again...", System.Environment.NewLine);
                    Toast.MakeText(context, message, ToastLength.Short).Show();
                }
            }
        }
        async void OnOptionItemSelected(object sender, OptionItemEventArgs e)
        {
            if (e.Item.TitleFormatted.ToString() == "Save")
            {
                await MainActivity.databaseConnection.AddNewListingAsync(Posting.PostTitle,
                                                                   Posting.Description,
                                                                   Posting.Link,
                                                                   Posting.ImageLink,
                                                                   Posting.Date);

                if (MainActivity.databaseConnection.StatusCode == codes.ok)
                    Toast.MakeText(this.Activity, string.Format("Saved Posting!"), ToastLength.Short).Show();
                else
                    Toast.MakeText(this.Activity, string.Format("Oops, something went wrong"), ToastLength.Short).Show();
            }
        }