public async Task <BasePagination <PersonModel> > LoadPerson(string page = null) { var currentPage = 1; if (!string.IsNullOrEmpty(page)) { var uri = new Uri(page); currentPage = int.Parse(HttpUtility.ParseQueryString(uri.Query)["page"]); } var response = await sWApiService.GetPeople(currentPage).ConfigureAwait(false); if (!response.Results.Any()) { return(new BasePagination <PersonModel>()); } var result = new BasePagination <PersonModel>(); foreach (var person in response.Results) { result.Results.Add(await buildPersonObject(person)); } result.Count = response.Count; result.Next = response.Next; response.Previous = response.Previous; return(result); }
public async Task <ICollection <Corretora> > Get(BasePagination pagination) { pagination.Count = _bCorretora.GetListAllCount(x => true).Result; return(await _bCorretora.GetListAll(x => true)); }
public dynamic GetOrder(BasePagination paging) { return(ExecuteInMonitoring(() => { return orderLogic.GetOrderPaging(paging); })); }
public dynamic GetProduct(BasePagination paging) { return(ExecuteInMonitoring(() => { var products = this.productLogic.GetProduct(paging); return products.Select(p => p.ToViewModel <ProductViewModel>()); })); }
public List <OrderViewModel> GetOrderPaging(BasePagination paging) { var orders = dbContext.Order.Where(o => o.IsAvailable == true) .OrderBy(o => o.Id) .Skip((paging.Page - 1) * paging.Size) .Take(paging.Size); return(orders.Select(o => o.ToViewModel <OrderViewModel>()).ToList()); }
public List <Product> GetProduct(BasePagination paging) { var products = dbContext.Product.Where(p => p.IsActive == true) .OrderBy(p => p.Id) .Skip((paging.Page - 1) * paging.Size) .Take(paging.Size); return(products.ToList()); }
public async Task <ICollection <TEntity> > GetListOrderByDescending(Expression <Func <TEntity, object> > orderpagination, BasePagination pagination, Expression <Func <TEntity, bool> > where, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderByDescending = null) { IQueryable <TEntity> query = _db.Set <TEntity>(); if (where != null) { query = query.Where(where).OrderByDescending(orderpagination).Skip(pagination.PageSkip).Take(pagination.PageTake); } if (orderByDescending != null) { return(await orderByDescending(query).ToListAsync()); } else { return(await query.ToListAsync()); } }
public async Task <ICollection <TEntity> > GetInclude(Expression <Func <TEntity, object> > orderpagination, BasePagination pagination, Expression <Func <TEntity, bool> > where = null, Expression <Func <TEntity, object> > include = null, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null) { //return _db.Set<TEntity>().Where(where).Include(include).AsQueryable(); IQueryable <TEntity> query = _db.Set <TEntity>(); if (where != null) { if (include != null) { if (include.Body is NewExpression) { (include.Body as NewExpression).Arguments.ToList().ForEach(x => { var inc = x as MemberExpression; string s = inc.ToString(); s = s.Substring(s.IndexOf('.') + 1); query = query.Include(s); }); query = query.Where(where).OrderBy(orderpagination).Skip(pagination.PageSkip).Take(pagination.PageTake); } else { query = query.Where(where).Include(include).OrderBy(orderpagination).Skip(pagination.PageSkip).Take(pagination.PageTake); } } else { query = query.Where(where).Include(include).OrderBy(orderpagination).Skip(pagination.PageSkip).Take(pagination.PageTake); } } if (orderBy != null) { return(await orderBy(query).ToListAsync()); } else { return(await query.ToListAsync()); } }
public async Task <ICollection <TEntity> > GetListPrimitive(Expression <Func <TEntity, object> > orderpagination, BasePagination pagination, Expression <Func <TEntity, bool> > where = null, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null) { IQueryable <TEntity> query = _db.Set <TEntity>(); if (where != null) { var initialQuery = query.Where(where); var orderedQuery = orderBy(initialQuery); query = orderedQuery.Skip(pagination.PageSkip).Take(pagination.PageTake); //query = query.Where(where).OrderBy(orderpagination).Skip(pagination.PageSkip).Take(pagination.PageTake); } if (orderBy != null) { return(await orderBy(query).ToListAsync()); } else { return(await query.ToListAsync()); } }
public async Task <ICollection <TEntity> > GetInclude(Expression <Func <TEntity, object> > orderpagination, BasePagination pagination, Expression <Func <TEntity, bool> > where = null, Expression <Func <TEntity, object> > include = null, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null) { return(await repository.GetInclude(orderpagination, pagination, where, include, orderBy)); }
public async Task <ICollection <TEntity> > GetListOrderByDescending(Expression <Func <TEntity, object> > orderpagination, BasePagination pagination, Expression <Func <TEntity, bool> > where, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderByDescending = null) { return(await repository.GetListOrderByDescending(orderpagination, pagination, where, orderByDescending)); }