Inheritance: System.Data.Objects.DataClasses.EntityObject
示例#1
0
        public void AddToCart(Album album)
        {
            // Get the matching cart and album instances
            var cartItem = storeDB.Carts.SingleOrDefault(c => c.CartId == ShoppingCartId && c.AlbumId == album.AlbumId);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    AlbumId = album.AlbumId,
                    CartId = ShoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                storeDB.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            storeDB.SaveChanges();
        }
示例#2
0
        public void AddToCart(Album album)
        {
            var cartItem = storeDB.Carts.SingleOrDefault(
                c => c.CartId == shoppingCartId && 
                c.AlbumId == album.AlbumId);

            if (cartItem == null)
            {
                // Create a new cart item
                cartItem = new Cart
                {
                    AlbumId = album.AlbumId,
                    CartId = shoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };
                storeDB.AddToCarts(cartItem);
            }
            else
            {
                // Add one to the quantity
                cartItem.Count++;
            }

            // Save it
            storeDB.SaveChanges();
        }
示例#3
0
        public void AddToCart(Album album)
        {
            // Get the matching cart and album instances
            Cart cartItem = Cart.FindByCartIdAlbum(ShoppingCartId, album);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    Album = album,
                    CartId = ShoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            cartItem.Save();
        }
        public void AddToCart(Album album)
        {
            // Get the matching cart and album instances
            //            var cartItem = storeDB.Carts.SingleOrDefault(
            //c => c.CartId == ShoppingCartId
            //&& c.AlbumId == album.Id);
            var cartItem = _cartsPersister.LoadByAlbumAndShoppingCartId(album.Id, ShoppingCartId);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    Album = album,
                    CartId = ShoppingCartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

            //                storeDB.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            //            storeDB.SaveChanges();
            _cartsPersister.Store(cartItem);
        }
示例#5
0
        public void AddToCart(Album album)
        {
            using (var tx = storeContext.Session.BeginTransaction())
            {
                var cartItem = storeContext.Carts.SingleOrDefault(
                    c => c.CartId == shoppingCartId &&
                         c.Album == album);

                if (cartItem == null)
                {
                    // Create a new cart item
                    cartItem = new Cart
                                   {
                                       Album = album,
                                       CartId = shoppingCartId,
                                       Count = 1,
                                       DateCreated = DateTime.Now
                                   };
                }
                else
                {
                    // Add one to the quantity
                    cartItem.Count++;
                }

                // Save it
                storeContext.Session.Save(cartItem);

                tx.Commit();
            }
        }
        public string AddToBooking(string scheduleid, string sectionid, string data)
        {
            int BookingDelayTime = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["BookingDelayTime"]);
            int schid = Convert.ToInt32(scheduleid);
            int secid = Convert.ToInt32(sectionid);
            var items = data.Split(',');

            var schedule = db.tSchedule.Single(a => a.tScheduleId == schid);
            var section = db.tSection.Single(a => a.tSectionId == secid );
            var product = db.Albums.Single(a => a.AlbumId == schedule.AlbumId);
            var cart = ShoppingCart.GetCart(this.HttpContext);
            string cartid = cart.GetCartId(this.HttpContext); //CartSessionKey

            foreach (string item in items)
            {
                var seat = db.tSeat.Single(a => a.tSectionId == section.tSectionId && a.Code == item);
                tBooking b = new tBooking
                {
                    ExpiryTime = DateTime.Now.AddMinutes(BookingDelayTime),
                    OrderDetailId=0,
                    tScheduleId = schedule.tScheduleId,
                    tSeatId = seat.tSeatId,
                    Pax = seat.Capacity,
                    CartId = cartid
                };
                db.tBooking.Add(b);
                //create cart item
                 //cart.AddToCartFromBooking(b);
                var cartitem = new Cart
                {
                    AlbumId = schedule.AlbumId,
                    CartId = cartid,
                    Count = b.Pax,
                    DateCreated = DateTime.Now,
                    t_ExpireTime = b.ExpiryTime,
                    t_Price = 1,
                    t_SeatClass = seat.tSeatClassId.ToString(),
                    t_SeatCode = seat.Code

                };
                db.Carts.Add(cartitem);

            }
                db.SaveChanges();

            return "PASS";
        }
示例#7
0
 public void AddToCart(Album album)
 {
     var cartItem = storeDb.Carts.SingleOrDefault(c => c.CartId == ShoppingCartId && c.AlbumId == album.AlbumId);
     if (cartItem == null)
     {
         cartItem = new Cart
         {
             AlbumId = album.AlbumId,
             CartId = ShoppingCartId,
             Count = 1,
             DateCreated = DateTime.Now
         };
         storeDb.Carts.Add(cartItem);
     }
     else 
     {
         cartItem.Count++;
     }
     storeDb.SaveChanges();
 }
示例#8
0
        public async Task AddToCart(Album album)
        {
            var cartItem = await GetCartItem(album.AlbumId);

            if (cartItem == null)
            {
                cartItem = new Cart
                {
                    AlbumId = album.AlbumId,
                    CartId = _cartId,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                _storeContext.Carts.Add(cartItem);
            }
            else
            {
                cartItem.Count++;
            }
        }
示例#9
0
 /// <summary>
 /// Create a new Cart object.
 /// </summary>
 /// <param name="recordId">Initial value of the RecordId property.</param>
 /// <param name="cartId">Initial value of the CartId property.</param>
 /// <param name="albumId">Initial value of the AlbumId property.</param>
 /// <param name="count">Initial value of the Count property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 public static Cart CreateCart(global::System.Int32 recordId, global::System.String cartId, global::System.Int32 albumId, global::System.Int32 count, global::System.DateTime dateCreated)
 {
     Cart cart = new Cart();
     cart.RecordId = recordId;
     cart.CartId = cartId;
     cart.AlbumId = albumId;
     cart.Count = count;
     cart.DateCreated = dateCreated;
     return cart;
 }
示例#10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Carts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCarts(Cart cart)
 {
     base.AddObject("Carts", cart);
 }
示例#11
0
 public void AddToCartFromBooking(tBooking book)
 {
     //var books = storeDB.tBooking.Where(a => a.CartId == ShoppingCartId);
     //foreach (tBooking book in books.ToList())
     //{
         //var sch = storeDB.tSchedule.Single(a=>a.tScheduleId == book.tScheduleId);
         var cartItem = new Cart
         {
             AlbumId = book.tSchedule.AlbumId,
             CartId = ShoppingCartId,
             Count = book.Pax,
             DateCreated = DateTime.Now,
             t_ExpireTime = book.ExpiryTime,
             t_Price = 1,
             //t_SeatClass = book.
         };
         storeDB.Carts.Add(cartItem);
     //}
     //storeDB.SaveChanges();
 }