示例#1
0
        /// <summary>
        /// Serves single-page app's page requests.
        /// </summary>
        /// <param name="paras">The entire relative URL.</param>
        public IActionResult Index(string paras)
        {
            var pi = pageProvider.GetPage(paras, true);

            if (pi == null)
            {
                pi = pageProvider.GetPage("404", true);
            }
            // If it's the results page, we cheat: retrieve score and fill title right here
            // Needed so Facebook shows my actual number when sharing
            string title = pi.Title;

            if (pi.RelNorm.StartsWith("/ergebnis/"))
            {
                string uid = pi.RelNorm.Replace("/ergebnis/", "");
                uid = uid.Substring(0, 10);
                int score = resultRepo.LoadScore(uid);
                title = title.Replace("*", score.ToString());
            }
            PageResult pr = new PageResult
            {
                NoIndex     = pi.NoIndex,
                Title       = title,
                Description = pi.Description,
                Keywords    = pi.Keywords,
                Html        = pi.Html
            };
            IndexModel model = new IndexModel(pr, gaCode);

            return(View("/Index.cshtml", model));
        }
示例#2
0
        /// <summary>
        /// Retrieves score based on quiz's unique ID.
        /// </summary>
        public IActionResult GetScore([FromForm] string uid)
        {
            // Retrieve score
            int score = resultRepo.LoadScore(uid.Substring(0, 10));

            // Respond
            if (score == -1)
            {
                return(new ObjectResult(null));
            }
            return(new ObjectResult(score));
        }