//private string connectionString;

        public GenericRepository(BlackJackContext blackJackContex)
        {
            _blackJackContex = blackJackContex;
            _blackJackContex.Configuration.ProxyCreationEnabled = false;
            _dbSet = blackJackContex.Set <TEntity>();
            //connectionString = ConfigurationManager.ConnectionStrings["BlackJackContex"].ConnectionString;
        }
Esempio n. 2
0
 public void Post(Data _data)
 {
     using (BlackJackContext dbContext = new BlackJackContext())
     {
         var model = dbContext.PlayLog.Where(pl => pl.SessionID == _data.session)?.FirstOrDefault();
         model.PutCache    = _data.putCache;
         model.CreatedDate = DateTime.Now;
         if (_data.isWin)
         {
             if (_data.putCache <= model.Cash)
             {
                 model.Cash += _data.putCache;
             }
         }
         else
         {
             if (_data.putCache <= model.Cash)
             {
                 model.Cash -= _data.putCache;
             }
             else
             {
                 model.Cash = 0;
             }
         }
         model.Win = _data.isWin;
         dbContext.SaveChanges();
     }
 }
Esempio n. 3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
            await Task.Delay(1000, stoppingToken);

            var conf = new RedisEndpoint()
            {
                Host = "****.redis.cache.windows.net", Port = 6379, Password = "******"
            };

            Console.WriteLine("Services Start...");
            using (IRedisClient client = new RedisClient(conf))
            {
                IRedisSubscription sub = null;
                using (sub = client.CreateSubscription())
                {
                    sub.OnMessage += (channel, exchange) =>
                    {
                        try
                        {
                            ExchangeModel _exchange = JsonConvert.DeserializeObject <ExchangeModel>(exchange);
                            Console.WriteLine(_exchange.Name + ": " + _exchange.Value);

                            //Redis UPDATE
                            using (IRedisClient clientServer = new RedisClient(conf))
                            {
                                string redisKey = "Exchange:" + _exchange.ID;
                                clientServer.Set <ExchangeModel>(redisKey, _exchange);
                            }

                            //Sql UPDATE
                            using (BlackJackContext context = new BlackJackContext())
                            {
                                var exchangeModel = context.Exchange.FirstOrDefault(ex => ex.Id == _exchange.ID);
                                exchangeModel.Value      = (decimal)_exchange.Value;
                                exchangeModel.UpdateDate = DateTime.Now;
                                context.SaveChanges();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    };
                    sub.SubscribeToChannels(new string[] { "Exchange" });
                }
            }
        }
Esempio n. 4
0
        public void OnException(ExceptionContext filterContext)
        {
            ExceptionDetail exceptionDetail = new ExceptionDetail()
            {
                ExceptionMessage = filterContext.Exception.Message,
                StackTrace       = filterContext.Exception.StackTrace,
                ControllerName   = filterContext.RouteData.Values["controller"].ToString(),
                ActionName       = filterContext.RouteData.Values["action"].ToString(),
                Date             = DateTime.Now
            };

            using (BlackJackContext db = new BlackJackContext())
            {
                db.ExceptionDetails.Add(exceptionDetail);
                db.SaveChanges();
            }

            filterContext.ExceptionHandled = true;
        }
Esempio n. 5
0
 // GET api/values/5
 public int?Get(string session)
 {
     using (BlackJackContext dbContext = new BlackJackContext())
     {
         var model = dbContext.PlayLog.Where(pl => pl.SessionID == session)?.FirstOrDefault();
         if (model == null)
         {
             PlayLog data = new PlayLog();
             data.Cash        = 500;
             data.CreatedDate = DateTime.Now;
             data.PutCache    = 0;
             data.SessionID   = session;
             data.Win         = true;
             dbContext.PlayLog.Add(data);
             dbContext.SaveChanges();
         }
         return(model != null ? model.Cash : 500);
     }
 }
Esempio n. 6
0
        public override void Load()
        {
            bool useDapper = true;

            if (useDapper)
            {
                string connectionString = ConfigurationManager.ConnectionStrings["DbConnection"].ConnectionString;

                Bind <IGameRepository>().To <DapperGameRepository>().WithConstructorArgument("connectionString", connectionString);
                Bind <IGameResultRepository>().To <DapperGameResultRepository>().WithConstructorArgument("connectionString", connectionString);
                Bind <IPlayerRepository>().To <DapperPlayerRepository>().WithConstructorArgument("connectionString", connectionString);
                Bind <ITurnRepository>().To <DapperTurnRepository>().WithConstructorArgument("connectionString", connectionString);

                return;
            }

            BlackJackContext blackJackContext = new BlackJackContext();

            Bind <IGameRepository>().To <GameRepository>().WithConstructorArgument("BlackJackContext", blackJackContext);
            Bind <IGameResultRepository>().To <GameResultRepository>().WithConstructorArgument("BlackJackContext", blackJackContext);
            Bind <IPlayerRepository>().To <PlayerRepository>().WithConstructorArgument("BlackJackContext", blackJackContext);
            Bind <ITurnRepository>().To <TurnRepository>().WithConstructorArgument("BlackJackContext", blackJackContext);
        }
Esempio n. 7
0
 public EFBaseRepository(BlackJackContext context)
 {
     _dbContext = context;
 }
 public PlayerRepository(BlackJackContext blackJackContext)
 {
     _blackJacksContext = blackJackContext;
 }
Esempio n. 9
0
 public RoundPlayerCardRepository(BlackJackContext context)
 {
     _context = context;
 }
 public GamePlayerRepository(BlackJackContext blackJackContext)
 {
     _blackJackContex = blackJackContext;
 }
Esempio n. 11
0
 public BotRepository(BlackJackContext db)
 {
     this.db = db;
 }
 public BlackJackController(BlackJackContext _context)
 {
     context = _context;
 }
Esempio n. 13
0
 public ExchangeServices(BlackJackContext context, IMapper mapper, IRedisCacheService redisCacheManager)
 {
     _context           = context;
     _mapper            = mapper;
     _redisCacheManager = redisCacheManager;
 }
Esempio n. 14
0
 public GameRepository(BlackJackContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 15
0
 public CardRepository(BlackJackContext blackJackContext)
 {
     _blackJackContext = blackJackContext;
 }
Esempio n. 16
0
 public GameResultRepository(BlackJackContext context) : base(context)
 {
     _context = context;
 }
Esempio n. 17
0
        //private string connectionString;

        public Repository(BlackJackContext blackJackContex)
        {
            _blackJackContex = blackJackContex;
            _dbSet           = blackJackContex.Set <TEntity>();
            //connectionString = ConfigurationManager.ConnectionStrings["BlackJackContex"].ConnectionString;
        }
Esempio n. 18
0
 public EFGameResultsRepository(BlackJackContext context) : base(context)
 {
 }
Esempio n. 19
0
 public EFMoveRepository(BlackJackContext context) : base(context)
 {
 }
 public CardRepository(BlackJackContext dbContext)
 {
     _dbContext = dbContext;
 }
 public DeckRepository(BlackJackContext dbContext)
 {
     _dbContext = dbContext;
 }
 public PlayerRepository(BlackJackContext context)
 {
     _db = context;
 }
 public PlayerRepository(BlackJackContext context) : base(new Context.MVC.BlackJackContext())
 {
 }
Esempio n. 24
0
 public EFPlayerRepository(BlackJackContext contex)
     : base(contex)
 {
 }
Esempio n. 25
0
 public EFUnitOfWork(string connectionString)
 {
     _db = new BlackJackContext(connectionString);
 }
Esempio n. 26
0
 public ResultRepository(BlackJackContext blackJackContext)
 {
     _blackJacksContext = blackJackContext;
 }
Esempio n. 27
0
 public GenericRepository(BlackJackContext context)
 {
     _context = context;
     _dbSet   = context.Set <T>();
 }
Esempio n. 28
0
 public PlayerRepository(BlackJackContext dbContext)
 {
     _dbContext = dbContext;
 }
 public CardRepository(BlackJackContext context)
 {
     _db = context;
 }
Esempio n. 30
0
 public GameHistoryRepository(BlackJackContext context)
 {
     _db = context;
 }