title: ASP.NET MVC NerdDinner Tutorial question
body: <p>I'm following Scott Guthries MVC tutorial (<a href="http://nerddinnerbook.s3.amazonaws.com/Part6.htm" rel="nofollow noreferrer">http://nerddinnerbook.s3.amazonaws.com/Part6.htm</a>) and there's something I don't understand.</p>
  
  <p>The Controller class called DinnersController has the following Create methods:</p>
  
  <pre><code>    public ActionResult Create()
      {
          Dinner dinner = new Dinner()
          {
              EventDate = DateTime.Now.AddDays(7)
          };
  
          return View(new DinnerFormViewModel(dinner));
      }
  
      [AcceptVerbs( HttpVerbs.Post)]
      public ActionResult Create(Dinner dinner)
      {
          if (ModelState.IsValid)
          {
              try
              {
                  dinner.HostedBy = "SomeUser";
                  dinnerRepository.Add(dinner);
                  dinnerRepository.Save();
  
                  return RedirectToAction("Details", new { id = dinner.DinnerID });
              }
              catch
              {
                  foreach (var violation in dinner.GetRuleViolations())
                      ModelState.AddModelError(violation.PropertyName, violation.ErrorMessage);                    
              }
          }
  
          return View(new DinnerFormViewModel(dinner));
      }
  </code></pre>
  
  <p>The first method causes the page Create.aspx to be shown which displays form data for the object type 'DinnerViewFormModel' i.e.</p>
  
  <p><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;NerdDinner.Controllers.DinnerFormViewModel&gt;" %&gt;</code></p>
  
  <p>The class 'DinnerViewFormModel' contains a property called 'Dinner' so displaying the relevant information for Dinner type objects is done by calling:</p>
  
  <p><code>&lt;label for="Title"&gt;Title:&lt;/label&gt;
                  &lt;%= Html.TextBox("Title", Model.Dinner.Title) %&gt;</code></p>
  
  <p>I understand whats going on so far. However, Create.aspx contains a submit type button:</p>
  
  <p><code>&lt;input type="submit" value="Create" /&gt;</code></p>
  
  <p>When the button is clicked, the following method is called:</p>
  
  <pre><code>    [AcceptVerbs( HttpVerbs.Post)]
      public ActionResult Create(Dinner dinner)
  </code></pre>
  
  <p>What I don't understand is, If the form's Model data is a 'DinnerViewFormModel' object, how does MVC know what 'Dinner' object needs to be passed to the Create method?</p>
  
  <p>Please could someone enlighten me? Thanks</p>