//private string connectionString; public GenericRepository(BlackJackContext blackJackContex) { _blackJackContex = blackJackContex; _blackJackContex.Configuration.ProxyCreationEnabled = false; _dbSet = blackJackContex.Set <TEntity>(); //connectionString = ConfigurationManager.ConnectionStrings["BlackJackContex"].ConnectionString; }
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(); } }
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" }); } } }
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; }
// 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); } }
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); }
public EFBaseRepository(BlackJackContext context) { _dbContext = context; }
public PlayerRepository(BlackJackContext blackJackContext) { _blackJacksContext = blackJackContext; }
public RoundPlayerCardRepository(BlackJackContext context) { _context = context; }
public GamePlayerRepository(BlackJackContext blackJackContext) { _blackJackContex = blackJackContext; }
public BotRepository(BlackJackContext db) { this.db = db; }
public BlackJackController(BlackJackContext _context) { context = _context; }
public ExchangeServices(BlackJackContext context, IMapper mapper, IRedisCacheService redisCacheManager) { _context = context; _mapper = mapper; _redisCacheManager = redisCacheManager; }
public GameRepository(BlackJackContext dbContext) { _dbContext = dbContext; }
public CardRepository(BlackJackContext blackJackContext) { _blackJackContext = blackJackContext; }
public GameResultRepository(BlackJackContext context) : base(context) { _context = context; }
//private string connectionString; public Repository(BlackJackContext blackJackContex) { _blackJackContex = blackJackContex; _dbSet = blackJackContex.Set <TEntity>(); //connectionString = ConfigurationManager.ConnectionStrings["BlackJackContex"].ConnectionString; }
public EFGameResultsRepository(BlackJackContext context) : base(context) { }
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()) { }
public EFPlayerRepository(BlackJackContext contex) : base(contex) { }
public EFUnitOfWork(string connectionString) { _db = new BlackJackContext(connectionString); }
public ResultRepository(BlackJackContext blackJackContext) { _blackJacksContext = blackJackContext; }
public GenericRepository(BlackJackContext context) { _context = context; _dbSet = context.Set <T>(); }
public PlayerRepository(BlackJackContext dbContext) { _dbContext = dbContext; }
public CardRepository(BlackJackContext context) { _db = context; }
public GameHistoryRepository(BlackJackContext context) { _db = context; }