Exemplo n.º 1
0
        public WinPrizeEN ExchangeCombos(int consumerID, int ComboID, ref string error)
        {
            WinPrizeEN wPrize = new WinPrizeEN();

            wPrize.RegDate = DateTime.Now;

            var getLastWinPrize = gameDAL.GetLastWinPrize(consumerID, ref error);

            if (error == "")
            {
                int tcPrize = int.Parse(ConfigurationManager.AppSettings["TimeToChangePrize"].ToString());

                TimeSpan difference = (getLastWinPrize != null && error == "") ? wPrize.RegDate - getLastWinPrize.RegDate : new TimeSpan(tcPrize, 0, 0);

                if (difference.Days > 0 || difference.Hours >= tcPrize)
                {
                    wPrize = gameDAL.ExchangeCombos(consumerID, ComboID, ref error);
                }
                else
                {
                    string timer = Convert.ToString(tcPrize - difference.Hours);
                    wPrize.ResponseCode = "02";
                    wPrize.Message      = "It is not possible to change the prize, you have to wait " + timer + " hour";
                    wPrize.WaitTime     = timer;
                }
            }
            return(wPrize);
        }