Пример #1
0
        public async Task AddArena(Lobby data)
        {
            var existingLobby = await LobbyController.GetLobby(_context, data.GuildId, data.ChannelId, data.OwnerId);

            if (existingLobby != null)
            {
                existingLobby.RoomId      = data.RoomId;
                existingLobby.Password    = data.Password;
                existingLobby.Comment     = data.Comment;
                existingLobby.PublishTime = data.PublishTime;
                await LobbyController.UpdateLobby(_context, existingLobby);
            }
            else
            {
                var key = new { gId = data.GuildId, cId = data.ChannelId, uId = data.OwnerId };
                await LobbyController.CreateLobby(_context, data);

                var timerData = new TimerData {
                    timeSpan = _arenaTimeSpan
                };
                timerData.callback += async() => await Pop(data.GuildId, data.ChannelId, data.OwnerId);

                _deleteTimerService.SaveData(key, timerData);
            }
        }