public async Task <IActionResult> Index(int?currentPage, string search = null)
        {
            try
            {
                string userId = FindCurrentUserId();

                int currPage   = currentPage ?? 1;
                int totalPages = await _characterServices.GetPageCount();

                IEnumerable <Character> characterAllResults = null;

                if (!string.IsNullOrEmpty(search))
                {
                    //For character search
                    characterAllResults = await _characterServices.SearchCharacter(search, currPage, userId);
                }
                else
                {
                    characterAllResults = await _characterServices.GetAllUserCharactersAsync(currPage, userId);
                }

                IEnumerable <CharacterViewModel> characterListing = characterAllResults
                                                                    .Select(m => CharacterMapper.MapCharacter(m));
                CharacterIndexViewModel characterIVM = CharacterMapper.MapFromCharacterIndex(characterListing,
                                                                                             currPage, totalPages);

                #region For pagination buttons and distribution
                characterIVM.CurrentPage = currPage;
                characterIVM.TotalPages  = totalPages;

                if (totalPages > currPage)
                {
                    characterIVM.NextPage = currPage + 1;
                }

                if (currPage > 1)
                {
                    characterIVM.PreviousPage = currPage - 1;
                }
                #endregion

                return(View(characterIVM));
            }
            catch (GlobalException e)
            {
                //TODO
                return(BadRequest(e.Message));
                //ModelState.AddModelError(string.Empty, ExceptionMessage.GlobalErrorMessage);
                //return RedirectToAction("Index", "Home");
            }
        }