示例#1
0
        private void CreateMovie(MovieModel movie)
        {
#if SILVERLIGHT_4
            template.PostForLocationAsync("movie", movie,
                                          r =>
            {
                if (r.Error == null)
                {
                    RefreshMovies();
                }
            });
#else
            // Using Task Parallel Library (TPL)
            template.PostForLocationAsync("movie", movie)
            .ContinueWith(task =>
            {
                if (!task.IsFaulted)
                {
                    RefreshMovies();
                }
            }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());     // execute on UI thread
#endif
        }
示例#2
0
        public Task <Uri> AddBookmarkAsync(string url, bool favorite = false, bool archived = false)
        {
            EnsureIsAuthorized();
            var parameters = new NameValueCollection();

            parameters.Add("url", url);
            if (favorite)
            {
                parameters.Add("favorite", "1");
            }
            if (archived)
            {
                parameters.Add("archive", "1");
            }
            return(_restTemplate.PostForLocationAsync("bookmarks", parameters));
        }