/// <summary> Adds the specified shopping cart entry entity to this listing. </summary> /// <param name="cartEntry"> The specified shopping cart entry entity to add to this listing. </param> public void AddShoppingCartEntry(ShoppingCartEntry cartEntry) { if (ShoppingCartEntries == null) { ShoppingCartEntries = new HashSet <ShoppingCartEntry>(); } cartEntry.Listing = this; this.ShoppingCartEntries.Add(cartEntry); }
public ProductOrderEntry(Order order, ShoppingCartEntry cartEntry) { ListingID = cartEntry.ListingID; Listing = cartEntry.Listing; SalePrice = cartEntry.Listing.SaleOrDefaultPrice(); ClaimedProductKeys = new HashSet<ClaimedProductKey>(); OrderID = order.OrderID; this.Order = order; }
public ProductOrderEntry(Order order, ShoppingCartEntry cartEntry) { ListingID = cartEntry.ListingID; Listing = cartEntry.Listing; SalePrice = cartEntry.Listing.SaleOrDefaultPrice(); ClaimedProductKeys = new HashSet <ClaimedProductKey>(); OrderID = order.OrderID; this.Order = order; }
public ProductOrderEntry(Order order, ShoppingCartEntry cartEntry, ClaimedProductKey claimedKey) { ListingID = cartEntry.ListingID; Listing = cartEntry.Listing; SalePrice = cartEntry.Listing.SaleOrDefaultPrice(); ClaimedProductKeys = new HashSet<ClaimedProductKey>() { claimedKey }; claimedKey.ProductOrderEntry = this; OrderID = order.OrderID; this.Order = order; //ProductOrderEntryID = claimedKey.ClaimedProductKeyID; }
public void ReduceEntry(int listingId, int quantityDeduction) { ShoppingCartEntry cartEntry = ShoppingCartEntries.Where(entry => Object.Equals(entry.UserID, this.Id) && entry.ListingID == listingId).Single(); cartEntry.Quantity -= quantityDeduction; ShoppingCartEntries.Remove(cartEntry); // removing all the quantity is essentially a delete, only re-add if there is some quantity left if (cartEntry.Quantity > 0) { ShoppingCartEntries.Add(cartEntry); } }
/// <summary> Removes the specified shopping cart entry entity from this listing. </summary> /// <param name="cartEntry"> The specified shopping cart entry entity to remove from this listing. </param> /// <returns> Returns the removed shopping cart entry entity if it existed, otherwise returns null. </returns> public ShoppingCartEntry RemoveShoppingCartEntry(ShoppingCartEntry cartEntry) { if (this?.ShoppingCartEntries?.Count == 0) { return(null); } if (ShoppingCartEntries.Contains(cartEntry)) { ShoppingCartEntries.Remove(cartEntry); return(cartEntry); } return(null); }
public ShoppingCartEntry AddShoppingCartEntry(Listing listing, int quantity = 1) { ShoppingCartEntry entry = ShoppingCartEntries.Where(e => e.ListingID == listing.ListingID).SingleOrDefault(); // && Object.Equals(e.UserID, Id)).SingleOrDefault(); if (entry == null) { entry = new ShoppingCartEntry(this, listing, quantity); ShoppingCartEntries.Add(entry); } else { entry.Quantity++; } return(entry); }
public ProductOrderEntry(Order order, ShoppingCartEntry cartEntry, ClaimedProductKey claimedKey) { ListingID = cartEntry.ListingID; Listing = cartEntry.Listing; SalePrice = cartEntry.Listing.SaleOrDefaultPrice(); ClaimedProductKeys = new HashSet <ClaimedProductKey>() { claimedKey }; claimedKey.ProductOrderEntry = this; OrderID = order.OrderID; this.Order = order; //ProductOrderEntryID = claimedKey.ClaimedProductKeyID; }
public ShoppingCartEntry RemoveShoppingCartEntry(ShoppingCartEntry cartEntry) { if (ShoppingCartEntries.Contains(cartEntry)) { ShoppingCartEntries.Remove(cartEntry); return cartEntry; } return null; }
public void AddShoppingCartEntry(ShoppingCartEntry cartEntry) { cartEntry.Listing = this; this.ShoppingCartEntries.Add(cartEntry); }
public ShoppingCartEntry AddShoppingCartEntry(Listing listing, int quantity = 1) { ShoppingCartEntry entry = ShoppingCartEntries.Where(e => e.ListingID == listing.ListingID).SingleOrDefault(); // && Object.Equals(e.UserID, Id)).SingleOrDefault(); if (entry == null) { entry = new ShoppingCartEntry(this, listing, quantity); ShoppingCartEntries.Add(entry); } else { entry.Quantity++; } return entry; }
public void UpdateShoppingCartEntry(ShoppingCartEntry shoppingCartEntry) { ShoppingCartEntry targetShoppingCartEntry = context.ShoppingCartEntries.Find(shoppingCartEntry.ShoppingCartEntryID); if (targetShoppingCartEntry != null) { targetShoppingCartEntry.Quantity = shoppingCartEntry.Quantity; targetShoppingCartEntry.DateAdded = shoppingCartEntry.DateAdded; targetShoppingCartEntry.ListingID = shoppingCartEntry.ListingID; targetShoppingCartEntry.UserID = shoppingCartEntry.UserID; } }
public void InsertShoppingCartEntry(ShoppingCartEntry shoppingCartEntry) { context.ShoppingCartEntries.Add(shoppingCartEntry); }
public void RemoveEntry(int listingId) { ShoppingCartEntry cartEntry = ShoppingCartEntries.Where(entry => Object.Equals(entry.UserID, this.Id) && entry.ListingID == listingId).Single(); ShoppingCartEntries.Remove(cartEntry); }