public async Task <PagedStockList> GetStockEntries(int articleId, int environmentId, int page, int itemsPerPage) { IQueryable <StockEntryValue> qry = _context.StockEntryValues .Where(se => se.EnvironmentId == environmentId && se.ArticleId == articleId) .OrderBy(se => se.ExpireDate).ThenByDescending(se => se.IsOpened); return(await PagedStockList.CreateAsync(qry, page, itemsPerPage)); }
public async Task <IActionResult> GetArticleStock(int articleId, int environmentId, int pageNumber, int itemsPerPage) { if (!await _authService.IsPermitted(User, environmentId, PermissionFlags.IsOwner | PermissionFlags.CanScan)) { return(Unauthorized()); } PagedStockList stockEntries = await _repo.GetStockEntries(articleId, environmentId, pageNumber, itemsPerPage); IEnumerable <StockEntryValueDto> stockEntriesDto = _mapper.Map <IEnumerable <StockEntryValueDto> >(stockEntries); Response.AddPagination(stockEntries.CurrentPage, stockEntries.PageSize, stockEntries.TotalCount, stockEntries.TotalPages); Response.AddCustomHeader("TotalStockAmount", stockEntries.TotalStockAmount.ToString()); return(Ok(stockEntriesDto)); }