Пример #1
0
        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;
        }
Пример #2
0
        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);
        }