示例#1
0
        /// <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);
        }
示例#2
0
        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;
        }
示例#3
0
        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;
        }
示例#4
0
        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;
        }
示例#5
0
        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);
            }
        }
示例#6
0
        /// <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);
        }
示例#7
0
        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);
        }
示例#8
0
        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;
        }
示例#9
0
        public ShoppingCartEntry RemoveShoppingCartEntry(ShoppingCartEntry cartEntry)
        {
            if (ShoppingCartEntries.Contains(cartEntry))
            {
                ShoppingCartEntries.Remove(cartEntry);
                return cartEntry;
            }

            return null;
        }
示例#10
0
 public void AddShoppingCartEntry(ShoppingCartEntry cartEntry)
 {
     cartEntry.Listing = this;
     this.ShoppingCartEntries.Add(cartEntry);
 }
示例#11
0
        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;
        }
示例#12
0
        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;
            }
        }
示例#13
0
 public void InsertShoppingCartEntry(ShoppingCartEntry shoppingCartEntry)
 {
     context.ShoppingCartEntries.Add(shoppingCartEntry);
 }
示例#14
0
        public void RemoveEntry(int listingId)
        {
            ShoppingCartEntry cartEntry = ShoppingCartEntries.Where(entry => Object.Equals(entry.UserID, this.Id) && entry.ListingID == listingId).Single();

            ShoppingCartEntries.Remove(cartEntry);
        }