Esempio n. 1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            SchoolEditForm schoolForm = new SchoolEditForm(DataContext);

            if (schoolForm.ShowDialog(schoolListView.SelectedItem) == DialogResult.OK)
            {
                DataContext.SubmitChanges();
                UpdateSchools();
            }
        }
Esempio n. 2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            SchoolEditForm schoolForm = new SchoolEditForm(DataContext);
            Entity         school     = new Entity();

            school.Country = DataContext.Countries.SingleOrDefault(c => c.Name == "United States");
            school.Type    = EntityType.University;

            if (suggestedSchoolListView.SelectedItem != null)
            {
                school.Name   = suggestedSchoolListView.SelectedItem.Name;
                school.Domain = suggestedSchoolListView.SelectedItem.Domain;
            }

            if (schoolForm.ShowDialog(school) == DialogResult.OK)
            {
                school.Topic           = new Topic();
                school.Topic.ForumId   = 7;
                school.Topic.UserId    = 2;
                school.Topic.Timestamp = DateTime.UtcNow;
                school.Topic.Title     = "Wall for " + school.Name;
                school.Topic.Status    = 0;
                school.Topic.Visible   = false;

                if (suggestedSchoolListView.SelectedItem != null)
                {
                    if (!String.IsNullOrEmpty(suggestedSchoolListView.SelectedItems[0].SubItems[3].Text.Trim()))
                    {
                        MailMessage message = new MailMessage(new MailAddress("*****@*****.**", "Fudge"), new MailAddress(suggestedSchoolListView.SelectedItem.NotifyEmail));
                        message.Subject = "Your school has been added to Fudge!";
                        message.Body    = school.Name + " has been added as a school on Fudge. Thank you for your suggestion. You can now register to Fudge by using any email address ending in " + school.Domain + "\n\nThanks,\nThe Fudge Team";

                        try {
                            new EmailSettingsForm().GetClient().Send(message);
                        }
                        catch (Exception ex) {
                            MessageBox.Show(ex.Message, "Smtp Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    DataContext.SuggestedEntities.DeleteOnSubmit(suggestedSchoolListView.SelectedItem);
                }

                DataContext.SubmitChanges();
                UpdateSchools();
            }
        }