private void randomResult(SlotSpinResponse slotSpinResponse)
        {
            //not really random.
            RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();

            byte[] randomNumber = new byte[slotSpinResponse.Results.Length];
            randomNumberGenerator.GetBytes(randomNumber);
            slotSpinResponse.Results = randomNumber.Select(p => p % 10).ToArray <int>();
        }
        /// <summary>
        /// Handle the request of api
        /// </summary>
        /// <param name="slotSpinReq"></param>
        /// <returns></returns>
        public SlotSpinResponse HandleRequest(SlotSpinReq slotSpinReq)
        {
            SlotSpinResponse slotSpinResponse = new SlotSpinResponse();

            User user = userService.GetUser(slotSpinReq.Uid);
            int  size = GetSlotQueueSize();

            slotSpinResponse.Results = new int[size];

            //create random result
            randomResult(slotSpinResponse);

            //calcute the result
            calcResult(slotSpinResponse);
            user.Balance -= slotSpinReq.Bet;
            user.Balance += slotSpinResponse.WonAmount;

            //save results
            userService.UpdateUser(slotSpinReq.Uid, user);

            return(slotSpinResponse);
        }
        private void calcResult(SlotSpinResponse slotSpinResponse)
        {
            int maxValue = 0;

            for (int i = 0; i < slotSpinResponse.Results.Length;)
            {
                int j = i + 1;
                while (j < slotSpinResponse.Results.Length)
                {
                    if (slotSpinResponse.Results[i] == slotSpinResponse.Results[j])
                    {
                        maxValue = Math.Max(maxValue, (j - i + 1) * slotSpinResponse.Results[i]);
                        ++j;
                    }
                    else
                    {
                        i = j;
                        ++j;
                    }
                }
            }
        }