public static List<UserViewModel> ToListOfUserViewModel(List<User> users) { List<UserViewModel> usersInListOfUserViewModel = new List<UserViewModel>(); foreach (User user in users) { UserViewModel userInUserViewModel = new UserViewModel(user); usersInListOfUserViewModel.Add(userInUserViewModel); } return usersInListOfUserViewModel; }
public ActionResult CurrentUserJson() { UserViewModel currentUserViewModel = new UserViewModel(); if (WebSecurity.IsAuthenticated) { int currentUserUserId = WebSecurity.CurrentUserId; User currentUser = UsersData.GetUserByUserId(currentUserUserId); currentUserViewModel = new UserViewModel(currentUser); } return Json(currentUserViewModel, JsonRequestBehavior.AllowGet); }