示例#1
0
 /// <summary>
 /// Method that calls service to polulate Json Posts
 /// </summary>
 private void PopulateJsonPosts()
 {
     //This makes an async call to the service
     Task <List <JsonPostViewObject> > .Factory.StartNew(() =>
     {
         return(ModelToViewObjectConverter.Convert(_service.GetPosts()));
     }).ContinueWith((t) =>
     {
         if (t != null && t.Result != null &&
             t.Result.Count > 0)
         {
             //Polulate results, pump up on UI thread
             if (App.Current != null)
             {
                 App.Current.Dispatcher.BeginInvoke((Action) delegate()
                 {
                     t.Result.ForEach(v => JsonPosts.Add(v));
                     if (JsonPosts != null && JsonPosts.Count > 0)
                     {
                         SelectedJsonPlaceHolder = JsonPosts.FirstOrDefault();
                     }
                 });
             }
             else //Test
             {
                 t.Result.ForEach(v => JsonPosts.Add(v));
                 if (JsonPosts != null && JsonPosts.Count > 0)
                 {
                     SelectedJsonPlaceHolder = JsonPosts.FirstOrDefault();
                 }
             }
         }
     });
 }
示例#2
0
        /// <summary>
        /// Just fetch Json Post as per supplied criteria
        /// </summary>
        /// <param name="param"></param>
        private void GetSelectedPost(object param)
        {
            if (_service != null && _selectedJsonPlaceHolder != null)
            {
                JsonPostDetailModel jsonPlaceHolderModel = _service.GetPost(_selectedJsonPlaceHolder.Id);

                if (jsonPlaceHolderModel != null)
                {
                    //Just populate fetched object after service call
                    SelectedJsonPlaceHolder = ModelToViewObjectConverter.Convert(jsonPlaceHolderModel);
                    NotifyPropertyChanged("CopyModeEnabled");
                    RenderPostContentFormat();
                }
            }
        }