public async Task <Result <List <PanelUserDTO> > > GetAllUserAsync(PanelUserSearchModel searchModel) { searchModel.FixPageDefinations(); int?companyId = searchModel.CompanyId; IQueryable <PanelUser> source = _unitOfWork.EntityRepository <PanelUser>().GetQueryable((PanelUser w) => w.IsDeleted == false && ((object)companyId == null || (object)(int?)w.CompanyId == (object)companyId), null); if (!string.IsNullOrEmpty(searchModel.SearchText)) { source = from w in source where w.Name.Contains(searchModel.SearchText) || w.Email.Contains(searchModel.SearchText) select w; } return(Result.Data(await EntityFrameworkQueryableExtensions.ToListAsync <PanelUserDTO>(from s in (from o in source orderby o.Id select o).Skip(searchModel.PageSize * searchModel.PageIndex).Take(searchModel.PageSize) select new PanelUserDTO { Id = s.Id, CompanyId = s.CompanyId, Role = s.Role, Name = s.Name, Email = s.Email, PlaceName = (s.PlaceId.HasValue ? s.Place.Name : null), Company = new CompanyInfoDTO { Name = s.Company.Name }, CreatedDate = s.CreatedDate }, default(CancellationToken)))); }
public async Task <ViewResult> Index() { PanelUserModel model = new PanelUserModel(); int? companyId = base.CurrentUser.CompanyId; if (base.CurrentUser.Role == UserRole.SuperAdmin) { model.IsSuperAdmin = true; companyId = null; } PanelUserSearchModel panelUserSearchModel = new PanelUserSearchModel { CompanyId = companyId, Page = 1, PageSize = 1000 }; Result <List <PanelUserDTO> > result = await _panelUserService.GetAllUserAsync(panelUserSearchModel); if (result.IsSuccess) { model.Users = result.Data; } return(this.View((object)model)); }