title: asp net. How to remove data from a database
body: <p>First I want to say I'm just starting to learn and I'm french, so please be very simple in your explanation. Just imagine you're talking to a 3 years old and I should be ok. Please don't overload me with dozens of lines of code without any explanation.</p>
  
  <p>OK here's what I want to do: I have a very simple database table of article author. The table has 5 columns:</p>
  
  <pre><code>First Name, Second name, Dob, Phone Nb, Place of Birth, UserId
  </code></pre>
  
  <p>The <code>userId</code> is automatically created. I have created a form where a user would write the first name and second name (in 2 separated textboxes and I want to use that to fetch the userId in the table and use it to delete the entire line)</p>
  
  <p>Here's the code for my form</p>
  
  <pre><code>    model projet_clement.Models.HomeModel
  
  &lt;form method="post" action="~/home/SupressionAuteur"&gt;
      &lt;h3&gt;deleting author page&lt;/h3&gt;
      &lt;p&gt;first name of the author to delete&lt;/p&gt;
      &lt;input type="text" name="Nom" /&gt;
      &lt;p&gt;second name of the author to delete&lt;/p&gt;
      &lt;input type="text" name="Prenom" /&gt;&lt;br /&gt;
      &lt;br /&gt;
      &lt;input type="submit" value="Delete" /&gt;
  &lt;/form&gt;
  
  
  
  &lt;h3&gt;For reminder, here's a table of the author already created&lt;/h3&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;Nom&lt;/td&gt;
          &lt;td&gt;Prenom&lt;/td&gt;
          &lt;td&gt;Date de naissance&lt;/td&gt;
          &lt;td&gt;N° de téléphone&lt;/td&gt;
          &lt;td&gt;Département de naissance&lt;/td&gt;
          &lt;td&gt;UserId&lt;/td&gt;
      &lt;/tr&gt;
      @foreach (var i in Model.UserList)
      {
          &lt;tr&gt;
              &lt;td&gt;@i.Nom&lt;/td&gt;
              &lt;td&gt;@i.Prenom&lt;/td&gt;
              &lt;td&gt;@i.Naissance&lt;/td&gt;
              &lt;td&gt;@i.Numero&lt;/td&gt;
              &lt;td&gt;@i.Departement&lt;/td&gt;
              &lt;td&gt;@i.userId&lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  </code></pre>
  
  <p>OK now what I would like to know is how can I get the userId thanks to the first name and second name, and how can I delete a whole row just using this id.</p>
  
  <p>Here's my c# code</p>
  
  <pre><code>[HttpGet]
  public ActionResult SupressionAuteur()
  {
       var allUsers = db.Users.Where(x =&gt; x.Nom != null);
  
       var model = new HomeModel(allUsers);
       return View(model);
  }
  
  [HttpPost]
  public ActionResult SupressionAuteur(Users formUser)
  {
      //for those who skipped french class, nom = first name and prenom = second name;)
      var userId = db.Users.Where(x =&gt; x.Nom == formUser.Nom &amp;&amp; x.prenom == formuser.prenom);
      db.Users.Remove([What should i write here?]);
      return RedirectToAction("SupressionAuteur", "Home");
  }
  </code></pre>
  
  <p>Of course it doesn't work!</p>
  
  <p>When I run my code the userId var never get the good value. So I guess the way I try to get it is wrong</p>
  
  <p>And how am I supposed to use the <code>db.users.remove()</code> method? Is it the one I should use by the way? I was told so. </p>
  
  <p>Thanks in advance, I'm really stuck :)</p>