예제 #1
0
        public void GivenTheFollowingUserAccountExists(Table table)
        {
            var dictionary    = table.ToDictionary();
            var username      = dictionary["Name"];
            var email         = dictionary["Email"];
            var password      = dictionary["Password"];
            var productOwner  = dictionary["ProductOwner"].ToBoolean();
            var scrumMaster   = dictionary["ScrumMaster"].ToBoolean();
            var developer     = dictionary["Developer"].ToBoolean();
            var passwordHash  = new PasswordHasher().HashPassword(password);
            var securityStamp = Guid.NewGuid().ToString();
            var user          = new ApplicationUser
            {
                UserName      = username,
                Email         = email,
                PasswordHash  = passwordHash,
                product_owner = productOwner,
                scrum_master  = scrumMaster,
                developer     = developer,
                SecurityStamp = securityStamp
            };

            context.Users.Add(user);
            context.SaveChanges();
        }
예제 #2
0
        static void Main(string[] args)
        {
            using (var context = new FunctionalDbContext("name=default"))
            {
                Console.WriteLine(context.Database.Connection.ConnectionString);
                var recordCount = context.MyModels.Count();

                // Create a record if none currently exist
                if (recordCount == 0)
                {
                    context.MyModels.Add(new MyModel
                    {
                        Id   = 1,
                        Name = "A Model"
                    });
                    context.SaveChanges();
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }