public int CreateCart()
 {
     using (var db = new ShoppingCartContext())
     {
         // Create new shopping cart
         var shoppingCart = new ShoppingCart { Created = DateTime.Now, Modified = DateTime.Now };
         db.ShoppingCarts.Add(shoppingCart);
         db.SaveChanges();
         return shoppingCart.ShoppingCartId;
     }
 }
 public int CreateCart(string username)
 {
     using (var db = new ShoppingCartContext())
     {
         var q = from c in db.ShoppingCarts
                 where c.Username == username
                 select c;
         ShoppingCart shoppingCart = q.FirstOrDefault();
         if (shoppingCart == null)
         {
             // Create new shopping cart
             shoppingCart = new ShoppingCart
                                {Username = username, Created = DateTime.Now, Modified = DateTime.Now};
             db.ShoppingCarts.Add(shoppingCart);
             db.SaveChanges();
         }
         return shoppingCart.ShoppingCartId;
     }
 }