title: MVC - Model - View and Controller 's role
body: <p>Following is my Architecture of an application. I am confuse with whether I understood MVC correct or not? My Architecture is right or not?</p>
  
  <p>View - interacts with the user, it has HTML part, on submit the form it calls controller</p>
  
  <p>Controller - it checks for information added is valid or not? (not database point of view. it will just check for weather all the mandatory fields are filled or not?) decides which model to call.</p>
  
  <p>Model - it contains class of view. and also some methods like add,modify or delete to deal with the database. </p>
  
  <p>Is this correct or making some mistake? 
  Following is sample of my code</p>
  
  <p>Controller: 
          <pre> public ActionResult AddCustomer(CustomerModel model)
          {
              if (ModelState.IsValid)
              {
                  model.AddCustomer();
                  return RedirectToAction("Index", "Home");
              }
              return (View("AddCustomer",model));
          }</p>
  
  <p>Model: </p>
  
  <p>public class AddBookModel
      {
          [Required(ErrorMessage = "The ISBN is required.")]
          [DisplayName("ISBN")]
          public String ISBN { get; set; }</p>
  
  <pre><code>    [DisplayName("Title")]
      [Required(ErrorMessage = "The Title is required.")]
      public String Title { get; set; }
  
      [Required(ErrorMessage = "The Publisher is required.")]
      [DisplayName("Publisher")]
      public String Publisher { get; set; }
  
      public void AddBook()
      {
          using (BBBDataContext DCBook = new BBBDataContext())
          {
              Book tableBook = new Book()
              {
                  ISBN = this.ISBN,
                  Title = this.Title,
                  Publisher = this.Publisher,
              }
            DCBook.Books.InsertOnSubmit(tableBook);
            DCBook.SubmitChanges(); 
          }
       }
  </code></pre>
  
  <p>View: </p>
  
  <pre><code>       &lt;% using (Html.BeginForm()) {%&gt;
      &lt;%= Html.ValidationSummary(true) %&gt;
  
      &lt;fieldset&gt;
          &lt;legend&gt;Insert Book Record&lt;/legend&gt;
          &lt;table id="displayform" cellspacing="0" cellpadding="5"&gt;
          &lt;colgroup&gt;
              &lt;col span="1" style="text-align:right" /&gt;
              &lt;col span="2" style="text-align:left" /&gt;
          &lt;/colgroup&gt;
          &lt;tr&gt;
              &lt;td class="editor-label"&gt;
                  &lt;%= Html.LabelFor(model =&gt; model.ISBN) %&gt;
              &lt;/td&gt;
              &lt;td class="editor-field"&gt;
                  &lt;%= Html.TextBoxFor(model =&gt; model.ISBN) %&gt;
                  &lt;%= Html.ValidationMessageFor(model =&gt; model.ISBN) %&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="editor-label"&gt;
                  &lt;%= Html.LabelFor(model =&gt; model.Title) %&gt;
              &lt;/td&gt;
              &lt;td class="editor-field"&gt;
                  &lt;%= Html.TextBoxFor(model =&gt; model.Title) %&gt;
                  &lt;%= Html.ValidationMessageFor(model =&gt; model.Title) %&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  </code></pre>
  
  <p></pre></p>