Пример #1
0
        public profilepage()
        {
            InitializeComponent();
            Country.ItemsSource   = GetCountryList();
            Country.SelectedIndex = 134; // set to us
            State.ItemsSource     = StateArray.States();
            StateB.ItemsSource    = StateArray.States();

            for (var a = 1; a <= 12; a++)
            {
                Month.Items.Add(a);
            }

            for (var a = currentYear; a <= currentYear + 10; a++)
            {
                Year.Items.Add(a);
            }

            string path = Utils.GetPath("Profile.json");

            // Checks if a profile exists or not. If not, will create a default profile.
            // Else (does exist) prompts us to read the file in like normal.
            if (CreateDefaultProfile(ref path))
            {
                ReadProfile(ref path);
            }
        }
Пример #2
0
        //In memory data seeding
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //Populate Contact Frequencies
            modelBuilder.Entity <ContactFrequency>().HasData(new ContactFrequency()
            {
                Id = 1, Frequency = "Contact only about account information"
            });
            modelBuilder.Entity <ContactFrequency>().HasData(new ContactFrequency()
            {
                Id = 2, Frequency = "Ok to contact with marketing information"
            });
            modelBuilder.Entity <ContactFrequency>().HasData(new ContactFrequency()
            {
                Id = 3, Frequency = "OK to contact with third-party marketing information"
            });

            //Populate Contact Methods
            modelBuilder.Entity <ContactMethod>().HasData(new ContactMethod()
            {
                Id = 1, Method = "Text"
            });
            modelBuilder.Entity <ContactMethod>().HasData(new ContactMethod()
            {
                Id = 2, Method = "Email"
            });
            modelBuilder.Entity <ContactMethod>().HasData(new ContactMethod()
            {
                Id = 3, Method = "Phone"
            });

            //populate initial contacts
            Random rnd = new Random();

            for (int i = 1; i <= 10; i++)
            {
                modelBuilder.Entity <Contact>().HasData(new Contact()
                {
                    Id               = i,
                    FirstName        = Faker.Name.First(),
                    LastName         = Faker.Name.Last(),
                    Email            = Faker.Internet.Email(),
                    PhoneNumber      = Faker.Phone.Number(),
                    StreetAddress    = Faker.Address.StreetAddress(),
                    City             = Faker.Address.City(),
                    State            = Faker.Address.UsStateAbbr(),
                    Zipcode          = Faker.Address.ZipCode(),
                    ContactFrequency = rnd.Next(1, 4),
                    ContactMethod    = rnd.Next(1, 4)
                });
            }

            //populate states
            var stateArray = StateArray.States();

            for (int i = 0; i < stateArray.Length; i++)
            {
                modelBuilder.Entity <State>().HasData(new State()
                {
                    Id = i + 1, FullName = stateArray[i].Name, Abbreviation = stateArray[i].Abbreviations
                });
            }
        }