예제 #1
0
 public SolutionLogic(ISolutionRepository solutionRepository, ITaskManager taskManager, IConfiguration configuration, IIndex <string, ICompiler> compilers, IDuelRepository duelRepository)
 {
     _solutionRepository = solutionRepository;
     _taskManager        = taskManager;
     _configuration      = configuration;
     _compilers          = compilers;
     _duelRepository     = duelRepository;
 }
예제 #2
0
 public TaskManager(IConfiguration iconfiguration, ISolutionRepository solutionRepository,
                    IDuelRepository duelRepository, IMemoryCache cache)
 {
     _iconfiguration     = iconfiguration;
     _solutionRepository = solutionRepository;
     _duelRepository     = duelRepository;
     _cache = cache;
 }
예제 #3
0
 public TaskRepository(ISolutionRepository solutionRepository,
                       IDuelRepository duelRepository, IMemoryCache cache, ApplicationDbContext dbContext)
 {
     _solutionRepository = solutionRepository;
     _duelRepository     = duelRepository;
     _cache     = cache;
     _dbContext = dbContext;
 }
예제 #4
0
 public BalanceLogic(ISolutionRepository solutionRepository, ITaskManager taskManager,
                     IPurchaseRepository purchaseRepository, IPrizeManager prizeManager, IDuelRepository duelRepository)
 {
     _solutionRepository = solutionRepository;
     _taskManager        = taskManager;
     _purchaseRepository = purchaseRepository;
     _prizeManager       = prizeManager;
     _duelRepository     = duelRepository;
 }
예제 #5
0
 public UserController(IBalanceLogic balanceLogic, IPurchaseRepository purchaseRepository,
                       IUserRepository userRepository, IDuelRepository duelRepository, ITaskRepository taskRepository)
 {
     _balanceLogic       = balanceLogic;
     _purchaseRepository = purchaseRepository;
     _userRepository     = userRepository;
     _duelRepository     = duelRepository;
     _taskRepository     = taskRepository;
 }
예제 #6
0
        public BalanceLogic(ISolutionRepository solutionRepository,
                            IPurchaseRepository purchaseRepository, IPrizeRepository prizeRepository, IDuelRepository duelRepository)
        {
            _solutionRepository = solutionRepository;

            _purchaseRepository = purchaseRepository;
            _prizeRepository    = prizeRepository;
            _duelRepository     = duelRepository;
        }
예제 #7
0
 public DuelHub(ITaskManager taskManager, IDuelRepository duelRepository, ISolutionLogic solutionLogic,
                IHostingEnvironment hostingEnv, IDuelLogic duelLogic, IUserRepository userRepository)
 {
     _taskManager    = taskManager;
     _duelRepository = duelRepository;
     _solutionLogic  = solutionLogic;
     _hostingEnv     = hostingEnv;
     _duelLogic      = duelLogic;
     _userRepository = userRepository;
 }
예제 #8
0
        public BoardLoader(IPrizeManager prizeManager, ISolutionRepository solutionRepository, IPurchaseRepository purchaseRepository, IUserRepository userRepository, IDuelRepository duelRepository, ApplicationDbContext dbContext)
        {
            _prizeManager       = prizeManager;
            _solutionRepository = solutionRepository;
            _purchaseRepository = purchaseRepository;
            _userRepository     = userRepository;
            _duelRepository     = duelRepository;
            _dbContext          = dbContext;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            lock (dbContext)
            {
                _solutions = _solutionRepository.GetAll().Where(s => s.IsCorrect).ToList();
                _duels     = _duelRepository.GetAllDuelsWithWinner().ToList();

                _prizes    = _prizeManager.GetAllPrizes().Result;
                _purchases = _purchaseRepository.GetAll().ToList();
                _users     = _userRepository.GetAll().ToList();

                UpdateLeaderBoard();
            }

            _timer = new Timer(state =>
            {
                try
                {
                    lock (dbContext)
                    {
                        SwitchBoard();

                        switch (Board)
                        {
                        case BoardEnum.LeaderBoard:
                            UpdateLeaderBoard();
                            Changed(nameof(LeaderBoard));
                            break;

                        case BoardEnum.Prizes:
                            {
                                GetNewPurchases();
                                UpdatePrizes();
                                Changed(nameof(PrizesForPoints));
                                break;
                            }

                        case BoardEnum.TodayPrizes:
                            {
                                GetNewPurchases();
                                UpdateTodayPrizes();
                                Changed(nameof(TodaysPrize));
                                break;
                            }

                        case BoardEnum.WeekPrizes:
                            {
                                GetNewPurchases();
                                UpdateWeekPrizes();
                                Changed(nameof(WeeksPrize));
                                break;
                            }

                        case BoardEnum.Duels:
                            {
                                UpdateDuelsStatistics();
                                Changed(nameof(DuelsStatistics));
                                break;
                            }
                        }

                        Changed(nameof(Board));
                        Changed(nameof(LastUpdate));

                        PushUpdates();
                    }
                }
                catch (Exception ex) { };
            }, null, 0, 15000);
        }
예제 #9
0
 public DuelLogic(IDuelRepository duelRepository, IConfiguration configuration)
 {
     _duelRepository = duelRepository;
     _configuration  = configuration;
 }