public ActionResult Index(int? page) { //paging var api = GoEat.Core.GoEatApi.Instance; page = (page ?? 1); const int pageSize = 10; var totalRow = api.CountAdminTransactions(Urls.GetRestaurantId(), TransactionStatus.Success); var lastPageIndex = getLastPageIndex(totalRow, pageSize); page = page <= lastPageIndex ? page : 1; int startIndex = page == 1 ? 1 : (((page.Value - 1) * pageSize) + 1); int endIndex = startIndex + pageSize - 1; ViewBag.currentPageIndex = page; ViewBag.lastPageIndex = lastPageIndex; var result = api.GetTransactions(startIndex, endIndex, Urls.GetRestaurantId(), TransactionStatus.Success); var transactions = new TransactionsViewModel(); if (result.Succeeded) { transactions.transactions = result.Data; } return View(transactions); }
public ActionResult GetTransactions(int? page, int fromDay, int fromMonth, int fromYear, int toDay, int toMonth, int toYear) { if (this.HasPermission("access_transaction")) { return RedirectToAction("index", "transaction"); } DateTime fromDate = new DateTime(fromYear, fromMonth, fromDay); DateTime toDate = new DateTime(toYear, toMonth, toDay); toDate = toDate.AddMinutes(1439); var api = GoEat.Core.GoEatApi.Instance; //paging page = (page ?? 1); const int pageSize = 10; var totalRow = api.CountCustomerTransactions(CurrentUser.Id, fromDate, toDate); var lastPageIndex = getLastPageIndex(totalRow, pageSize); page = page <= lastPageIndex ? page : 1; int startIndex = page == 1 ? 1 : (((page.Value - 1) * pageSize) + 1); int endIndex = startIndex + pageSize - 1; ViewBag.currentPageIndex = page; ViewBag.lastPageIndex = lastPageIndex; var result = api.GetTransactions(startIndex, endIndex, CurrentUser.Id, fromDate, toDate); var transactions = new TransactionsViewModel(); if (result.Succeeded) { transactions.transactions = result.Data; } return PartialView("_transactionHistory", transactions); }