Exemple #1
0
        private static void SeedUser(CDLContext context)
        {
            context.User.AddOrUpdate(u => u.Email,
                                     new User()
            {
                Username = "******", FirstName = "Donovan", LastName = "May", Email = "*****@*****.**"
            },
                                     new User()
            {
                Username = "******", FirstName = "Freddie", LastName = "Mack", Email = "*****@*****.**"
            },
                                     new User()
            {
                Username = "******", FirstName = "Darth", LastName = "Vader", Email = "*****@*****.**"
            },
                                     new User()
            {
                Username = "******", FirstName = "Loke", LastName = "Groundrunner", Email = "*****@*****.**"
            },
                                     new User()
            {
                Username = "******", FirstName = "Grumpy", LastName = "Pants", Email = "*****@*****.**"
            },
                                     new User()
            {
                Username = "******", FirstName = "Captain", LastName = "Crunch", Email = "*****@*****.**"
            });

            context.SaveChanges();
        }
Exemple #2
0
        private static void SeedUserAddress(CDLContext context)
        {
            context.UserAddress.AddOrUpdate(a => new { a.Address1 },
                                            new UserAddress()
            {
                Address1 = "1234 Dearborn Pkwy", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 1
            },
                                            new UserAddress()
            {
                Address1 = "5678 Transit St", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 2
            },
                                            new UserAddress()
            {
                Address1 = "8912 Stone Rd", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 3
            },
                                            new UserAddress()
            {
                Address1 = "12 Black St", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 4
            },
                                            new UserAddress()
            {
                Address1 = "8932 Fisk Rd", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 5
            },
                                            new UserAddress()
            {
                Address1 = "4023 Carriage Lane", Address2 = "Address Line 2", City = "Houston", PostalCode = "12345", StateId = 43, UserId = 6
            }
                                            );

            context.SaveChanges();
        }
Exemple #3
0
        private static void SeedUserRoles(CDLContext context)
        {
            context.UserRole.AddOrUpdate(ur => ur.UserId,
                                         new UserRole()
            {
                UserId = 1, RoleId = 1
            },
                                         new UserRole()
            {
                UserId = 2, RoleId = 2
            },
                                         new UserRole()
            {
                UserId = 3, RoleId = 3
            },
                                         new UserRole()
            {
                UserId = 4, RoleId = 1
            },
                                         new UserRole()
            {
                UserId = 5, RoleId = 2
            },
                                         new UserRole()
            {
                UserId = 6, RoleId = 3
            }
                                         );

            context.SaveChanges();
        }
Exemple #4
0
        private static void SeedMembership(CDLContext context)
        {
            try
            {
                context.Memberships.AddOrUpdate(m => m.UserId,    //userID is PK
                                                new Membership()
                {
                    UserId = 1, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                },
                                                new Membership()
                {
                    UserId = 2, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                },
                                                new Membership()
                {
                    UserId = 3, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                },
                                                new Membership()
                {
                    UserId = 4, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                },
                                                new Membership()
                {
                    UserId = 5, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                },
                                                new Membership()
                {
                    UserId = 6, CreateDate = DateTime.UtcNow, IsConfirmed = true, PasswordFailuresSinceLastSuccess = 0, Password = "******", PasswordSalt = ""
                }
                                                );

                context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    ////  Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                    //     eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
Exemple #5
0
        private static void SeedRoles(CDLContext context)
        {
            context.Roles.AddOrUpdate(r => r.Name,
                                      new Role()
            {
                Name = Role.ADMINISTRATOR
            },
                                      new Role()
            {
                Name = Role.STAFF
            },
                                      new Role()
            {
                Name = Role.USER
            }
                                      );

            context.SaveChanges();
        }
Exemple #6
0
        private static void SeedState(CDLContext context)
        {
            context.State.AddOrUpdate(s => s.PostalCode,
                                      new State()
            {
                Name = "Alabama", PostalCode = "AL", CountryId = 1
            },
                                      new State()
            {
                Name = "Alaska", PostalCode = "AK", CountryId = 1
            },
                                      new State()
            {
                Name = "Arizona", PostalCode = "AZ", CountryId = 1
            },
                                      new State()
            {
                Name = "Arkansas", PostalCode = "AR", CountryId = 1
            },
                                      new State()
            {
                Name = "California", PostalCode = "CA", CountryId = 1
            },                                                                        //5
                                      new State()
            {
                Name = "Colorado", PostalCode = "CO", CountryId = 1
            },
                                      new State()
            {
                Name = "Connecticut", PostalCode = "CT", CountryId = 1
            },
                                      new State()
            {
                Name = "Deleware", PostalCode = "DE", CountryId = 1
            },
                                      new State()
            {
                Name = "Florida", PostalCode = "FL", CountryId = 1
            },
                                      new State()
            {
                Name = "Georgia", PostalCode = "GA", CountryId = 1
            },                                                                     //10
                                      new State()
            {
                Name = "Hawaii", PostalCode = "HI", CountryId = 1
            },
                                      new State()
            {
                Name = "Idaho", PostalCode = "ID", CountryId = 1
            },
                                      new State()
            {
                Name = "Illinois", PostalCode = "IL", CountryId = 1
            },
                                      new State()
            {
                Name = "Indiana", PostalCode = "IN", CountryId = 1
            },
                                      new State()
            {
                Name = "Iowa", PostalCode = "IA", CountryId = 1
            },
                                      new State()
            {
                Name = "Kansas", PostalCode = "KS", CountryId = 1
            },                                                                    //16
                                      new State()
            {
                Name = "Kentucky", PostalCode = "KY", CountryId = 1
            },
                                      new State()
            {
                Name = "Lousiana", PostalCode = "LA", CountryId = 1
            },
                                      new State()
            {
                Name = "Maine", PostalCode = "ME", CountryId = 1
            },
                                      new State()
            {
                Name = "Maryland", PostalCode = "MD", CountryId = 1
            },                                                                      //20
                                      new State()
            {
                Name = "Massachucetts", PostalCode = "MA", CountryId = 1
            },
                                      new State()
            {
                Name = "Michigan", PostalCode = "MI", CountryId = 1
            },
                                      new State()
            {
                Name = "Minnesota", PostalCode = "MN", CountryId = 1
            },
                                      new State()
            {
                Name = "Mississippi", PostalCode = "MS", CountryId = 1
            },
                                      new State()
            {
                Name = "Missouri", PostalCode = "MO", CountryId = 1
            },                                                                     //25
                                      new State()
            {
                Name = "Montana", PostalCode = "MT", CountryId = 1
            },
                                      new State()
            {
                Name = "Nebraska", PostalCode = "NE", CountryId = 1
            },
                                      new State()
            {
                Name = "Nevada", PostalCode = "NV", CountryId = 1
            },
                                      new State()
            {
                Name = "New Hampshire", PostalCode = "NH", CountryId = 1
            },
                                      new State()
            {
                Name = "New Jersey", PostalCode = "NJ", CountryId = 1
            },                                                                       //30
                                      new State()
            {
                Name = "New Mexico", PostalCode = "NM", CountryId = 1
            },
                                      new State()
            {
                Name = "New York", PostalCode = "NY", CountryId = 1
            },
                                      new State()
            {
                Name = "North Carolina", PostalCode = "NC", CountryId = 1
            },
                                      new State()
            {
                Name = "North Dakota", PostalCode = "ND", CountryId = 1
            },
                                      new State()
            {
                Name = "Ohio", PostalCode = "OH", CountryId = 1
            },                                                                  //35
                                      new State()
            {
                Name = "Oklahoma", PostalCode = "OK", CountryId = 1
            },
                                      new State()
            {
                Name = "Oregon", PostalCode = "OR", CountryId = 1
            },
                                      new State()
            {
                Name = "Pennsylvania", PostalCode = "PA", CountryId = 1
            },
                                      new State()
            {
                Name = "Rhode Island", PostalCode = "RI", CountryId = 1
            },
                                      new State()
            {
                Name = "South Carolina", PostalCode = "SC", CountryId = 1
            },                                                                            //40
                                      new State()
            {
                Name = "South Dakota", PostalCode = "SD", CountryId = 1
            },
                                      new State()
            {
                Name = "Tennessee", PostalCode = "TN", CountryId = 1
            },
                                      new State()
            {
                Name = "Texas", PostalCode = "TX", CountryId = 1
            },
                                      new State()
            {
                Name = "Utah", PostalCode = "UT", CountryId = 1
            },
                                      new State()
            {
                Name = "Vermont", PostalCode = "VT", CountryId = 1
            },                                                                     //45
                                      new State()
            {
                Name = "Virginia", PostalCode = "VA", CountryId = 1
            },
                                      new State()
            {
                Name = "Washington", PostalCode = "WA", CountryId = 1
            },
                                      new State()
            {
                Name = "West Virgina", PostalCode = "WV", CountryId = 1
            },
                                      new State()
            {
                Name = "Wisconsin", PostalCode = "WI", CountryId = 1
            },
                                      new State()
            {
                Name = "Wyoming", PostalCode = "WY", CountryId = 1
            }                                                                     //50
                                      );

            context.SaveChanges();
        }