Ejemplo n.º 1
0
        public async Task <IActionResult> Index(int page = 1)
        {
            try
            {
                // Get the current user to show his/her transactions
                User currentUser = await _userLogic.GetCurrentUser(HttpContext.User);

                IndexTransactionViewModel model = new IndexTransactionViewModel
                {
                    Transactions = _transactionLogic.List()
                                   .Where(t => t.PlayerId == currentUser.PlayerId)
                                   .OrderByDescending(t => t.TransactionId)
                                   .Skip((page - 1) * PageSize)
                                   .Take(PageSize),
                    PagingInfo = new PagingInfo
                    {
                        CurrentPage  = page,
                        ItemsPerPage = PageSize,
                        TotalItems   = _transactionLogic.List().Count
                    }
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, $"The following error occurred: {ex.Message} @ {GetType().Name}");
                ViewBag.ErrorMessage = ex.Message;

                return(View("Index"));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Index(int page = 1)
        {
            try
            {
                IndexTransactionViewModel model = new IndexTransactionViewModel
                {
                    Transactions = _transactionLogic.List()
                                   .OrderByDescending(t => t.TransactionId)
                                   .Skip((page - 1) * PageSize)
                                   .Take(PageSize),
                    PagingInfo = new PagingInfo
                    {
                        CurrentPage  = page,
                        ItemsPerPage = PageSize,
                        TotalItems   = _transactionLogic.List().Count
                    }
                };

                return(View(model));
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, $"The following error occurred: {ex.Message} @ {GetType().Name}");
                ViewBag.ErrorMessage = ex.Message;

                return(View("Index"));
            }
        }