示例#1
0
        async void addOffer_Clicked(object sender, EventArgs e)
        {
            string     title       = titleEntry.Text;
            string     description = descriptionEntry.Text;
            int        categoryId  = Convert.ToInt32(((Category)CategoryBinder.SelectedItem).CategoryID);
            int        quantity    = Convert.ToInt32(quantityEntry.Text);
            string     price       = priceEntry.Text;
            OfferState state       = (OfferState)StateBinder.SelectedItem;


            var offerItem = new Models.BindingModels.OfferBindingModel
            {
                Title            = title,
                Description      = description,
                CategoryID       = categoryId,
                InStockOriginaly = quantity,
                Price            = price,
                UserID           = Session.user.UserID,
                OfferState       = state
            };

            if (string.IsNullOrEmpty(titleEntry.Text) || string.IsNullOrEmpty(descriptionEntry.Text))
            {
                await DisplayAlert("Enter data", "Enter valid data", "Ok");
            }
            else
            {
                try
                {
                    OfferItem response = await AddOfferViewModel.AddOfferAsync(offerItem);

                    if (response != null)
                    {
                        output.Text = "Oferta dodana pomyślnie!";
                    }
                    else
                    {
                    }
                }
                catch (AggregateException err)
                {
                    foreach (var errInner in err.InnerExceptions)
                    {
                        Debug.WriteLine(errInner); //this will call ToString() on the inner execption and get you message, stacktrace and you could perhaps drill down further into the inner exception of it if necessary
                    }
                    ;
                }
            }
        }