public async Task <OrderSearchViewResult> GetOrders(int pageNumber, OrderStatusViewEnum status) { var itemsPerPage = Convert.ToInt32(ConfigurationManager.AppSettings["AdminOrdersPerPage"]); var itemsToSkip = (pageNumber - 1) * itemsPerPage; var dbStatus = status.ToDbEnum(); OrderSearchResult result = null; if (status == OrderStatusViewEnum.ALL) { result = await _iOrderRepository.GetAllOrders(itemsPerPage, itemsToSkip); } else { result = await _iOrderRepository.GetOrdersByStatus(itemsPerPage, itemsToSkip, dbStatus); } if (result != null) { var orderSearchViewResult = new OrderSearchViewResult { TotalCount = result.TotalCount, Orders = result.Orders.Select(x => x.ToViewModel()) }; return(orderSearchViewResult); } return(null); }
public async Task <OrderSearchViewResult> GetUserOrders(int pageNumber, string userId) { var itemsPerPage = Convert.ToInt32(ConfigurationManager.AppSettings["UserOrdersPerPage"]); var itemsToSkip = (pageNumber - 1) * itemsPerPage; var userOrders = await _iOrderRepository.GetUserOrders(itemsPerPage, itemsToSkip, userId); var orderSearchViewResult = new OrderSearchViewResult { TotalCount = userOrders.TotalCount, Orders = userOrders.Orders.Select(x => x.ToViewModel()) }; return(orderSearchViewResult); }