using System; using MahApps.Twitter.Models; using MahTweets.Mango.Core.Models; namespace MahTweets.Extensions.Twitter.Mango.Extensions { public static class ContactExtensions { public static Contact UpdateContact(this Contact oldContact, User remoteContact) { oldContact.Id = remoteContact.Id.ToString(); oldContact.Website = remoteContact.Url; oldContact.FullName = remoteContact.Name; oldContact.Private = remoteContact.Protected; var imageUri = new Uri(remoteContact.ProfileImageUrl); if (oldContact.ImageUrl != imageUri) { oldContact.ImageUrl = (imageUri); } oldContact.Bio = remoteContact.Description; if (remoteContact.FollowersCount != null) oldContact.Followers = Convert.ToInt32((long) remoteContact.FollowersCount); if (remoteContact.FriendsCount != null) oldContact.Following = Convert.ToInt32((long) remoteContact.FriendsCount); if (remoteContact.StatusCount != null) oldContact.Updates = Convert.ToInt32((long) remoteContact.StatusCount); return oldContact; } } }