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(); }
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(); }
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); }
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"; }
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(); }
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++; } }
/// <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; }
/// <summary> /// Deprecated Method for adding a new object to the Carts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCarts(Cart cart) { base.AddObject("Carts", cart); }
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(); }