private void RemoveConnection() { using (TedTechVPNEntities dbContext = new TedTechVPNEntities()) { dbContext.VpnConnection.Attach(SelectedConnection.Connection); dbContext.Entry(SelectedConnection.Connection).State = EntityState.Deleted; dbContext.SaveChanges(); } VpnConnections.Remove(SelectedConnection); }
public void Load() { using (TedTechVPNEntities dbContext = new TedTechVPNEntities()) { VpnConnections = new ObservableCollection <VpnConnectionInfo>(); foreach (VpnConnection connection in dbContext.VpnConnection.Where(x => x.IsActive)) { VpnConnections.Add(new VpnConnectionInfo(connection)); } } }
public bool Login() { UnicodeEncoding encoding = new UnicodeEncoding(); using (TedTechVPNEntities dbContext = new TedTechVPNEntities()) { User user = dbContext.User.FirstOrDefault(u => u.Name == User.Name); if (user == null || user.Password != encoding.GetString(_passwordProvider.Hash(SecurePassword, encoding.GetBytes(user.Salt)))) { return(false); } User.IsPrivileged = user.IsPrivileged; return(true); } }
public void SaveConnectionChanges() { if (SelectedConnection == null) { return; } using (TedTechVPNEntities dbContext = new TedTechVPNEntities()) { if (dbContext.VpnConnection.Any(x => x.Id == SelectedConnection.Connection.Id)) { dbContext.VpnConnection.Attach(SelectedConnection.Connection); dbContext.Entry(SelectedConnection.Connection).State = EntityState.Modified; } else { SelectedConnection.Connection.IsActive = true; dbContext.Entry(SelectedConnection.Connection).State = EntityState.Added; } dbContext.SaveChanges(); } }