Exemplo n.º 1
0
        private static void CreateDatas(OnionArchitectureContext context)
        {
            if (context.Students.Any())
            {
                return;
            }

            var students = new Student[]
            {
                Student.Create("Ricardo", "11111111111", DateTime.Parse("03/07/1987")),
                Student.Create("Ana Paula", "22222222222", DateTime.Parse("25/03/1979")),
                Student.Create("Yago Andrade", "33333333333", DateTime.Parse("27/07/2008"))
            };

            context.AddRange(students);
            var address = new Address[]
            {
                Address.Create("Enótria", "133", "Casa 13", "Vila Mazzei", "02309100",
                               "São Paulo", "SP", "BR", students[0].Id),
                Address.Create("Enótria", "133", "Casa 13", "Vila Mazzei", "02309100",
                               "São Paulo", "SP", "BR", students[1].Id),
                Address.Create("Enótria", "133", "Casa 13", "Vila Mazzei", "02309100",
                               "São Paulo", "SP", "BR", students[2].Id)
            };

            context.AddRange(address);
            context.SaveChanges();
        }
Exemplo n.º 2
0
        private static void CreateRoles(OnionArchitectureContext context, RoleManager <IdentityRole> roleManager)
        {
            var roles = new IdentityRole[] {
                new IdentityRole("Admin"),
                new IdentityRole("Teacher"),
                new IdentityRole("Student")
            };

            if (!context.Roles.Any())
            {
                foreach (var item in roles)
                {
                    roleManager.CreateAsync(item).GetAwaiter().GetResult();
                }
            }
        }
Exemplo n.º 3
0
 public UnitOfWork(OnionArchitectureContext context)
 {
     _context = context;
 }
 protected void ContextInjection(OnionArchitectureContext context)
 {
     Context  = context;
     Entities = Context.Set <T>();
 }
 public StudentRepository(OnionArchitectureContext context)
 {
     ContextInjection(context);
 }
Exemplo n.º 6
0
 public ProductRepository(OnionArchitectureContext context)
 {
     _dbContext = context;
 }