예제 #1
0
 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);
 }
예제 #2
0
 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));
         }
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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();
            }
        }