public ActionResult ResultPlayer([FromForm] PlayerResultViewModel playerResultRecieved) { var playerResult = _playerService.resultPlayer(playerResultRecieved.id, playerResultRecieved.result); Console.WriteLine(playerResultRecieved.id + " : " + playerResultRecieved.result); return(Ok(playerResult)); }
/// <summary>Results the player.</summary> /// <param name="playerId">The player identifier.</param> /// <param name="result">The result.</param> /// <returns> /// ResultPlayer this method is used to get the final yoyo fitness test result from web api service by using httpclinet <br /> /// <br /> /// </returns> public async Task <PlayerResultViewModel> ResultPlayer(int playerId, string result) { var playerResult = new PlayerResultViewModel(); try { using (HttpClient client = new HttpClient()) { var url = FillApiAddress(Constants.webApiResult, apiUrl, string.Empty); UriBuilder builder = new UriBuilder(url); builder.Query = "id=" + playerId + " &result=" + result + ""; playerResult = new PlayerResultViewModel(); Uri uri = new Uri(url); client.BaseAddress = new Uri(url); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = await client.GetAsync(builder.Uri).ConfigureAwait(false); if (response.IsSuccessStatusCode) { playerResult = JsonConvert.DeserializeObject <PlayerResultViewModel>(response.Content.ReadAsStringAsync().Result); } } return(playerResult); } catch (Exception ex) { } return(playerResult); }
public PlayerResultViewModel resultPlayer(int playerId, string result) { var playerResult = new PlayerResultViewModel(); var playersList = GetPlayers(); int editIndex = playersList.FindIndex(o => o.id == playerId); playerResult.id = playersList[editIndex].id; playerResult.result = result; //save data someware.. return(playerResult); }
/// <summary>Results the player.</summary> /// <param name="playerId">The player identifier.</param> /// <param name="result">The result.</param> /// <returns> /// ResultPlayer this method is used to get the final result of the participents <br /> /// </returns> public PlayerResultViewModel ResultPlayer(int playerId, string result) { var playerResult = new PlayerResultViewModel(); try { var playersList = _getPlayerRepository.GetPlayers(); int editIndex = playersList.FindIndex(o => o.id == playerId); playerResult.id = playersList[editIndex].id; playerResult.result = result; //save data someware.. } catch (Exception ex) { } return(playerResult); }
public ActionResult ResultPlayer([FromForm] PlayerResultViewModel playerResultRecieved) { var playerResult = _playerService.ResultPlayer(playerResultRecieved.id, playerResultRecieved.result); return(Ok(playerResult)); }