private string CreateResourceUri(ResourcePaging paging, ResourceTypeUri type) { switch (type) { case ResourceTypeUri.PreviousPage: return(_urlHelper.Link("GetCashAccounts", new { pageNumber = paging.Page - 1, pageSize = paging.PageSize })); case ResourceTypeUri.NextPage: return(_urlHelper.Link("GetCashAccounts", new { pageNumber = paging.Page + 1, pageSize = paging.PageSize })); default: return(_urlHelper.Link("GetCashAccounts", new { pageNumber = paging.Page, pageSize = paging.PageSize })); } }
public async Task <ActionResult> Get([FromQuery] ResourcePaging paging) { var condition = new QueryCondition <CashAccount>(); condition.QueryPredicates.Add(x => x.IsActivated); var results = await _service.GetAllCashAccounts(condition, paging); //continue metadata for pagination creation. return(Ok(results)); }
public async Task <IEnumerable <ExpenseModel> > GetAllExpenses(ResourcePaging paging) { var condition = new QueryCondition <Expense>(); condition.QueryIncludes.Add(x => x.CashAccount); var results = await Query(condition) .Skip(paging.PageSize * (paging.Page - 1)) .Take(paging.PageSize) .Select(e => new ExpenseModel() { Amount = e.Amount, Beneficiary = e.Beneficiary, Description = e.ExpenseDescription, ExpenseDate = e.ExpenseDate.LocalDateTime, ModeOfPayment = e.ModeOfPayment, AccountName = e.CashAccount.AccountName }).ToListAsync(); return(results); }
public async Task <IEnumerable <CashAccountModel> > GetAllCashAccounts( QueryCondition <CashAccount> conditions, ResourcePaging paging) { //var qResult = await PagedList<CashAccount>.Create(Query(conditions), paging.Page, paging.PageSize); var queryResult = await Query(conditions) .Skip(paging.PageSize * (paging.Page - 1)) .Take(paging.PageSize) .Select(c => new CashAccountModel() { Id = c.CashAccountId.ToString(), AccountActive = c.IsActivated, AccountBalance = c.AccountBalance, CashAccountName = c.AccountName, Currency = c.Currency.ToString(), DateCreated = c.CreatedDate }).ToListAsync().ConfigureAwait(false); return(queryResult); }
public Task <IEnumerable <ExpenseModel> > GetExpenses(QueryCondition <Expense> conditions, ResourcePaging paging) { throw new System.NotImplementedException(); }
public async Task <IEnumerable <IncomeModel> > GetAllIncomes(QueryCondition <Income> conditions, ResourcePaging paging) { var results = await Query(conditions) .Skip(paging.PageSize * (paging.Page - 1)) .Take(paging.PageSize) .Select(x => new IncomeModel() { IncomeDate = x.IncomeDate.LocalDateTime, PaymentType = x.ModeOfPayment, Amount = x.Amount, Currency = x.Currency, CashBalance = x.CashAccount.AccountBalance, IncomeType = x.IncomeType, CashAccount = x.CashAccount.AccountName }).ToListAsync().ConfigureAwait(false); return(results); }