Beispiel #1
0
        private async void ConnectivityChangedExecute(object obj)
        {
            var wLanIdentification = await _connectivityService.GetWLanIdentification();

            var userWLanTimeEntryType = WLansBoundToTimeEntryTypes.FirstOrDefault(x => x.WifiName.ToUpper() == wLanIdentification.ToUpper());

            if (userWLanTimeEntryType != null)
            {
                UserWLanTimeEntryTypeId = userWLanTimeEntryType.DefaultTimeEntryTypeId;
                BoundToWLan             = true;
            }
            else
            {
                UserWLanTimeEntryTypeId = 0;
                BoundToWLan             = false;
            }
            ApplicationCommands.PremiseSettingChanged.Execute(null);
        }
        private async void PremiseSettingChangedExecute(object obj)
        {
            var list = new List <IUserWLanTimeEntryType>();

            list.AddRange(_userWlanSettingsService.WLansBoundToTimeEntryTypes);
            var availableNetworkList = await _connectivityService.GetAvailableNetworkList();

            var unlistedWLanTimeEntryTypes = availableNetworkList
                                             .Select(x => new UserWLanTimeEntryType(0, x))
                                             .Where(newWlans => list.All(x => x.WifiName != newWlans.WifiName));

            list.AddRange(unlistedWLanTimeEntryTypes);

            foreach (var userWLanTimeEntryType in list)
            {
                userWLanTimeEntryType.Connected = userWLanTimeEntryType.WifiName == await _connectivityService.GetWLanIdentification();
            }

            WLansBoundToTimeEntryTypes.Clear();
            WLansBoundToTimeEntryTypes.AddRange(list.Select(x =>
            {
                var timeEntryTypes = TimeEntryTypes.SingleOrDefault(t => t.Id == x.DefaultTimeEntryTypeId);
                return(new UserWLanTimeEntryTypeItemViewmodel(timeEntryTypes, x));
            }));
            WLansBoundToTimeEntryTypes.ItemChanged += WLansBoundToTimeEntryTypesOnCollectionChanged;
        }