public static void SaveFeeds(ref RssLista feeds, ref YourMovies db)
 {
     db.Rss.InsertAllOnSubmit(feeds.feedit);
     db.SubmitChanges();
     feeds.feedit.Clear();
 }
        public static void DeSerialisoiXml(string uri, ref RssLista feed)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(RssLista));
            try
            {
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(uri);
                myRequest.AllowAutoRedirect = true;
                myRequest.Method = "GET";
                myRequest.Timeout = 10000;
                WebResponse myResponse = myRequest.GetResponse();

                XmlTextReader reader = new XmlTextReader(myResponse.GetResponseStream());
                feed = (RssLista)deserializer.Deserialize(reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
        }
        public void myIni()
        {
            if (username != null)
            {
                Tyokalut.IsEnabled = true;
                Menubaari.IsEnabled = true;

                feedit = new RssLista();
                string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                SqlConnection myConnection = new SqlConnection(con);
                db = new YourMovies(myConnection);
                etsityt = new List<Elokuva>();
                movies = new ElokuvaLista();
                newWTiedot = new List<Lisatiedot>();
                esine = new List<MenuItem>();

                //ElokuvaController.initDatabase(ref db);
                //UserController.RegisterUser("teppo", "salasana", ref db);

                var leffat = ElokuvaController.getMoviesByUsers(username, ref db);

                bool exist = false;
                foreach (Elokuva leffa in leffat)
                {
                    MenuItem item = new MenuItem();
                    item.Header = leffa.Lista;
                    item.Click += new RoutedEventHandler(MenuItemClick);
                    foreach (MenuItem existingItem in esine)
                    {
                        if (item.Header.Equals(existingItem.Header) && item.Header.ToString() != "")
                        {
                            exist = true;
                        }
                    }
                    if (!exist)
                    {
                        esine.Add(item);
                        mnOmatelo.Items.Add(item);
                    }
                    exist = false;

                }
                valittulista = Properties.Settings.Default.OletusListaNimi.ToString();
                var oletusLeffat = ElokuvaController.getMoviesByListName(valittulista, username, ref db);
                if (oletusLeffat != null)
                {
                    movies.Movies = oletusLeffat.ToList<Elokuva>();
                }
                else
                {
                    MessageBox.Show("Oletus listaa ei ole enää olemassa!", "Virhe", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                etsityt = movies.Movies;

                paivitaDatagrid(movies.Movies);
                this.SizeToContent = SizeToContent.WidthAndHeight;
            }
            else
            {
                Tyokalut.IsEnabled = false;
                Menubaari.IsEnabled = false;

                while (username == null)
                {
                    login = new Login();
                    if (login.ShowDialog() == false)
                    {
                        if (login.userName != null)
                        {
                            username = login.userName;
                            myIni();
                        }
                        else
                        {
                            Environment.Exit(1);
                        }
                    }
                }
            }
        }