/// <summary> /// GETs following data to display back to user /// number of images /// guess minus actual answer /// average time (Time/images) /// </summary> /// <param name="userGuid"></param> /// <returns></returns> public async Task <ActionResult> PhaseTwoFinish(string userGuid) { if (_session._isLoggedin) { var getUserRequest = new HttpRequestMessage(HttpMethod.Get, $"/api/user/hash/{userGuid}"); var getUserResponse = await _db.BuildApiResponse <UserModel>(getUserRequest, _session._accessToken); if (getUserResponse.Status == HttpStatusCode.OK) { var getUserGuessRequest = new HttpRequestMessage(HttpMethod.Get, $"/api/usersGuess/{getUserResponse.Content.UserId}/{(byte)Phase.TWO}"); var getUserGuessResponse = await _db.BuildApiResponse <List <UserGuessModel> >(getUserGuessRequest, _session._accessToken); if (getUserResponse.Status == HttpStatusCode.OK) { var imageNumberArray = new List <int>(); var guessResultsArray = new List <decimal>(); var time = getUserResponse.Content.TimePhase2.HasValue ? getUserResponse.Content.TimePhase2.Value : DateTime.Now.Date; //convert time into seconds var seconds = time.Second; seconds += (time.Minute * 60); seconds += (time.Hour * 3600); //Get GuessPercentage - Actual Answer for table int i = 1; var guesses = getUserGuessResponse.Content.OrderBy(x => x.UsersGuessId); foreach (var item in guesses) { var result = (item.GuessPercentage - item.Image.DecayRate) * 100; guessResultsArray.Add(result); imageNumberArray.Add(i); i++; } //Total Time TimeSpan t = TimeSpan.FromSeconds(seconds); string totalTime = string.Format("{0:D2}:{1:D2}:{2:D2}s", t.Hours, t.Minutes, t.Seconds); //Average Time TimeSpan t2 = TimeSpan.FromSeconds((seconds / imageNumberArray.Count)); string averageTime = string.Format("{0:D2}:{1:D2}:{2:D2}s", t2.Hours, t2.Minutes, t2.Seconds); var model = new FinishedModelView() { GuessResult = guessResultsArray.ToArray(), NumberOfImages = imageNumberArray.ToArray(), TotalTime = totalTime, AverageTime = averageTime, UserGuid = userGuid }; return(View(model)); } } return(RedirectToAction("Errorpage", "Home")); } return(RedirectToAction("Login", "Account")); }
public ActionResult FinishPhase2(FinishedModelView model) { return(RedirectToAction("GuessNoFeedback", "UserGuess", new { model.UserGuid, phase = 2 })); }