public VendingMachineResponse ReturnCoins()
        {
            var response = new VendingMachineResponse();

            response.Product = null;
            response.Change  = _changeCalculator.GetChange(this.CurrentTransaction.Balance);

            this.CurrentTransaction     = null;
            this.CurrentSelectedProduct = null;
            return(response);
        }
        public VendingMachineResponse SelectProduct(ProductCode code)
        {
            if (this.Products.Count(p => p.Code == code) > 0)
            {
                var product = this.Products.First(p => p.Code == code);
                CurrentSelectedProduct = product;

                if (product.Cost > this.CurrentTransaction.Balance)
                {
                    var errorResponse = new VendingMachineResponse()
                    {
                        Message = $"PRICE: {product.Cost.ToString("C2")}. INSERT COIN.",
                        Product = product
                    };
                    return(errorResponse);
                }

                var response = new VendingMachineResponse()
                {
                    Message = "THANK YOU",
                    Product = product,
                };

                if (product.Cost < this.CurrentTransaction.Balance)
                {
                    response.Change = _changeCalculator.GetChange(CurrentTransaction.Balance - product.Cost);
                }

                this.Products.Remove(product);

                this.CurrentTransaction     = null;
                this.CurrentSelectedProduct = null;

                return(response);
            }
            else
            {
                var response = new VendingMachineResponse()
                {
                    Message = "SOLD OUT",
                    Product = null
                };
                return(response);
            };
        }