Exemple #1
0
        private void TestData()
        {
            using (DatingAppContext db = new DatingAppContext(AppContext.Instance.ConnectionString))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the local database.
                    db.CreateDatabase();

                    Note n1 = new Note { CreatedDate = DateTime.Now, Content = "This is a note" };
                    Note n2 = new Note { CreatedDate = DateTime.Now, Content = "This is another note and this is extra text to push it onto another line but will it" };

                    db.Notes.InsertOnSubmit(n1);
                    db.Notes.InsertOnSubmit(n2);

                    Venue v1 = new Venue { Name = "Zizzi Chislehurst", Latitude = 51.417493, Longitude = 0.067863, IsFavourite = true };
                    Venue v2 = new Venue { Name = "TGI Friday New York", Latitude = 40.706681, Longitude = -74.013169 };
                    Venue v3 = new Venue { Name = "Bella Italia Leicester Square", Latitude = 51.510687, Longitude = -0.129290 };
                    Venue v4 = new Venue { Name = "Hyde Park", Latitude = 51.507432, Longitude = -0.165708 };
                    Venue v5 = new Venue { Name = "Sea Life Centre Brighton", Latitude = 50.819573, Longitude = -0.135351, IsFavourite = true };

                    db.Venues.InsertOnSubmit(v1);
                    db.Venues.InsertOnSubmit(v2);
                    db.Venues.InsertOnSubmit(v3);
                    db.Venues.InsertOnSubmit(v4);
                    db.Venues.InsertOnSubmit(v5);

                    Interest i1 = new Interest() { Description = "Football", Weighting = 3 };
                    Interest i2 = new Interest() { Description = "Tennis", Weighting = 2 };
                    Interest i3 = new Interest() { Description = "Ping Pong", Weighting = 1 };
                    Interest i4 = new Interest() { Description = "Hockey", Weighting = 1 };
                    Interest i5 = new Interest() { Description = "Squash", Weighting = 3 };
                    Interest i6 = new Interest() { Description = "Judo", Weighting = 2 };

                    db.Interests.InsertOnSubmit(i1);
                    db.Interests.InsertOnSubmit(i2);
                    db.Interests.InsertOnSubmit(i3);
                    db.Interests.InsertOnSubmit(i4);
                    db.Interests.InsertOnSubmit(i5);
                    db.Interests.InsertOnSubmit(i6);

                    Date d1 = new Date { Venue = v1, DateOfMeeting = DateTime.Now.AddMinutes(25), Rating = 2.5, Notes = new EntitySet<Note>() { n1, n2 } };
                    Date d2 = new Date { Venue = v2, DateOfMeeting = DateTime.Now.AddDays(26), Rating = 5, IsFavourite = true };
                    Date d3 = new Date { Venue = v3, DateOfMeeting = DateTime.Now.AddDays(1), Rating = 3, IsFavourite = true };
                    Date d4 = new Date { Venue = v4, DateOfMeeting = DateTime.Now.AddDays(2), Rating = 4, IsFavourite = true };
                    Date d5 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(5), Rating = 1 };
                    Date d6 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(25), Rating = 1 };
                    Date d7 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(14), Rating = 5 };

                    db.Dates.InsertOnSubmit(d1);
                    db.Dates.InsertOnSubmit(d2);
                    db.Dates.InsertOnSubmit(d3);
                    db.Dates.InsertOnSubmit(d4);
                    db.Dates.InsertOnSubmit(d5);
                    db.Dates.InsertOnSubmit(d6);
                    db.Dates.InsertOnSubmit(d7);

                    //Country c1 = new Country() { Name = "United Kingdom" };
                    //db.Countries.InsertOnSubmit(c1);

                    // Prepopulate the categories.
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Alex", SecondName = "Williams", PhoneNumber = "067878768", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet<Date>() { d1, d2, d6, d7 }, Interests = new EntitySet<Interest>() { i1, i2, i3, i4, i5, i6 } });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Rachel", SecondName = "Scott", PhoneNumber = "0345234545", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet<Date>() { d3 } });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Iain", SecondName = "Smith", PhoneNumber = "032234324", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet<Date>() { d4 } });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "John", SecondName = "Benson", PhoneNumber = "03454353", Email = "*****@*****.**", Dates = new EntitySet<Date>() { d5 } });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Peter", SecondName = "Parker", PhoneNumber = "034324324", Email = "*****@*****.**" });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Amit", SecondName = "Dam", PhoneNumber = "0234324", Email = "*****@*****.**" });
                    db.Persons.InsertOnSubmit(new Person { FirstName = "Helen", SecondName = "Johnson", PhoneNumber = "04365435", Email = "*****@*****.**" });

                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Alex", SecondName = "Williams", PhoneNumber = "067878768", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d1, d2, d6, d7 }, Interests = new EntitySet<Interest>() { i1, i2, i3, i4, i5, i6 } });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Rachel", SecondName = "Scott", PhoneNumber = "0345234545", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d3 } });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Iain", SecondName = "Smith", PhoneNumber = "032234324", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d4 } });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "John", SecondName = "Benson", PhoneNumber = "03454353", Email = "*****@*****.**", Country = c1, Dates = new EntitySet<Date>() { d5 } });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Peter", SecondName = "Parker", PhoneNumber = "034324324", Email = "*****@*****.**", Country = c1 });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Amit", SecondName = "Dam", PhoneNumber = "0234324", Email = "*****@*****.**", Country = c1 });
                    //db.Persons.InsertOnSubmit(new Person { FirstName = "Helen", SecondName = "Johnson", PhoneNumber = "04365435", Email = "*****@*****.**", Country = c1 });

                    //db.Countries.InsertOnSubmit(new Country() { Name = "Albania" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Algeria" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Andorra" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Angola" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Argentina" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Armenia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Australia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Austria" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Bangladesh" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Barbados" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Belarus" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Belgium" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Belize" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Bolivia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Bosnia and Herzegovina" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Brazil" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Bulgaria" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Cambodia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Cameroon" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Canada" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Chile" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "China" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Colombia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Costa Rica" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Croatia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Cuba" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Cyprus" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Czech Republic" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Denmark" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Ecuador" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Egypt" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Estonia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Fiji" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Finland" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "France" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Georgia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Germany" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Ghana" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Greece" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Grenada" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Hungary" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Iceland" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "India" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Indonesia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Ireland" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Israel" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Italy" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Jamaica" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Japan" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Jordan" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Kenya" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Korea, South" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Kuwait" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Latvia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Lebanon" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Liberia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Liechtenstein" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Lithuania" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Luxembourg" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Macedonia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Malaysia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Malta" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Mauritius" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Mexico" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Moldova" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Monaco" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Mongolia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Montenegro" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Morocco" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Mozambique" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Myanmar (Burma)" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Netherlands" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "New Zealand" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Nigeria" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Norway" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Oman" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Pakistan" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Panama" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Paraguay" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Peru" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Philippines" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Poland" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Portugal" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Romania" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Russia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Kitts and Nevis" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Lucia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Vincent and the Grenadines" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Samoa" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Senegal" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Serbia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Singapore" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Slovakia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Slovenia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "South Africa" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Spain" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Sri Lanka" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Sudan" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Sweden" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Switzerland" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Thailand" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Togo" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Tonga" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Trinidad and Tobago" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Tunisia" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Turkey" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Uganda" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Ukraine" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "United Arab Emirates" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "United States" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Uruguay" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Venezuela" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Vietnam" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Yemen" });
                    //db.Countries.InsertOnSubmit(new Country() { Name = "Zambia" });

                    // Save categories to the database.
                    db.SubmitChanges();
                }
            }
        }
 partial void DeleteVenue(Venue instance);
 partial void InsertVenue(Venue instance);
 partial void UpdateVenue(Venue instance);
        private void Use_Click(object sender, EventArgs e)
        {
            GooglePlaceSearchResult result = (GooglePlaceSearchResult)((LongListSelector)this.ResultsListSelector).SelectedItem;

            if (result != null)
            {
                Venue venue = new Venue() { Name = result.Name, Latitude = result.Geometry.Location.Latitude, Longitude = result.Geometry.Location.Longitude };

                XmlSerializer ser = new XmlSerializer(typeof(Venue));
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                System.IO.StringWriter writer = new System.IO.StringWriter(sb);
                ser.Serialize(writer, venue);

                StringBuilder destination = new StringBuilder("/Views/Dates/CEDateView.xaml");
                destination.AppendFormat("?Venue={0}", sb);

                NavigationService.Navigate(new Uri(destination.ToString(), UriKind.Relative));
            }
        }