public ActionResult ScoreInput(ScoreInputModel scoreInputModel)
        {
            var scoreGoal = scoreInputModel.ScoreGoal;

            this.GroupBasedOnGoal(scoreGoal);
            this.Session["Goal"] = scoreGoal;

            return(this.RedirectToAction("Results"));
        }
        public ScoreModelResponse GetScore([FromBody] ScoreInputModel model)
        {
            var result = _helper.InvokeRequestResponseService(model).Result;

            if (result != null)
            {
                var scoreModel = new ScoreModelResponse()
                {
                    MeanScore         = result.Results?.output1?.value?.Values[0][7],
                    ScoreStdDeviation = result.Results?.output1?.value?.Values[0][8]
                };

                return(scoreModel);
            }

            return(null);
        }
Exemple #3
0
        public async Task <Rootobject> InvokeRequestResponseService(ScoreInputModel model)
        {
            using (var client = new HttpClient())
            {
                var scoreRequest = new
                {
                    Inputs = new Dictionary <string, StringTable>()
                    {
                        {
                            "input1",
                            new StringTable()
                            {
                                ColumnNames = new string[] { "Age", "Domain", "SkillTitle", "DomainOrdinal", "SkillOrdinal", "SkillLevel", "DaysToMastery" },
                                Values      = new string[, ] {
                                    { model.Age, model.Domain, model.SkillTitle, model.DomainOrdinal, model.SkillOrdinal, model.SkillLevel, model.DaysToMastery }
                                }
                            }
                        },
                    },
                    GlobalParameters = new Dictionary <string, string>()
                    {
                    }
                };
                const string apiKey = "p5UIzIRDTZDKwz8W21jwcuxcsWUC4pvwQKZMzhB2lZ9jABgiDpDymRtgb/kKOhyN8pupnzqwzwhp6yxMY7svhQ=="; // Replace this with the API key for the web service
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);

                client.BaseAddress = new Uri("https://ussouthcentral.services.azureml.net/workspaces/6a52fb6be2244c358ce891ad4dfc2773/services/c44488bcf108433ab77e4f74df9f235d/execute?api-version=2.0&details=true");


                HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    var responseStr = response.Content.ReadAsStringAsync().Result;
                    var returnValue = JsonConvert.DeserializeObject <Rootobject>(responseStr);
                    return(returnValue);
                }
                else
                {
                    var result = response.Content.ReadAsStringAsync().Result;

                    return(new Rootobject());
                }
            }
        }
        public async Task <IActionResult> CreateScore(long id, [FromBody] ScoreInputModel scoreInput)
        {
            if (scoreInput == null)
            {
                return(BadRequest());
            }

            if (id == 0)
            {
                return(NotFound());
            }

            var leaderboardExists = await _context.Leaderboards.AnyAsync(l => l.Id == id);

            if (!leaderboardExists)
            {
                return(NotFound());
            }

            // TODO: More validation e.g. minimum length.
            if (scoreInput.Name == null)
            {
                return(BadRequest());
            }

            // TODO: More validation e.g. allowed ranges.
            if (!scoreInput.Value.HasValue)
            {
                return(BadRequest());
            }

            Score score = new Score {
                LeaderboardId = id, Name = scoreInput.Name, Value = scoreInput.Value.Value
            };
            // TEMPORARY HACK WHILE WE ARE USING IN-MEMORY DATABASE
            long maxId = await _context.Scores.Select(s => s.Id).MaxAsync();

            score.Id = maxId + 1;

            _context.Add(score);
            await _context.SaveChangesAsync();

            return(CreatedAtRoute("GetScore", new { id = score.Id }, score));
        }
Exemple #5
0
 public ActionResult Predict(ScoreInputModel model)
 {
     return(View());
 }