public PlayersTrackingEN UpdatePlayerAge(int pConsumerID, int pAgeID) { PlayersTrackingEN playerTracking = new PlayersTrackingEN(); try { playerTracking = cnn.Cnn.Query <PlayersTrackingEN>("SpUpdatePlayerAge", new { ConsumerID = pConsumerID, AgeID = pAgeID }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { playerTracking = null; Console.WriteLine("Error AgeDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); } finally { cnn.Cnn.Close(); } return(playerTracking); }
public PlayersTrackingEN GetProgressGameIsNotExistTracking(int consumerID, string LocationID, DateTime RegDate, ref string error) { PlayersTrackingEN result = new PlayersTrackingEN(); try { con.Cnn.Open(); result = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumerIsNotExistTracking", new { ConsumerID = consumerID, LocationID = LocationID, RegDate = RegDate }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine("Error ExchangeCoinsDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); result = null; error = ex.Message; } finally { con.Cnn.Close(); } return(result); }
public int UpdatePlayerTracking(PlayersTrackingEN tracking) { int?result = default(int); try { connection.Cnn.Open(); result = connection.Cnn.Update(tracking); } catch (Exception ex) { result = 0; Console.WriteLine(ex.Message); EventViewerLogger.LogError("UpdatePlayerTracking: " + ex.Message); } finally { connection.Cnn.Close(); } return(Convert.ToInt32(result)); }
public PlayersTrackingEN GetProgressGame(int consumerID, ref string error) { PlayersTrackingEN result = new PlayersTrackingEN(); try { con.Cnn.Open(); result = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumer", new { @ConsumerID = consumerID }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine("Error ExchangeCoinsDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); } finally { con.Cnn.Close(); } return(result); }
public bool AddCoinByTopup(int pConsumerID) { bool addedCoin = false; try { PlayersTrackingEN tracking = new PlayersTrackingEN(); int coins = int.Parse(ConfigurationManager.AppSettings["CoinsByTopupSuccess"].ToString()); var currentTracking = gameDAL.GetProgressGame(pConsumerID); if (currentTracking != null) { tracking = currentTracking; tracking.CurrentCoinsProgress = currentTracking.CurrentCoinsProgress + coins; tracking.CurrentCoinsProgress = (tracking.CurrentCoinsProgress >= 20) ? 20 : tracking.CurrentCoinsProgress; tracking.ModDate = DateTime.Now; tracking.ConsumerID = pConsumerID; tracking.PlayersTrackingID = currentTracking.PlayersTrackingID; tracking.TotalWinCoins = currentTracking.TotalWinCoins + coins; int UpdateResult = gameDAL.UpdatePlayerTracking(tracking); //Updates current progress if (UpdateResult > 0) { WinCoinEN winCoin = new WinCoinEN(); winCoin.ConsumerID = pConsumerID; winCoin.ExchangeCoins = coins; winCoin.RegDate = DateTime.Now; winCoin.Longitude = 0; winCoin.Latitude = 0; winCoin.LocationID = "0"; winCoin.ChestType = 1; var ResultInsert = gameDAL.InsertWinCoin(winCoin); if (ResultInsert > 0) { addedCoin = true; } } } else { tracking.CurrentCoinsProgress = coins; tracking.CurrentCoinsProgress = (tracking.CurrentCoinsProgress >= 20) ? 20 : coins; tracking.TotalWinCoins = coins; tracking.TotalWinPrizes = 0; int ResltInsert = gameDAL.InsertPlayerTracking(tracking.TotalWinCoins, tracking.CurrentCoinsProgress, pConsumerID, DateTime.Now); //Inserts current progress if (ResltInsert > 0) { WinCoinEN winCoin = new WinCoinEN(); winCoin.ConsumerID = pConsumerID; winCoin.ExchangeCoins = coins; winCoin.RegDate = DateTime.Now; winCoin.Longitude = 0; winCoin.Latitude = 0; winCoin.LocationID = "0"; winCoin.ChestType = 0; int InsertWinCoin = gameDAL.InsertWinCoin(winCoin); if (InsertWinCoin > 0) { addedCoin = true; } } } } catch (Exception ex) { Console.WriteLine(ex.Message); EventViewerLogger.LogError("" + ex.Message); } return(addedCoin); }