title: Display comments asp mvc
body: <p>I'm working on an mvc .net web application. I hava a database that contains difficulties (a table called difficultes) and each difficulty has comments.
  In my view I want to show every difficulty with its corresponding comments and a text area for a new comment and a button to submit it.
  I created a model class that contains a difficulty and comments, a string var for the content of a new comment, and a string var for the name of the person who wants to comment. My problem is that I failed to submit the new comment.</p>
  
  <p>Here is my model class</p>
  
  <pre><code>public class difficultecommentaires
  {
      public difficulte diff { get; set; }
      public IList&lt;commentaire&gt; comms { get; set; }
      public string pseudo { get; set; }
      public string nouveau { get; set; }
  }
  </code></pre>
  
  <p>Here is my action method for submitting the new comment</p>
  
  <pre><code>        [HttpPost]
      public ActionResult NewComment(int id_diff, string pseudo, string contenu)
      {
          difficulte d = new difficulte();
          using (BDGestionEntities bd = new BDGestionEntities())
          {
              var query = from j in bd.difficultes where (j.id_diff == id_diff) select j;
              foreach (var k in query)
                  d = k;
          }
          commentaire com = new commentaire();
          com.pseudo = pseudo;
          com.difficulte= d;
          com.contenu = contenu;
          db.AddTocommentaires(com);
          db.SaveChanges();
          ObtenirDifficulte(id_diff);
          return View();
      }
  </code></pre>
  
  <p>And here is my view</p>
  
  <pre><code> @model GestionProjet.Models.difficultecommentaires
  
  @{
      ViewBag.Title = "ObtenirDifficulte";
  }
  
  &lt;h2&gt;Détails&lt;/h2&gt;
  
  &lt;fieldset&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;
      &lt;label&gt;&lt;b&gt;Titre de la difficulté :&lt;/b&gt;&lt;/label&gt;&lt;/td&gt;&lt;td&gt;@Html.DisplayFor(m=&gt;m.diff.titre)&lt;/td&gt;&lt;/tr&gt;
  
      &lt;tr&gt;&lt;td&gt;
      &lt;label&gt;&lt;b&gt;Description :&lt;/b&gt;&lt;/label&gt;&lt;/td&gt;&lt;td&gt;@Html.DisplayFor(m=&gt;m.diff.description)&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
      &lt;table&gt;
      @foreach (var k in Model.comms)
      {
  
          &lt;tr&gt;&lt;td&gt;@k.pseudo a dit :&lt;/td&gt;&lt;td&gt;
          @k.contenu&lt;/td&gt;&lt;/tr&gt;
  
      }
      &lt;/table&gt;
      &lt;br /&gt;
      &lt;table&gt;
      &lt;tr&gt;&lt;label&gt;&lt;b&gt;Nouveau commentaire&lt;/b&gt;&lt;/label&gt;&lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;b&gt;Nom :&lt;/b&gt;&lt;/td&gt;&lt;td&gt;@Html.TextBoxFor(m=&gt;m.pseudo)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;b&gt;Commentaire :&lt;/b&gt;&lt;/td&gt;&lt;td&gt;@Html.TextAreaFor(m=&gt;m.nouveau)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      @Html.ActionLink("Ajouter", "NewComment", new { Model.diff.id_diff, Model.pseudo , Model.nouveau}) 
  
  &lt;/fieldset&gt;
  &lt;p&gt;
  &lt;a href="@Url.Action("Index")"&gt;&lt;img src="~/Images/retour.png" alt =""/&gt;&lt;/a&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>And here is my model design  (the difficulties part)</p>
  
  <p><img src="https://i.stack.imgur.com/A2PTc.jpg" alt="enter image description here"></p>
  
  <p>I think that the problem is in the parameters of my action link. I an error of null value.
  How can I solve this.</p>