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


            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }

            var users = new User[]
            {
                new User {
                    Id = Guid.NewGuid(), FirstName = "Julien", LastName = "Desterbecq"
                },
                new User {
                    Id = Guid.NewGuid(), FirstName = "Arnold", LastName = "Schwarzenegger"
                },
                new User {
                    Id = Guid.NewGuid(), FirstName = "Bruce", LastName = "Willis"
                },
                new User {
                    Id = Guid.NewGuid(), FirstName = "Sylvester", LastName = "Stallone"
                }
            };

            foreach (User s in users)
            {
                context.Users.Add(s);
            }
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public User PostUser(User value)
        {
            using (var uow = _uowProvider.CreateUnitOfWork(false))
            {
                User user = new User()
                {
                    Id        = Guid.NewGuid(),
                    FirstName = value.FirstName,
                    LastName  = value.LastName
                };

                _context.Users.Add(user);
                _context.SaveChanges();
                return(user);
            }
        }