title: Passing Properties as Parameters
body: <p>I'm trying to pass properties from my <code>Game</code> class into a method called <code>Compete</code>. I am calling the <code>Compete</code> method in my controller, but can't access these parameters.</p>
  
  <blockquote>
    <p><strong>Question:</strong> How can I pass <code>UserGuess</code> and <code>ComputerGuess</code> properties into my <code>Compete</code> method</p>
  </blockquote>
  
  <p><strong>Model</strong></p>
  
  <pre><code>namespace RockPaperScissors.Models
  
  {
      public class Game
      {
          public string UsersGuess { get; set; }
          public string ComputersGuess { get; set; }
          public string Winner { get; set; }
      }
  }
  </code></pre>
  
  <p><strong>GameLogic</strong></p>
  
  <pre><code>namespace RockPaperScissors.Business
  {
      public class GameLogic
      {
          public string Outcome { get; set; }
  
          public string Compete(string userInput, string computerInput)
          {
             // Logic Here
  
              return Outcome;
          }
      }
  }
  </code></pre>
  
  <p><strong>GameController</strong></p>
  
  <pre><code>using System.Web.Mvc;
  using RockPaperScissors.Business;
  using RockPaperScissors.Models;
  
  namespace RockPaperScissors.Controllers
  {
      public class GameController : Controller
      {
          public ActionResult Index()
          {
  
              var model = new Game
               {
                   Winner = new GameLogic().Compete(UserGuess, ComputerGuess)
               };
  
              return View(model);
          }
      }
  }
  </code></pre>
  
  <p><strong>ComputerLogic</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  namespace RockPaperScissors.Business
  {
      public class ComputerLogic
      {
          public string ComputersGuess()
          {
              var options = new List&lt;string&gt; { "Rock", "Paper", "Scissors" };
  
              var randomizer = new Random();
              var random = randomizer.Next(options.Count);
  
              return options[random];
          }
      }
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@using RockPaperScissors.Models
  @model Game
  
  @{
      ViewBag.Title = "Games";
  }
  
  &lt;h2&gt;Rock, Paper, Scissors&lt;/h2&gt;
  
  @using (Html.BeginForm("Index", "Game"))
  {
      &lt;div class="form-group"&gt;
          &lt;label&gt;Enter your decision:&lt;/label&gt;
          @Html.TextBoxFor(m =&gt; m.UsersGuess, new { @class = "form-control", required = "required" })
      &lt;/div&gt;
      &lt;div&gt;
          &lt;input class="btn btn-primary" type="submit" value="Guess" /&gt;
      &lt;/div&gt;
  }
  
  &lt;h3&gt;Computers Guess: &lt;/h3&gt; @Html.DisplayFor(m =&gt; m.ComputersGuess)
  
  &lt;h2&gt;Winner: &lt;/h2&gt; @Html.DisplayFor(m =&gt; m.Winner)
  </code></pre>