title: Asp.NetWebAPI add related entities
body: <p>I am trying to add data to related entities. But I think the way I code is really not appropriate. Should I use SharedService instead of Shared Controller.</p>
  <p>Here is my Code</p>
  <pre><code>     [HttpPost(&quot;addtocart&quot;)]
       public IActionResult AddToCart([FromBody] AddToCart addToCart)
       {
           _cartService.Add(addToCart.Cart);
           addToCart.Product.CartId = addToCart.Cart.Id;
           _productService.Add(addToCart.Product);
           addToCart.ProductOption.ProductId = addToCart.Product.Id;
           _productOptionService.Add(addToCart.ProductOption);
  
           return Ok(&quot;Added&quot;);
       }
  </code></pre>
  <p>Cart.cs</p>
  <pre><code> public class Cart:IEntity
      {
          public int Id   { get; set; }
          public int UserId { get; set; }
          public DateTime CreatedDate { get; set; }
          public virtual ICollection&lt;Product&gt; Products { get; set; }
      }
  </code></pre>
  <p>Product.cs</p>
  <pre><code>public class Product:IEntity
      {
          public int Id { get; set; }
         
          public string SerialNumber { get; set; }
          public string StockCode { get; set; }
          public int CartId { get; set; }
          public int Quantity { get; set; }
          public virtual ICollection&lt;ProductOption&gt; ProductOptions { get; set; }
          
          [ForeignKey(nameof(CartId))] 
          public virtual Cart Cart { get; set; }
  
      }
  </code></pre>
  <p>ProductOption.cs</p>
  <pre><code> public class ProductOption:IEntity
      {
          public int Id { get; set; }
          public int ProductId { get; set; }
          public int OptionId { get; set; }
  
          
          [ForeignKey(nameof(ProductId))]
          public virtual Product Product { get; set; }
  
          [ForeignKey(nameof(OptionId))]
          public virtual Option Options { get; set; }
  
      }
  </code></pre>
  <p>How can I make it better. Thanks...</p>