public override void AddToBasket(int productId, int quantity, IPrincipal user)
        {
            var basketLine = (from bl in this.context.BasketLines.Include("User")
                              where bl.ProductId == productId
                              && bl.User.LoweredUserName == user.Identity.Name.ToLower()
                              select bl).FirstOrDefault();
            if (basketLine == null)
            {
                basketLine = new BasketLine();
                basketLine.User = (from u in this.context.Users
                                   where u.LoweredUserName == user.Identity.Name.ToLower()
                                   select u).First();
                basketLine.Product = (from p in this.context.Products
                                      where p.ProductId == productId
                                      select p).First();

                this.context.AddToBasketLines(basketLine);
            }
            basketLine.Quantity += quantity;
            basketLine.UtcUpdated = DateTime.UtcNow;
            this.context.SaveChanges();
        }
 /// <summary>
 /// Create a new BasketLine object.
 /// </summary>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="utcUpdated">Initial value of the UtcUpdated property.</param>
 public static BasketLine CreateBasketLine(global::System.Int32 productId, global::System.Int32 quantity, global::System.Guid userId, global::System.DateTime utcUpdated)
 {
     BasketLine basketLine = new BasketLine();
     basketLine.ProductId = productId;
     basketLine.Quantity = quantity;
     basketLine.UserId = userId;
     basketLine.UtcUpdated = utcUpdated;
     return basketLine;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the BasketLines EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBasketLines(BasketLine basketLine)
 {
     base.AddObject("BasketLines", basketLine);
 }