SHARE
TWEET

Untitled

a guest Mar 21st, 2017 70 in 8 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public string ListFriends(string username)
  2.         {
  3.             using (PhotoShareContext context = new PhotoShareContext())
  4.             {
  5.                 var friends = context.Users.SingleOrDefault(u => u.Username == username).Friends.ToList();
  6.  
  7.                 if(friends.Count == 0)
  8.                 {
  9.                     return "No friends for this user. :(";
  10.                 }
  11.  
  12.                 string result = "Friends:";
  13.  
  14.                 foreach(var friend in friends.OrderBy(f => f.Username))
  15.                 {
  16.                     result += $"\n-{friend.Username}";
  17.                 }
  18.  
  19.                 return result;
  20.  
  21.             }
  22.         }
RAW Paste Data
Top