Skip to content

Instantly share code, notes, and snippets.

@jonathanpeppers
Created December 15, 2016 02:48
Show Gist options
  • Select an option

  • Save jonathanpeppers/c6b0dbb4f61660bf1abd11354024c0d5 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanpeppers/c6b0dbb4f61660bf1abd11354024c0d5 to your computer and use it in GitHub Desktop.
For Packt, AddFriend() in FriendViewModel
public async Task AddFriend()
{
if (settings.User == null)
throw new Exception("Not logged in.");
if (string.IsNullOrEmpty(UserName))
throw new Exception("Username is blank.");
IsBusy = true;
try
{
var friend = await service
.AddFriend(settings.User.Name, UserName);
//Update our local list of friends
var friends = new List<User>();
if (Friends != null)
friends.AddRange(Friends);
friends.Add(friend);
Friends = friends.OrderBy(f => f.Name).ToArray();
}
finally
{
IsBusy = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment