/// <summary>
        /// Shows all tournaments that belongs to the
        /// LeagueOwners League/Leagues'
        /// </summary>
        /// <returns>Returns a view</returns>
        public async Task <IActionResult> Admin()
        {
            List <Tournament> TournamentList = new List <Tournament>();
            string            errorMessage   = "No tournaments available";

            LeagueOwner user = (LeagueOwner)_SessionHelper.GetSessionUser(HttpContext);

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            TournamentList = await GetActiveTournaments(user);

            ViewData["ActiveTournaments"] = TournamentList;

            if (TournamentList.Count == 0)
            {
                ViewData["ActiveTournaments"] = null;
                ViewBag.Error = errorMessage;
            }

            return(View(new TournamentViewModel()
            {
                Advert = await _Adhelper.ShowAd()
            }));
        }
        // GET: LeagueOwners/Create
        public IActionResult Create()
        {
            var leagueOwner = new LeagueOwner();

            leagueOwner = _context.LeagueOwners.Include(l => l.Phone).FirstOrDefault();
            return(View(leagueOwner));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,firstName,lastName,accountActive,PhoneId")] LeagueOwner leagueOwner)
        {
            if (id != leagueOwner.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(leagueOwner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LeagueOwnerExists(leagueOwner.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PhoneId"] = new SelectList(_context.Phones, "Id", "phoneNumber", leagueOwner.PhoneId);
            return(View(leagueOwner));
        }
        public async Task <IActionResult> Create(LeagueOwner leagueOwner)
        {
            if (ModelState.IsValid)
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                leagueOwner.IdentityUserId = userId;
                _context.Add(leagueOwner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PhoneId"] = new SelectList(_context.Phones, "Id", "phoneNumber", leagueOwner.PhoneId);
            return(View(leagueOwner));
        }