title: HttpPut Request in C#
body: <p>I'm fairly new to this Web API stuff and I'm trying to set up simple http requests to a local database on my computer. I have a get request that looks like this:</p>
  
  <pre><code>[HttpGet]
  [Route("")]
  [Route("{ID:int}")]
  public IQueryable&lt;ListTable&gt; Get(int id = -1)
  {
      if(id == -1)
          return db.ListTables;
      else
          return db.ListTables.Where(lt =&gt; lt.ID == id);
  }
  </code></pre>
  
  <p>This just returns all items in the database or one item relating to the specified ID. Now I'm trying to make a put request where I can add a new item to the database or edit item related to a certain ID. I was trying something like this:</p>
  
  <pre><code>[HttpPut]
  [Route("{ID:int}")]
  [Route("{ID:int}/{TITLE:string}")]
  [Route("{ID:int}/{TITLE:string}/{DESCRIPTION:string}")]
  public ListTable Put(int id = -1, string title = null, string descr = null)
  {
      //if ID == -1 add a new item to the DB
      //else add title and description to the item with the specified ID
  }
  </code></pre>
  
  <p>I am a little unsure of how to add a new item to the database and save the changes. I tried something like <code>db.ListTables.Add(new ListTable())</code> and <code>db.SaveChanges()</code> but those didn't seem to actually save anything because when I called the <code>Get()</code> method again the new item wasn't there.</p>