Example #1
0
        /// <summary>
        /// Get the exact <c>Box</c> by the arguments
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns><c>null</c> if no match</returns>
        public Box GetBox(double x, double y)
        {
            //Search the main tree
            var mainTreeSearchTerm = new BottomSizeTreeDataModel(x);

            if (_mainTree.FindExact(mainTreeSearchTerm, out BottomSizeTreeDataModel mainTreeData) == false)
            {
                return(null);
            }

            //search the inner tree
            var innerTreeSearchTerm = new HeightSizeTreeDataModel(y);

            if (mainTreeData.InnerTree.FindExact(innerTreeSearchTerm, out HeightSizeTreeDataModel innerTreeData) == false)
            {
                return(null);
            }

            //return the box
            return(new Box
            {
                Id = innerTreeData.Id,
                X = mainTreeData.X,
                Y = innerTreeData.Y,
                Count = innerTreeData.Count,
                TimeLastPurchase = innerTreeData.DateNode.Data.TimeLastPurchase
            });
        }