public ActionResult ViewUser(int uid) { // 用户基本信息 UserDetailItem user = Service.GetUserDetailItems(db, uid); // 用户相关信息 ViewBag.CommentsNum = db.Comment.Where(x => x.uid == uid).Count(); ViewBag.PartComments = Service.GetCommentItemsByUid(db, uid, 1, 3); return(View(user)); }
public UserDetailItem getUserDetail(string id) { var userDetailItem = new UserDetailItem(); var userItem = new UserItem(); var user = UserRepository.Find(id); if (user == null) { return(new UserDetailItem()); } userItem = user.Adapt <User, UserItem>(); var roleIds = UserRoleDetail.GetAll().Where(r => r.UserId == user.Id).Select(r => r.RoleId).ToArray(); var roles = AnraRole.GetAll().Where(r => roleIds.Contains(r.RoleId)); userDetailItem.UserName = userItem.FirstName + userItem.LastName; userDetailItem.UserEmail = userItem.Email; userDetailItem.UserRoles = roles.Adapt <IEnumerable <Role>, List <ViewModel.Roles.RoleItem> >(); userDetailItem.PhoneNumber = userItem.PhoneNumber != null ? userItem.PhoneNumber : "000000000"; return(userDetailItem); }