Пример #1
0
 public UserInfoPage()
 {
     InitializeComponent();
     vm = BindingContext as UserInfoPageViewModel;
     userplaylists.ChildAdded += Userplaylists_ChildAdded;
     subplaylists.ChildAdded  += Subplaylists_ChildAdded;
 }
Пример #2
0
        // GET /User/Info
        public ActionResult Info(string user, string genre)
        {
            UserInfoPageViewModel pageModel = new UserInfoPageViewModel();

            if (Session["user"] != null && Session["user"].GetType() == (typeof(ViewUser)))
            {
                pageModel.user = (ViewUser)(Session["user"]);
            }
            Neo4jDataProvider dbNeo4j = new Neo4jDataProvider();

            #region NavBarData

            if (genre == "All" || genre == "")
            {
                pageModel.genre = null;
            }
            else
            {
                pageModel.genre = genre;
            }

            //Getting artists
            pageModel.artists = dbNeo4j.ArtistRead(pageModel.genre);
            for (char c = 'A'; c <= 'Z'; c++)
            {
                if (pageModel.artists.ContainsKey(c.ToString()))
                {
                    List <ViewArtist> tmp = pageModel.artists[c.ToString()];
                    pageModel.artists[c.ToString()] = tmp.OrderBy(x => x.name).ToList();
                }
            }


            //Getting genres
            pageModel.genres = dbNeo4j.GenreRead();
            pageModel.genres.Sort();

            #endregion

            //Geting user created songs
            pageModel.userSongs = dbNeo4j.SongRead(user);

            //Geting user
            pageModel.profile = dbNeo4j.UserRead(user);

            ViewBag.showNav = true;
            return(View(pageModel));
        }
Пример #3
0
        /// <summary>
        /// 通过用户名获取所有的用户信息集合
        /// </summary>
        /// <param name="name">用户名</param>
        /// <returns>用户信息</returns>
        public UserInfoPageViewModel GetListbyName(string name, int pageIndex, int pageSize)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                //获取用户信息列表
                List <UserInfoViewModel> list;

                int pageCount, count;//总页数,总行数

                //获取数据总条数
                count = db.OT_User.Where(a => a.Name.Contains(name) & a.IsDelete == (byte)EDataStatus.Normal & a.Name != "admin").Count();

                //获取总页数
                pageCount = count % pageSize > 0 ? count / pageSize + 1 : count / pageSize;

                //如果页数大于总页数,或者小于1,则返回第一页
                if (pageIndex > pageCount || pageIndex < 1)
                {
                    pageIndex = 1;
                }

                //获取用户信息
                if (pageIndex == 1)
                {
                    list = db.OT_User.Where(a => a.Name.Contains(name) & a.IsDelete == (byte)EDataStatus.Normal & a.Name != "admin").OrderBy(a => a.Name).Take(pageSize).Select(a => new UserInfoViewModel
                    {
                        UserId   = a.Id,
                        UserName = a.Name,
                    }).ToList();
                }
                else
                {
                    int excludedRows = (pageIndex - 1) * pageSize;//计算起始索引

                    list = db.OT_User.Where(a => a.Name.Contains(name) & a.IsDelete == (byte)EDataStatus.Normal & a.Name != "admin").OrderBy(a => a.Name).Skip(excludedRows).Take(pageSize).Select(a => new UserInfoViewModel
                    {
                        UserId   = a.Id,
                        UserName = a.Name,
                    }).ToList();
                }

                //给用户的角色赋值
                foreach (UserInfoViewModel model in list)
                {
                    model.RoleList = db.OT_UserRole.Where(a => a.UserId == model.UserId && a.IsDelete == (byte)EDataStatus.Normal).Select(a => new RoleInfoViewModel
                    {
                        RoleId   = a.RoleId,
                        RoleName = a.OT_Role.Name
                    }).ToList();
                }

                //构建分页用户信息并返回
                UserInfoPageViewModel upModel = new UserInfoPageViewModel();
                upModel.Count     = count;
                upModel.PageCount = pageCount;
                upModel.PageIndex = pageIndex;
                upModel.UserInfo  = list;

                return(upModel);
            }
        }