public void Execute(object parameter) { var viewModel = parameter as SettingsViewModel; if (viewModel == null) { throw new ArgumentException(@"Invalid ViewModel ", "parameter"); } _saveService.SaveCredentials(viewModel.MattermostUrl, viewModel.TeamId, viewModel.Username, viewModel.Version); _saveService.SaveChannels(string.Empty); _window.Close(); }
public async Task OnRefreshChannelListClick(Office.IRibbonControl control) { try { var session = await _sessionRepository.RestoreSession(); var channelList = await Task.Run(() => session.GetChannels()); var channelSettings = new ChannelListSetting { Channels = channelList.Select(x => x.ToSetting()).ToList() }; var channelMap = JsonConvert.SerializeObject(channelSettings); await Task.Run(() => _settingsSaveService.SaveChannels(channelMap)); } catch (MattermostException mex) { _errorDisplay.Display(mex); } catch (Exception exception) { _errorDisplay.Display(exception); } }