Ejemplo n.º 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);
 }
Ejemplo n.º 2
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();
            }
        }