Exemplo n.º 1
0
 public ActionResult Users(VModel.SyRole.RUser m)
 {
     if (m.Grid == null)
     {
         m.Grid       = new Common.Model.PList <VModel.SyRole.UserGrid>();
         m.Grid.Pager = new Common.Model.Pager();
         m.Grid       = Bll.SyRoleBll.GetUsers(m);
     }
     else
     {
         m.Grid = Bll.SyRoleBll.GetUsers(m);
         if (Request.IsAjaxRequest())
         {
             return(PartialView("_UsersGrid", m));
         }
     }
     return(View(m));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据角色ID获取用户
        /// </summary>
        /// <returns></returns>
        public static Common.Model.PList <VModel.SyRole.UserGrid> GetUsers(VModel.SyRole.RUser m)
        {
            Common.Model.PList <VModel.SyRole.UserGrid> pl = new Common.Model.PList <VModel.SyRole.UserGrid>();
            pl.Data = new List <VModel.SyRole.UserGrid>();

            using (var db = new fz_basicEntities())
            {
                var query = db.sy_user.OrderBy(o => o.Account).Where(w => w.sy_user_and_role.Where(w1 => w1.RoleId == m.id).Select(s2 => s2.UserId).Contains(w.Id) && w.IsEnabled).AsQueryable();
                pl.Pager = new Common.Model.Pager(m.Grid.Pager.PageIndex, m.Grid.Pager.PageSize, query.Count());
                pl.Data  = query.Skip((m.Grid.Pager.PageIndex - 1) * m.Grid.Pager.PageSize).Take(m.Grid.Pager.PageSize).Select(s => new VModel.SyRole.UserGrid
                {
                    Account   = s.Account,
                    Name      = s.Name,
                    RoleNames = s.sy_user_and_role.Select(s1 => s1.sy_role.Name).ToList(),
                    Time      = s.sy_user_and_role.Select(s1 => s1.Time).FirstOrDefault()
                }).ToList();
            }

            return(pl);
        }