public virtual PageDataOutputDto <UserDto> GetPageData(UserPageInputDto vm) { if (vm == null) { throw new ApiParamNullException(nameof(vm)); } if (vm.PageIndex < 1) { throw new ApiParamException(nameof(vm.PageIndex)); } if (vm.PageSize < 1) { throw new ApiParamException(nameof(vm.PageSize)); } var pagedata = this.userRepository.GetPageData(vm); List <RoleDto> rolelsit = new List <RoleDto>(); foreach (var m in pagedata.Data) { var role = rolelsit.Find(q => q.Id == m.RoleId); if (role == null) { role = roleRepository.Get(m.RoleId); } m.RoleName = role?.Name; } return(pagedata); }
public IActionResult GetPageData(UserPageInputDto vm) { if (vm != null && this.ModelState.IsValid) { var data = this.userService.GetPageData(vm); return(Success(data)); } return(Error()); }
public virtual PageDataOutputDto <UserDto> GetPageData(UserPageInputDto vm) { PageDataOutputDto <UserDto> pageData = null; using (var db = this.GetContext()) { var query = from q in db.User where q.IsDelete == false select new UserDto { Id = q.Id, Account = q.Account, Name = q.Name, //Password = q.Password, RoleId = q.RoleId, Mail = q.Mail, Mobile = q.Mobile, Status = q.Status, IsSystem = q.IsSystem, UpdateTime = q.UpdateTime, CreateTime = q.CreateTime }; if (!string.IsNullOrEmpty(vm.RoleId)) { query = query.Where(q => q.RoleId == vm.RoleId); } if (vm.Status.HasValue) { var status = vm.Status.Value; query = query.Where(q => q.Status == status); } if (!string.IsNullOrEmpty(vm.Keyword)) { var value = vm.Keyword.DbLike(DbLikeType.All); query = query.Where(q => EF.Functions.Like(q.Account, value) || EF.Functions.Like(q.Name, value) || EF.Functions.Like(q.Mobile, value) || EF.Functions.Like(q.Mail, value)); } pageData = query.ToPage(vm); } return(pageData); }