public async Task <IActionResult> Index(DiceViewModel diceVM) { if (diceVM == null) { diceVM = new DiceViewModel(); } ProbabilityModel probabilityModel = null; if (diceVM.Dice1 != 0 && diceVM.Dice2 != 0) { using (var httpClient = new HttpClient()) { HttpResponseMessage result = await httpClient.GetAsync($"https://diceservice.azurewebsites.net/api/Dice?Dice1={diceVM.Dice1}&Dice2={diceVM.Dice2}&Sides=6"); var responseBody = await result.Content.ReadAsStringAsync(); probabilityModel = JsonConvert.DeserializeObject <ProbabilityModel>(responseBody); } diceVM.Win = probabilityModel.Win; diceVM.Lose = probabilityModel.Lose; diceVM.Tie = probabilityModel.Tie; } return(View(diceVM)); }
public DiceViewModel Roll() { var diceViewModel = new DiceViewModel(); var registerCommand = _mapper.Map <RegisterNewRollCommand>(diceViewModel); Bus.SendCommand(registerCommand); return(_mapper.Map <DiceViewModel>(_repository.GetById(diceViewModel.Id))); }