public async Task <IBusinessLoadByPagingResult <User> > LoadAsync(string searchExpr , Func <IQueryable <User>, IOrderedQueryable <User> > orderBy = null , int pageNumber = 0 , int pageSize = 15) { var entites = new BusinessLoadByPagingResult <User>(); try { var query = unitOfWork.UserDataService.GetQuery() .IncludeFilter(x => x.Roles.Where(r => r.Deleted == false)) .IncludeFilter(x => x.Roles.Select(r => r.Role)) .Where(x => (x.UserName.Contains(searchExpr) || x.Email.Contains(searchExpr) || x.Name.Contains(searchExpr) || x.LastName.Contains(searchExpr) || x.Roles.Any(r => r.Role.FaName.Contains(searchExpr))) && x.Deleted == false && x.Roles.Any(r => r.Role.IsUsingBySystem == false)); entites.TotalRows = await query.CountAsync(); query = orderBy(query); query = query.Skip(pageNumber).Take(pageSize); entites.ResultValue = await query.ToListAsync(); entites.ReturnStatus = true; } catch (Exception ex) { CatchException(ex, entites, ""); } return(entites); }
public async Task <IBusinessLoadByPagingResult <GroupByStartEndDate> > LoadGroupByStartEndDateGoalsAync(bool?isUsed, int pageNumber = 0, int pageSize = 15) { var result = new BusinessLoadByPagingResult <GroupByStartEndDate>(); try { var query = (from gl in unitOfWork.GoalDataService.GetQuery() where (isUsed == null || gl.IsUsed == isUsed) && (gl.GoalGoodsCategoryTypeId == GoalGoodsCategoryTypeEnum.Single || gl.GoalGoodsCategoryTypeId == GoalGoodsCategoryTypeEnum.Group) && gl.Deleted == false group gl by new { gl.StartDate, gl.EndDate } into grpgl select new { grpgl.Key.StartDate, grpgl.Key.EndDate }); result.TotalRows = await query.CountAsync(); var takePaging = await query.OrderBy(x => x.StartDate).Skip(pageNumber).Take(pageSize).ToListAsync(); result.ResultValue = takePaging.Select(x => new GroupByStartEndDate { EndDate = x.EndDate, StartDate = x.StartDate, IsUsed = isUsed }).ToList(); result.ReturnStatus = true; } catch (Exception ex) { CatchException(ex, result, ""); } return(result); }
public async Task <IBusinessLoadByPagingResult <OrgStructureShareDTO> > LoadOrgStructureShareDTOByPagingAsync(string brandName , Func <IQueryable <OrgStructureShareDTO>, IOrderedQueryable <OrgStructureShareDTO> > orderBy , int pageNumber = 0 , int pageSize = 15) { var result = new BusinessLoadByPagingResult <OrgStructureShareDTO>(); try { var queryResult = await unitOfWork.OrgStructureShareDataService.GetOrgStructureShareDTOByPagingAsync(brandName, orderBy, pageNumber, pageSize); result.ResultValue = queryResult.Item1; result.TotalRows = queryResult.Item2; result.ReturnStatus = true; } catch (Exception ex) { CatchException(ex, result, ""); } return(result); }
public virtual IBusinessLoadByPagingResult <TEntity> Load(Expression <Func <TEntity, bool> > where = null , Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null , int pageNumber = 0 , int pageSize = 15 , params Expression <Func <TEntity, object> >[] includes) { IBusinessLoadByPagingResult <TEntity> entites = new BusinessLoadByPagingResult <TEntity>(); try { int totalRows; entites.ResultValue = dataRepository.GetByPaging(out totalRows, where, orderBy, pageNumber, pageSize, includes).AsEnumerable <TEntity>().ToList(); entites.TotalRows = totalRows; entites.ReturnStatus = true; } catch (Exception ex) { CatchException(ex, entites, ""); } return(entites); }
public virtual async Task <IBusinessLoadByPagingResult <TEntity> > LoadAsync(Expression <Func <TEntity, bool> > where = null , Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null , int pageNumber = 0 , int pageSize = 15 , params Expression <Func <TEntity, object> >[] includes) { IBusinessLoadByPagingResult <TEntity> entites = new BusinessLoadByPagingResult <TEntity>(); try { entites.ResultValue = await dataRepository.GetByPagingAsync(where, orderBy, pageNumber, pageSize, includes); entites.TotalRows = await dataRepository.GetCountAsync(where : where); entites.ReturnStatus = true; } catch (Exception ex) { CatchException(ex, entites, ""); } return(entites); }