public async Task DeleteSurveyThinkingOfYouAsync(ThinkingOfYou thinkingOfYou)
        {
            await InitializeAsync();

            //			throw new NotImplementedException ();
            //if (string.IsNullOrEmpty (question.Id)) {
            //	await questionsTable.InsertAsync (question);
            //}
            await thinkingOfYouTable.DeleteAsync(thinkingOfYou);

            System.Diagnostics.Debug.WriteLine("Pending operations in the sync context queue: {0}", client.SyncContext.PendingOperations);


            //var localItems = await questionsTable.Select (i => i.Answers).ToListAsync();
            //System.Diagnostics.Debug.WriteLine ("Local table): { 0}", string.Join (", ", localItems));

            //			await client.SyncContext.PushAsync ();

            await SynchronizeThinkingOfYouAsync(thinkingOfYou.theId);             //(response.SurveyQuestionId);

            System.Diagnostics.Debug.WriteLine("Pending operations in the sync context queue: {0}", client.SyncContext.PendingOperations);


            //throw new NotImplementedException ();
        }
Пример #2
0
        public MyNewNativeCell()
        {
            DateTime dt = DateTime.Now;

            CultureInfo ci = new CultureInfo("en-US");
            string      sampleDateString     = dt.ToString("MMM d", ci);
            string      sampleDateTimeString = dt.ToString("MMM d h:mm tt", ci);
            //Also above can be done more formally like this:
            //https://msdn.microsoft.com/en-us/library/cc165448.aspx

            var prayerAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            prayerAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            prayerAction.Clicked += async(sender, e) => {
                var mi = ((MenuItem)sender);
                Debug.WriteLine("More Context Action clicked: " + ((SurveyQuestion)mi.CommandParameter).SharedText);
                await App.Service.DeleteSurveyQuestionAsync((SurveyQuestion)mi.CommandParameter);

                AppConstants.NeedsUpdating = true;
                MessagingCenter.Send <object> (this, "RefreshData");

                //AT THE CONTACTS PAGE LEVEL - NEED TO RUN :: PostDeleteActions ();
            };

            var thoughtAction = new MenuItem {
                Text = "T&P"
            };                                                            //, IsDestructive = true }; // red background

            thoughtAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            thoughtAction.Clicked += async(sender, e) => {
                var mi = ((MenuItem)sender);

                System.Random random       = new Random();
                string        randomNumber = string.Join(string.Empty, Enumerable.Range(0, 10).Select(number => random.Next(0, 5).ToString()));

                ThinkingOfYou oneThinkingOfYou = new ThinkingOfYou()
                {
                    theId                = randomNumber,
                    FirstName            = "TestFirst",
                    LastName             = "TestLast",
                    FullName             = AppConstants.FBFullName,
                    SharedText           = String.Format("{0} is thinking of you!", AppConstants.FBFullName),
                    NewText              = "Test NewText",
                    FBProfileUrl         = AppConstants.FullURLPlusFBIdentityID,
                    CreateDateString     = sampleDateString,
                    CreateDateTimeString = sampleDateTimeString,

                    //public string "WE NEED THE ID OF THE PRAYER REQUEST"
                    //i.e. each prayer request needs an ID
                    //THEN on the page, we want to filter by that ID

                    thePrayerRequestId = ((SurveyQuestion)mi.CommandParameter).Id,
                    theFBID            = AppConstants.FBIdentityID,
                };

                await App.Service.AddOrUpdateThinkingOfYouAsync(oneThinkingOfYou);

                //App.Service.SynchronizeQuestionsAsync (oneSurveyQuestion.Id);
                //AppConstants.NeedsUpdating == false;
                AppConstants.NeedsUpdating = true;

                MessagingCenter.Send <object> (this, "RefreshData");
            };
            // add to the ViewCell's ContextActions property
            ContextActions.Add(prayerAction);
            ContextActions.Add(thoughtAction);


            label = new Label {
                VerticalTextAlignment = TextAlignment.Center
            };

            label.SetBinding(Label.TextProperty, "SharedText");


            tempLabel = new Label {
                VerticalTextAlignment = TextAlignment.Center
            };
            tempLabel.SetBinding(Label.TextProperty, "FBProfileUrl");

            localFBString = String.Format("http://graph.facebook.com/165706980572556/picture?type=normal");              //{0}/picture?type=normal", tempLabel.Text);

            //if (tempLabel.Text != null)
            //{
            //	localFBString = String.Format ("http://graph.facebook.com/{0}/picture?type=normal", tempLabel.Text);
            //}
            //else
            //{
            //	localFBString = String.Format ("http://graph.facebook.com/165706980572555/picture?type=normal", tempLabel.Text);
            //}

            //IMAGES - BOXES
            var profileImage = new Image {
                //Source =   ImageSource.FromUri (new Uri("http://graph.facebook.com/165706980572556/picture?type=normal"))
                //			Source = ImageSource.FromUri (new Uri (localFBString))
                //Source = localFBString
            };

            profileImage.SetBinding(Image.SourceProperty, "FBProfileUrl");
            //			profileImage.SetBinding (Image.SourceProperty, "FullURIFBProfileUrl");


            //IMAGES - CIRLCE-BOXES
            var circleProfileImage = new CircleImage {
                //Source =   ImageSource.FromUri (new Uri("http://graph.facebook.com/165706980572556/picture?type=normal"))
                //			Source = ImageSource.FromUri (new Uri (localFBString))
                //Source = localFBString

                BorderColor       = Color.White,
                BorderThickness   = 3,
                HeightRequest     = 59,
                WidthRequest      = 59,
                Aspect            = Aspect.AspectFill,
                HorizontalOptions = LayoutOptions.Center
            };

            circleProfileImage.SetBinding(Image.SourceProperty, "FBProfileUrl");
            //			profileImage.SetBinding (Image.SourceProperty, "FullURIFBProfileUrl");



            dateLabel = new Label {
                FontAttributes = FontAttributes.Italic,
                FontSize       = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                TextColor      = Color.Gray
            };

            dateLabel.SetBinding(Label.TextProperty, "CreateDateString");

            //Need a date and time data point (simple) - let's just do (month & year) Nov 9th

            //string URLNormal = String.Format ("http://graph.facebook.com/{0}/picture?type=normal", _profileId);
            //string URLSquare = String.Format ("http://graph.facebook.com/{0}/picture?type=square", _profileId);
            //string URLSmall = String.Format ("http://graph.facebook.com/{0}/picture?type=small", _profileId);

            //string fullNameString = AppConstants.FBFullName;

            //Label fullNameLabel = new Label ();
            //fullNameLabel.Text = fullNameString;

            //var webImage = new Image { Aspect = Aspect.AspectFit };
            //webImage.Source = ImageSource.FromUri (new Uri (URLLarge));

            ////webImage.Source = ImageSource.FromUri (new Uri ("https://xamarin.com/content/images/pages/forms/example-app.png"));

            ////webImage.Source = ImageSource.FromUri (new Uri ("http://graph.facebook.com/v2.2/423402/picture"));

            //var webImage2 = new Image { Aspect = Aspect.AspectFit };
            //webImage2.Source = ImageSource.FromUri (new Uri (URLNormal));//new Uri ("http://graph.facebook.com/423402/picture?type=large"));

            var imageStackLayout = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(0, 0, 0, 0),
                //HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { circleProfileImage }                 //profileImage } // label, dateLabel }
                //Children = { firstName, label }
            };



            var text = new StackLayout {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(0, 0, 0, 0),
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children          = { label, dateLabel }
            };

            layout = new StackLayout {
                Padding           = new Thickness(10, 10, 5, 10),
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children          = { imageStackLayout, text }        // profileImage, text }//, dateLabel}//, dateLabel } //, fav }
            };

            View = layout;
        }