public async void SetConnection() { eventAggregator.PublishOnUIThread(Connection.DatabaseType); if (!string.IsNullOrEmpty(Connection.FileName)) { try { IsProcessRingActive = true; ConnectionService.SaveUserSettings(Connection); switch (Connection.DatabaseType) { case DatabaseType.Json: SetConnectionService(new JsonTaskService(Connection.FileName)); IsSetttingsVisible = false; break; case DatabaseType.SqlLite: SetConnectionService(new SqlLiteService(Connection.FileName)); IsSetttingsVisible = false; break; case DatabaseType.SqlServer: var sqlService = new SQLService(Connection); try { await System.Threading.Tasks.Task.Run(() => sqlService.Authenticate()); SetConnectionService(sqlService); IsProcessRingActive = false; MessageBox.Show("Connected Successfully"); IsSetttingsVisible = false; } catch { IsSetttingsVisible = true; } break; } } catch (Exception e) { MessageBox.Show(e.ToString()); ConnectionService.DeleteUserSettings(); } finally { IsProcessRingActive = false; } } }