Ejemplo n.º 1
0
 public bool MakeEmailCurrent(Email email)
 {
     foreach (Email e in this.Emails)
     {
         e.IsPrimary = false;
     }
     email.IsPrimary = true;
     return true;
 }
        private void SeedAuthors()
        {
            List<Author> authors = new List<Author>();
            int i;
            for (i = 1; i <= 2; i++)
            {
                Author author = new Author();
                if (i == 1)
                {
                    ContactInfo contact = new ContactInfo();
                    Address address = new Address();
                    List<Address> addresses = new List<Address>();
                    Email email = new Email();
                    List<Email> emails = new List<Email>();
                    author.Name = "John Doe";
                    contact.TwitterCallsign = "@JohnDoe";
                    contact.ContactType = ContactType.Home;
                    {
                        address.City = "Los Angeles";
                        address.IsMailing = true;
                        address.IsPublic = false;
                        address.State = "CA";
                        address.Street1 = "1234 Main Street";
                        address.Street2 = "Apt. 203";
                        address.Zip = "90001";
                        address.IsPrimary = true;
                    }
                    addresses.Add(address);
                    contact.Addresses = addresses;
                    {
                        email.EmailAddress = "*****@*****.**";
                        email.DisplayName = "John Doe at Home";
                        email.IsSubscribed = true;
                        emails.Add(email);
                        contact.Emails = emails;
                    }

                    author.ContacntInfo = contact;
                    authors.Add(author);
                }
                if (i == 2)
                {
                    ContactInfo contact = new ContactInfo();
                    Address address = new Address();
                    List<Address> addresses = new List<Address>();
                    Email email = new Email();
                    List<Email> emails = new List<Email>();
                    author.Name = "Jane Doe";
                    contact.TwitterCallsign = "@JaneDoe";
                    contact.ContactType = ContactType.Home;
                    Phone phone = new Phone();
                    phone.CountryCode = 1;
                    phone.Number = 1234567890;
                    contact.PrimaryPhoneNumber = phone;
                    {
                        address.City = "New York";
                        address.IsMailing = false;
                        address.IsPublic = true;
                        address.State = "NY";
                        address.Street1 = "4678 Park Ave";
                        address.Street2 = "Apt. 304";
                        address.Zip = "10007";
                        address.IsPrimary = true;
                    }
                    addresses.Add(address);
                    contact.Addresses = addresses;
                    {
                        email.EmailAddress = "*****@*****.**";
                        email.DisplayName = "Jane Doe";
                        email.IsSubscribed = false;
                        emails.Add(email);
                        contact.Emails = emails;
                    }

                    author.ContacntInfo = contact;
                    authors.Add(author);
                }
            }
            foreach (Author a in authors)
            {
                authorDB.Insert(a);
            }
            authorDB.SaveChanges();
        }