Exemplo n.º 1
0
        public void Initialize(sdsDBcontext context)
        {
            context.Database.EnsureCreated();

            if (context.TodoItems.Any())
            {
                return;
            }

            List <TodoItem> items = new List <TodoItem>
            {
                new TodoItem {
                    IsComplete = true, Name = "I did it!!"
                },
                new TodoItem {
                    IsComplete = false, Name = "Failed...again"
                },
                new TodoItem {
                    IsComplete = false, Name = "<h3>Message from a Black Hat! Ha, ha, ha...<h3>"
                }
            };

            string password = "******";

            byte[] passwordHashChili, passwordSaltChili, passwordHashNadia, passwordSaltNadia;

            authenticationHelper.CreatePasswordHash(password, out passwordHashChili, out passwordSaltChili);
            authenticationHelper.CreatePasswordHash(password, out passwordHashNadia, out passwordSaltNadia);

            List <User> users = new List <User>
            {
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashChili,
                    PasswordSalt = passwordSaltChili,
                    IsAdmin      = false
                },
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashNadia,
                    PasswordSalt = passwordSaltNadia,
                    IsAdmin      = true
                }
            };

            context.TodoItems.AddRange(items);
            context.Users.AddRange(users);
            context.SaveChanges();
        }
Exemplo n.º 2
0
 public void Add(User entity)
 {
     db.Users.Add(entity);
     db.SaveChanges();
 }