title: Asp.net - Refactor action
body: <p>I have this "problem" that i have code like this in many of my controller actions:</p>
  
  <pre><code>var users = new List&lt;SelectListItem&gt;();
  foreach(var user in userRepository.GetAll())
  {
   var item = new SelectListItem { Text = user.FriendlyName, Value = user.UserId.ToString() };
  
   if (User.Identity.Name == user.UserName)
    item.Selected = true;
  
   users.Add(item);
  }
  
  ViewData["Users"] = users;
  </code></pre>
  
  <p>How would you refactor this to a more clean solution? I want to get DRY!</p>