Esempio n. 1
0
        /// <summary>
        /// Try to add a new incremental rule into this room
        /// </summary>
        /// <param name="incrementalRule">The new attendant and potential buyer</param>
        /// <returns></returns>
        public bool TryAddNewIncrementalRange(IncrementalRule incrementalRule)
        {
            var fiscal = new RoomCanReceiveNewIncrementalRuleValidation();
            var result = fiscal.Valid(this);

            if (!result.IsValid)
            {
                ValidationErrors = result.Errors;
                return(false);
            }

            IncrementalRules.Add(incrementalRule);

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Calculate the next minimum bid
        /// </summary>
        /// <returns>Minimum bid amount</returns>
        public decimal NextPrice()
        {
            if (!Bids.Any())
            {
                return(CurrentItem.StartingBid);
            }

            var nextPrice         = Bids.Max(bid => bid.Amount);
            var incrementalRenges = IncrementalRules.OrderByDescending(range => range.MinimumItemValue).ToList();

            incrementalRenges.ForEach(range =>
            {
                if (nextPrice >= range.MinimumItemValue)
                {
                    return;
                }
                nextPrice += range.Increment;
            });
            return(nextPrice);
        }