Esempio n. 1
0
        private async Task <IEnumerable <string> > GerReasons()
        {
            try
            {
                using (var repo = new ReasonRepository())
                {
                    var str = await repo.GetKickReasonsAsync();

                    return(str);
                }
            }
            catch (Exception)
            {
                return(new[] { string.Empty });
            }
        }
Esempio n. 2
0
        private async void Init()
        {
            Servers = (await _infoRepository.GetServerInfoAsync()).Select(x => new ServerInfoModel(x)).ToList();


            using (var dc = new ReasonRepository())
            {
                BanReasons = (await dc.GetBanReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                KickReasons = (await dc.GetKickReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                BanTimes =
                    (await dc.GetBanTimesAsync()).Select(x => new BanTimeEdit {
                    Text = x.Title, Minutes = x.TimeInMinutes
                }).ToList();

                BadNicknames = (await dc.GetBadNicknamesAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                ImportantWords = (await dc.GetImportantWordsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
            }

            var zones = TimeZoneInfo.GetSystemTimeZones().ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i].Id == Settings.TimeZoneInfo?.Id)
                {
                    zones[i] = Settings.TimeZoneInfo;
                }
            }

            TimeZones = zones;

            RaisePropertyChanged(nameof(Servers));
            RaisePropertyChanged(nameof(BanReasons));
            RaisePropertyChanged(nameof(KickReasons));
            RaisePropertyChanged(nameof(BanTimes));
            RaisePropertyChanged(nameof(BadNicknames));
            RaisePropertyChanged(nameof(ImportantWords));
            RaisePropertyChanged(nameof(TimeZones));
        }
Esempio n. 3
0
        private async void Init()
        {
            var dbServers = (await _infoRepository.GetServerInfoAsync()).ToArray();

            Servers = dbServers.Select(x => new ServerInfoModel(x)).ToList();


            using (var dc = new ReasonRepository())
            {
                BanReasons = (await dc.GetBanReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                KickReasons = (await dc.GetKickReasonsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                BanTimes =
                    (await dc.GetBanTimesAsync()).Select(x => new BanTimeEdit {
                    Text = x.Title, Minutes = x.TimeInMinutes
                }).ToList();

                BadNicknames = (await dc.GetBadNicknamesAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
                ImportantWords = (await dc.GetImportantWordsAsync()).Select(x => new ReasonEdit {
                    Text = x
                }).ToList();
            }

            var zones = TimeZoneInfo.GetSystemTimeZones().ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i].Id == Settings.TimeZoneInfo?.Id)
                {
                    zones[i] = Settings.TimeZoneInfo;
                }
            }

            TimeZones = zones;

            var customStore = _settingsStoreSource.GetCustomSettingsStore();

            ServerSettings = dbServers.Select(x => new
            {
                ServerSettings =
                    customStore.Load <ServerSettings>(x.Id.ToString()) ?? new ServerSettings()
                {
                    IdleTimeInMins  = 0,
                    KickIdlePlayers = false,
                    IdleKickReason  = "Lobby Idle",
                    ServerId        = x.Id
                },
                ServerName = x.Name
            })
                             .Select(x => new ServerSettingsVM()
            {
                ServerId        = x.ServerSettings.ServerId,
                IdleTimeInMins  = x.ServerSettings.IdleTimeInMins,
                ServerName      = x.ServerName,
                IdleKickReason  = x.ServerSettings.IdleKickReason,
                KickIdlePlayers = x.ServerSettings.KickIdlePlayers
            })
                             .ToList();


            RaisePropertyChanged(nameof(Servers));
            RaisePropertyChanged(nameof(BanReasons));
            RaisePropertyChanged(nameof(KickReasons));
            RaisePropertyChanged(nameof(BanTimes));
            RaisePropertyChanged(nameof(BadNicknames));
            RaisePropertyChanged(nameof(ImportantWords));
            RaisePropertyChanged(nameof(TimeZones));
            RaisePropertyChanged(nameof(ServerSettings));
        }