I wrote a simple generic method for making POST calls to MVC4 WebApi for use on Windows Phone 8 (But you can use it elsewhere).  The idea is simple: Create one set of generic methods that will take a generic TResultType, an Api Uri, and optionally some data to post and return back a strongly typed response object.

Usage is simple:

This allows you to simply use await to make your MVC4 WebApi calls and get back strongly typed objects.  The Post code uses Newtonsoft Json library to deserialize the response string as an object.

I will package this up as a simple GIT project when I have time and create a nuget package so that everyone can use this simply.

First off, I did not author this from scratch.  Instead, I added some functionality to this class that WindowsPhoneGeek published. I wanted to add CanExecute() and Execute() methods that take no parameter.   Most of the commands I use in my MVVM apps tend to be based on the state of the ViewModel anyway and thus I do not need the parameters.

Here is the DelegateCommand.cs class and the cmds snippet that lets you quickly add a command to any ViewModel.

      

Command code would look like the following:

The code for the DelegateCommand.cs looks like this:

While building a small application for viewing passwords (basically pwsafe for Windows Phone 8) I realized that because of the restrictions of WP8 with regard to the file system I needed a way to pull password files from a remote storage.  As it turns out, the SkyDrive API is comprehensive but did not have a concise Windows Phone 8 API so I started building one.

https://github.com/dsandor/SkydriveHelper

The code is very basic at this point but I do intend on improving it.

With the API helper you can:

These commands will allow you to do the majority of what you need (except upload).

To use it, simply place a SignInButton found in the Microsoft.Live.Controls assembly for Windows Phone 8.  On the OnSessionChanged event simply pass the Session to the helper and it is ready to go.

There is a very simple sample application included in the source tree that will let you get the directories from the skydrive and download a file.

This is a pretty rookie mistake with .NET 4.5 and the new async / await operators.  While searching for the answer I found a lot of noise and no valuable answers so I thought I would notate the solution on my blog.

The short answer is that any method that uses await must itself be marked with async.

Take this code for example:

Error    2    The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task’.