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

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

                IEnumerable <Team> allTeams = null;

                if (!string.IsNullOrEmpty(search))
                {
                    allTeams = await _teamServices.SearchTeam(search, currPage);
                }
                else
                {
                    allTeams = await _teamServices.GetAllTeamsAsync(currPage);
                }

                IEnumerable <TeamViewModel> teamListing = allTeams
                                                          .Select(m => TeamMapper.MapTeam(m));
                TeamIndexViewMode teamVM = TeamMapper.MapFromTeamIndex(teamListing,
                                                                       currPage, totalPages);

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

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

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

                return(View(teamVM));
            }
            catch (GlobalException e)
            {
                return(BadRequest(e.Message));
            }
        }