Example #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);
        }
Example #2
0
        public WinPrizeEN ProcessToWinPrizeWildcard(int consumerID, string LocationID, int AgeID, ref string error)
        {
            WinPrizeEN    result        = new WinPrizeEN();
            AchievementEN achievementEN = new AchievementEN();

            try
            {
                con.Cnn.Open();

                result = con.Cnn.Query <WinPrizeEN>("SpProcessToWinPrizeWildcard", new { ConsumerID = consumerID, LocationID = LocationID, AgeID = AgeID },
                                                    commandType: CommandType.StoredProcedure).FirstOrDefault();

                result.tracking = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumer", new { @ConsumerID = consumerID },
                                                                    commandType: CommandType.StoredProcedure).FirstOrDefault();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                Console.WriteLine("Error GameDAL: " + ex.Message);
                EventViewerLoggerDAL.LogError(ex.Message);
            }
            finally
            {
                con.Cnn.Close();
            }

            return(result);
        }
Example #3
0
        public WinPrizeEN ProcessToValidateAndWinPrizeWildCard(int ConsumerID, string LocationID, int AgeID, ref string error)
        {
            WinPrizeEN wPrize = new WinPrizeEN();

            wPrize.RegDate = DateTime.Now;
            try
            {
                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(24, 0, 0);

                    if (difference.Days > 1 || difference.Hours > 0)
                    {
                        var process = gameDAL.ProcessToWinPrizeWildcard(ConsumerID, LocationID, AgeID, ref error);

                        if (process.ResponseCode == "00")
                        {
                            wPrize.ResponseCode = process.ResponseCode;
                            wPrize.Message      = process.Message;
                            wPrize.Code         = process.Code;
                            wPrize.Title        = process.Title;
                            wPrize.Dial         = process.Dial;
                            wPrize.RGBColor     = process.RGBColor;
                            wPrize.HexColor     = process.HexColor;
                            wPrize.logoUrl      = process.logoUrl;
                            wPrize.Description  = process.Description;

                            wPrize.CurrentCoinsProgress = process.tracking.CurrentCoinsProgress;
                            wPrize.TotalWinCoins        = process.tracking.TotalWinCoins;
                            wPrize.TotalWinPrizes       = process.tracking.TotalWinPrizes;
                            wPrize.TotalSouvenirs       = process.tracking.TotalSouvenirs;
                            wPrize.AgeID = process.tracking.AgeID;
                        }
                        else
                        {
                            wPrize.ResponseCode = process.ResponseCode;
                            wPrize.Message      = process.Message;
                        }
                    }
                    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 + " hours";
                        wPrize.WaitTime     = timer;
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            return(wPrize);
        }
        public IResponse createWinPrizeResultsResponse(WinPrizeEN pWinPrize, string error)
        {
            WinPrizeWildcardResponse response = new WinPrizeWildcardResponse();

            if (pWinPrize.ResponseCode == "00")
            {
                response.Type         = 3;
                response.ResponseCode = pWinPrize.ResponseCode;
                response.Message      = pWinPrize.Message;
                response.Code         = pWinPrize.Code;
                response.Title        = pWinPrize.Title;
                response.Dial         = pWinPrize.Dial;
                response.RGBColor     = pWinPrize.RGBColor;
                response.HexColor     = pWinPrize.HexColor;
                response.logoUrl      = pWinPrize.logoUrl;
                response.Description  = pWinPrize.Description;

                response.tracking = new TrackingResponse();
                response.tracking.CurrentCoinsProgress = pWinPrize.CurrentCoinsProgress;
                response.tracking.TotalWinCoins        = pWinPrize.TotalWinCoins;
                response.tracking.TotalWinPrizes       = pWinPrize.TotalWinPrizes;
                response.tracking.TotalSouvenirs       = pWinPrize.TotalSouvenirs;
                response.tracking.AgeID = pWinPrize.AgeID;
                response.PrizeLevel     = pWinPrize.PrizeLevel;

                if (pWinPrize.Achievement.NewLevel > 0)
                {
                    response.Achievement                = new NewAchievement();
                    response.Achievement.Name           = pWinPrize.Achievement.Name;
                    response.Achievement.Level          = pWinPrize.Achievement.Level;
                    response.Achievement.Score          = pWinPrize.Achievement.Score;
                    response.Achievement.ValueNextLevel = pWinPrize.Achievement.ValueNextLevel;
                    response.Achievement.Prize          = pWinPrize.Achievement.Prize;
                }
            }
            else
            {
                if (pWinPrize.ResponseCode == "02")
                {
                    response.ResponseCode = pWinPrize.ResponseCode;
                    response.Message      = pWinPrize.Message;
                    response.WaitTime     = pWinPrize.WaitTime;
                }
                else
                {
                    response.ResponseCode = pWinPrize.ResponseCode;
                    response.Message      = pWinPrize.Message;
                }
            }

            return(response);
        }
Example #5
0
        public WinPrizeEN ProcessToExchangeSouvenirByPrize(int consumerID, int SouvenirID, int CountryID, ref string error)
        {
            WinPrizeEN    result        = new WinPrizeEN();
            AchievementEN achievement   = new AchievementEN();
            int           TotalWinCoins = 0;

            try
            {
                con.Cnn.Open();
                con.Tra = con.Cnn.BeginTransaction();

                result = con.Cnn.Query <WinPrizeEN>("SpExchangeSouvenirByPrize", new { ConsumerID = consumerID, SouvenirID = SouvenirID, CountryID = CountryID },
                                                    con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();

                if (result.ResponseCode == "04")
                {
                    result = con.Cnn.Query <WinPrizeEN>("SpExchangeSouvenirByPrize", new { ConsumerID = consumerID, SouvenirID = SouvenirID, CountryID = CountryID },
                                                        con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();
                }


                result.tracking = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumer", new { @ConsumerID = consumerID },
                                                                    con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();


                TotalWinCoins = result.tracking.TotalWinCoins;

                result.Achievement = ProcessToWinAchievement(consumerID, 1, TotalWinCoins, 8, con.Tra);

                con.Tra.Commit();
            }
            catch (Exception ex)
            {
                con.Tra.Rollback();
                error = ex.Message;
                Console.WriteLine("Error GameDAL: " + ex.Message);
                EventViewerLoggerDAL.LogError(ex.Message);
            }
            finally
            {
                con.Cnn.Close();
            }

            return(result);
        }
Example #6
0
        public WinPrizeEN ProcessToWinPrize(int consumerID, int CountryID, ref string error)
        {
            WinPrizeEN    result        = new WinPrizeEN();
            AchievementEN achievementEN = new AchievementEN();

            try
            {
                con.Cnn.Open();
                con.Tra = con.Cnn.BeginTransaction();

                result = con.Cnn.Query <WinPrizeEN>("SpProcessToWinPrize", new { ConsumerID = consumerID, CountryID = CountryID }, con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();

                if (result.ResponseCode == "04")
                {
                    result = con.Cnn.Query <WinPrizeEN>("SpProcessToWinPrize", new { ConsumerID = consumerID, CountryID = CountryID }, con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault();

                    if (result.ResponseCode == "00")
                    {
                        result.Achievement = ProcessToWinAchievement(consumerID, 1, result.TotalWinCoins, 8, con.Tra);
                    }
                }
                else if (result.ResponseCode == "00")
                {
                    result.Achievement = ProcessToWinAchievement(consumerID, 1, result.TotalWinCoins, 8, con.Tra);
                }

                con.Tra.Commit();
            }
            catch (Exception ex)
            {
                con.Tra.Rollback();
                result.Code = "500";
                error       = ex.Message;
                Console.WriteLine("Error GameDAL: " + ex.Message);
                EventViewerLoggerDAL.LogError(ex.Message);
            }
            finally
            {
                con.Cnn.Close();
            }

            return(result);
        }
        public WinPrizeEN IsAvailableWinPrize(int consumerID, ref string error)
        {
            WinPrizeEN result = new WinPrizeEN();

            try
            {
                con.Cnn.Open();

                result = con.Cnn.Query <WinPrizeEN>("GetPrizeByConsumerID", new { @ConsumerID = consumerID },
                                                    commandType: CommandType.StoredProcedure).FirstOrDefault();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error WinPrizeDAL: " + ex.Message);
                EventViewerLoggerDAL.LogError(ex.Message);
            }
            finally
            {
                con.Cnn.Close();
            }

            return(result);
        }
Example #8
0
        public WinPrizeEN ProcessToValidateAndWinPrize(int ConsumerID, int CountryID, ref string error)
        {
            WinPrizeEN wPrize = new WinPrizeEN();

            wPrize.RegDate = DateTime.Now;
            try
            {
                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.ProcessToWinPrize(ConsumerID, CountryID, 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 + " hours";
                        wPrize.WaitTime     = timer;
                    }
                }
            }
            catch (Exception ex)
            {
                wPrize.Code = "500";
                error       = ex.Message;
            }

            return(wPrize);
        }