Ejemplo n.º 1
0
        public GameProcessService(BulkaContext context)
        {
            _gameProcessRepository = new GameProcessRepository(context);
            _playersRepository     = new PlayersRepository(context);
            _clubRepository        = new ClubRepository(context);

            PaymentService       = new PaymentService(new PaymentRepository(context));
            PlayerSessionService = new PlayerSessionService(context);

            DateTime = DateTime.Now;
        }
Ejemplo n.º 2
0
        public void StopProcess(int gameProcessId)
        {
            var gameProcess = _gameProcessRepository.GetAll().First(c => c.Id == gameProcessId);

            if (!gameProcess.EndDateTime.HasValue)
            {
                gameProcess.EndDateTime = DateTime;
                _gameProcessRepository.Save();

                var playersSessions = new List <PlayerSession>();

                var gameProcessItems = GetGameProcessItems(gameProcess);

                foreach (var gameProcessItem in gameProcessItems)
                {
                    if (gameProcessItem.OutPut == null)
                    {
                        gameProcessItem.OutPut = new PlayerStuff
                        {
                            Amount = 0,
                            Time   = DateTime
                        };
                    }

                    playersSessions.Add(new PlayerSession
                    {
                        PlayerId = gameProcessItem.PlayerId,
                        ClubId   = gameProcess.ClubId,
                        Begin    = gameProcessItem.Input.First().Time,
                        End      = gameProcessItem.OutPut.Time,
                        Input    = gameProcessItem.Input.Sum(c => c.Amount),
                        Output   = gameProcessItem.OutPut.Amount
                    });
                }

                PlayerSessionService.Create(playersSessions);
            }
        }