title: asp.net MVC How to add a Data object to IList method
body: <p>I am creating a test project where i have products, i didn't won't to use a database at the beginning so i made Mocks Data that returns a list of products, but i want a user should be able to add to the list.</p>
  
  <blockquote>
    <p>This is the Model</p>
  </blockquote>
  
  <pre><code>namespace StoreTest.Models
  {
      public class Products
      {
          public int Id { get; set; }
          public string Name { get; set; }
          public double Price { get; set; }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>This is the Mock data class</p>
  </blockquote>
  
  <pre><code>using System.Collections.Generic;
  using StoreTest.Models;
  
  namespace StoreTest.Data.Mocs
  {
  
      public class ProductMocks
      {
          public IList&lt;Products&gt; ProductList
          {
              get
              {
                  return
                      new List&lt;Products&gt;
                      {
                          new Products
                          {
                              Id = 1,
                              Name = "Some Data",
                              Price = 34.00
                          },
                          new Products
                          {
                              Id = 2,
                              Name = "More Data",
                              Price = 28.00
                          }
                      };
              }
  
          }
  
      }
  }
  </code></pre>
  
  <blockquote>
    <p>This is the part from the Controller where i want to add to the ProductList</p>
  </blockquote>
  
  <pre><code>        [HttpPost]
          public IActionResult NewProduct(NewProductViewModel vm)
          {
  
              if (ModelState.IsValid)
              {
                  Products product = new Products()
                  {
                      Id = vm.Id,
                      Name = vm.Name,
                      Price = vm.Price
                  };
  
                  ProductMocks addProduct = new ProductMocks();
                  // THIS IS NOT WORKING 
                  productMocs.ProductList.Add(product);
                  return View("Index", addProduct);
              }
              else
              {
                  return View(vm);
              }     
          }
  </code></pre>
  
  <p>I am very new to asp.net.</p>
  
  <p>Idon't know if i need to change the whole ProductMocks class, or i only need to add something in the controller?</p>
  
  <p>Thank you in advanced!</p>