コード例 #1
0
        public static async Task <IActionResult> GetRegister <T>(
            this ContestControllerBase <T> that,
            string homePage)
            where T : class, IContestContext
        {
            if (that.Contest.Team != null)
            {
                that.StatusMessage = "Already registered";
                return(that.RedirectToAction(homePage));
            }

            var context = that.CreateRegisterProviderContext();

            that.ViewBag.Context = context;

            var items = new List <(IRegisterProvider, object)>();

            foreach (var(_, provider) in RPBinderAttribute.Get(that.HttpContext))
            {
                if (provider.JuryOrContestant)
                {
                    continue;
                }
                if (!await provider.IsAvailableAsync(context))
                {
                    continue;
                }
                var input = await provider.CreateInputModelAsync(context);

                items.Add((provider, input));
            }

            if (items.Count == 0)
            {
                that.StatusMessage = "Registration is not for you.";
                return(that.RedirectToAction(homePage));
            }

            return(that.View("Register", items));
        }