Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool allGood = true;
            string message = null;
            string url = txbUrl.Text;

            if (!InputValidator.IsUrl(url))
            {
                allGood = false;
                message += "The \"Url-field\" must be in the correct format. \n";
            }
            if (InputValidator.IsEmpty(txbUpdate.Text))
            {
                allGood = false;
                message += "The \"Update Interval-field\" must be filled in. \n";
            }
            if (InputValidator.ContainsChar(txbUpdate.Text))
            {
                allGood = false;
                message += "The \"Update Interval-field\" can´t contain characters. \n";
            }
            //validering

            if (allGood)
            {
                RssReader rr = new RssReader();
                Feed feed = rr.ReadBasicFeed(url);
                rr.UpdateFeedItems(feed);
                feed.UpdateInterval = Convert.ToInt64(txbUpdate.Text) * TimeSpan.TicksPerDay;

                feed.Category = new Category() { Name = cbCategory.Text };
                feed.LastUpdate = DateTime.Today;

                feedList.Add(feed);

                MessageBox.Show("The new feed has been added!", "Sucess!");
                txbUpdate.Clear();
                txbUrl.Clear();

            }
            else
            {
                MessageBox.Show(message, "Error");
            }
        }