public ActionResult MyList() { Users user = new Users_BLL().GetCurrentUser(); if (user.Users_Role.RoleName != "普通用户") { OfficialAccount_BLL bll = new OfficialAccount_BLL(); List <OfficialAccount> sourselist = bll.GetList().ToList(); AutoMapper.Mapper.CreateMap <OfficialAccount, OfficialAccount_ViewModel>() .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Users.UserName)); List <OfficialAccount_ViewModel> list = AutoMapper.Mapper.Map <List <OfficialAccount_ViewModel> >(sourselist); ViewBag.IsAdmin = true; return(View(list)); } else { OfficialAccount_BLL bll = new OfficialAccount_BLL(); List <OfficialAccount> sourselist = bll.GetList(a => a.UserID == user.UserID).ToList(); AutoMapper.Mapper.CreateMap <OfficialAccount, OfficialAccount_ViewModel>() .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Users.UserName)); List <OfficialAccount_ViewModel> list = AutoMapper.Mapper.Map <List <OfficialAccount_ViewModel> >(sourselist); ViewBag.IsAdmin = false; return(View(list)); } }
public ActionResult Select() { Users user = new Users_BLL().GetCurrentUser(); OfficialAccount_BLL bll = new OfficialAccount_BLL(); List <OfficialAccount> list = new List <OfficialAccount>(); if (user.Users_Role.RoleName != "普通用户") { list = bll.GetList() .OrderByDescending(a => a.CreateTime) .ToList(); } else { list = bll.GetList(a => a.UserID == user.UserID) .OrderByDescending(a => a.CreateTime) .ToList(); } return(View(list)); }
public PartialViewResult _OrderMenu() { Users user = new Users_BLL().GetCurrentUser(); OfficialAccount_BLL bll = new OfficialAccount_BLL(); List <OfficialAccount> list = new List <OfficialAccount>(); if (user.Users_Role.RoleName != "普通用户") { list = bll.GetList(a => a.IsConfigure == true) .OrderByDescending(a => a.CreateTime) .ToList(); } else { list = bll.GetList(a => a.UserID == user.UserID && a.IsConfigure == true) .OrderByDescending(a => a.CreateTime) .ToList(); } return(PartialView(list)); }