예제 #1
0
 public void SetUp()
 {
     contexto = new TarefasDbContext(new DbContextOptionsBuilder()
                                     .UseNpgsql(parametrosConexão)
                                     .Options);
     contexto.Database.ExecuteSqlRaw("TRUNCATE TABLE public.tarefas");
 }
예제 #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app, IWebHostEnvironment env,
            TarefasDbContext db,
            UserManager <IdentityUser> userManager,
            RoleManager <IdentityRole> roleManager
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            SeedData.CreateRolesAsync(roleManager).Wait();

            //SeedData.Populate(db);

            if (env.IsDevelopment())
            {
                SeedData.Populate(db);
                SeedData.PopulateUsersAsync(userManager).Wait();
            }
            else
            {
                // Make sure that there is an  account
                // ...
            }
        }
예제 #3
0
        private static void PopulateProfessor(TarefasDbContext db)
        {
            if (db.Professor.Any())
            {
                return;
            }

            db.Professor.AddRange(
                new Professor {
                Nome = "Anabela Tavares", Telemovel = "963004726", Email = "*****@*****.**", Gabinete = "22", Disciplina = "Contabilidade", Escola = "ESTG"
            },
                new Professor {
                Nome = "Carina Sofia", Telemovel = "914009710", Email = "*****@*****.**", Gabinete = "48", Disciplina = "Desporto", Escola = "ESECD"
            },
                new Professor {
                Nome = "Pedro Carvalho", Telemovel = "932586941", Email = "*****@*****.**", Gabinete = "30", Disciplina = "Programação", Escola = "ESTG"
            },
                new Professor {
                Nome = "Luis Alexandre", Telemovel = "938523698", Email = "*****@*****.**", Gabinete = "2", Disciplina = "turismo", Escola = "ESTH"
            }
                );
            db.SaveChanges();
        }
예제 #4
0
        private static void PopulateFuncionario(TarefasDbContext db)
        {
            if (db.Funcionario.Any())
            {
                return;
            }

            db.Funcionario.AddRange(
                new Funcionario {
                Nome = "Carlos Lopes", Morada = "Avenida de Liberdade", Numero = "1012180", Escola = "ESTG", Email = "*****@*****.**", Telemovel = "914009888", NIF = "250114585"
            },
                new Funcionario {
                Nome = "Barbara Teixeira", Morada = "Rua Espirito Santo", Numero = "1012164", Escola = "ESTG", Email = "*****@*****.**", Telemovel = "914009785", NIF = "250114580"
            },
                new Funcionario {
                Nome = "Carolina Pinto", Morada = "Avenida Alterto Torres", Numero = "1002006", Escola = "ESTG", Email = "*****@*****.**", Telemovel = "914009756", NIF = "500114525"
            },
                new Funcionario {
                Nome = "Cátia Esteves", Morada = "Travessa Castro", Numero = "1023566", Escola = "ESTG", Email = "*****@*****.**", Telemovel = "914009785", NIF = "250114852"
            }
                );

            db.SaveChanges();
        }
예제 #5
0
 public TarefasController(TarefasDbContext context)
 {
     _context = context;
 }
예제 #6
0
 public static void Populate(TarefasDbContext db)
 {
     PopulateProfessor(db);
     PopulateFuncionario(db);
 }
예제 #7
0
 public static void Populate(TarefasDbContext db)
 {
     // ...
 }
 public ProfessorsController(TarefasDbContext context)
 {
     _context = context;
 }
예제 #9
0
 public EFGestaoTarefas_CPRepository(TarefasDbContext db)
 {
     this.db = db;
 }
 public FuncionariosController(TarefasDbContext context)
 {
     _context = context;
 }