예제 #1
0
        public static void SeedDataUnidadeOrganizacional(GestaoDeTarefasDbContext db)
        {
            if (db.UnidadeOrganizacional.Any())
            {
                return;
            }

            db.UnidadeOrganizacional.AddRange(
                new UnidadeOrganizacional
            {
                Nome     = "Escola Superior de Tecnologia e Gestão",
                Contacto = "270230510",
                Email    = "*****@*****.**",
            },
                new UnidadeOrganizacional
            {
                Nome     = "Escola Superior de Saúde",
                Contacto = "270230605",
                Email    = "*****@*****.**",
            },
                new UnidadeOrganizacional
            {
                Nome     = "Escola Superior de Turismo e Hotelaria",
                Contacto = "270230705",
                Email    = "*****@*****.**",
            },
                new UnidadeOrganizacional
            {
                Nome     = "Escola Superior de Educação",
                Contacto = "270230807",
                Email    = "EscolaEducaç[email protected]",
            });
            db.SaveChanges();
        }
예제 #2
0
        private static Cargo GetCargoCreatingIfNeed(GestaoDeTarefasDbContext db, string nome)
        {
            Cargo cargo = db.Cargo.SingleOrDefault(e => e.Nome == nome);

            if (cargo == null)
            {
                cargo = new Cargo {
                    Nome = nome
                };
                db.Add(cargo);
                db.SaveChanges();
            }

            return(cargo);
        }
예제 #3
0
        private static void SeedDataCargo(GestaoDeTarefasDbContext db)
        {
            if (db.Cargo.Any())
            {
                return;
            }


            db.Cargo.AddRange(
                new Cargo {
                Nome = "Presidente",
            },
                new Cargo {
                Nome = "Vice Presidente",
            },
                new Cargo {
                Nome = "Director ESTG",
            },
                new Cargo {
                Nome = "Director ESS",
            },
                new Cargo {
                Nome = "Director ESECD",
            },
                new Cargo {
                Nome = "Director ESTH",
            },
                new Cargo {
                Nome = "Chefe de Funcionarios ESTG",
            },
                new Cargo {
                Nome = "Chefe de Funcionarios ESECD",
            },
                new Cargo {
                Nome = "Chefe de Funcionarios ESS",
            },
                new Cargo {
                Nome = "Chefe de Funcionarios ESTH",
            },
                new Cargo {
                Nome = "Chefe de Funcionarios Ação Social",
            }
                );
            db.SaveChanges();
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            GestaoDeTarefasDbContext 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.UseStaticFiles();

            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();

            if (env.IsDevelopment())
            {
                SeedData.Populate(db);
                // SeedData.PopulateUserAsync(userManager).Wait();
            }
        }
예제 #5
0
        private static void SeedDataFuncionarios(GestaoDeTarefasDbContext db)
        {
            if (db.Funcionario.Any())
            {
                return;
            }

            Cargo Empregados = GetCargoCreatingIfNeed(db, "Responsavel pela limpeza");

            Cargo Seguranca = GetCargoCreatingIfNeed(db, "Segurança");

            db.Funcionario.AddRange(
                new Funcionario
            {
                Nome            = "Fernando Fernandes",
                Endereco        = " Resi Masculina 1 Rua Soeirov Viegas Nº6",
                CodigoPostal    = "6300-758 GUARDA",
                Data_Nascimento = new DateTime(1990, 4, 19),
                Contacto        = "912377773",
                Email           = "*****@*****.**",
                CargoId         = Seguranca.CargoId
            },
                new Funcionario
            {
                Nome            = "Tiago Mota",
                Endereco        = "AV DA IGREJA  PORTO MOS SAO JOAO BAPTISTA PEDRO, LOTE R1 22 R/C ESQ.",
                CodigoPostal    = ", 2480-301 LEIRIA",
                Data_Nascimento = new DateTime(1980, 4, 19),
                Contacto        = "916378987",
                Email           = "*****@*****.**",
                CargoId         = Seguranca.CargoId
            },
                new Funcionario
            {
                Nome            = "Sérgio Cardoso",
                Endereco        = " R ELIAS GARCIA 228 SALA 7,  ARCOZELO BARCELOS",
                CodigoPostal    = ",4750-144 BRAGA",
                Data_Nascimento = new DateTime(1989, 12, 19),
                Contacto        = "915678563",
                Email           = "*****@*****.**",
                CargoId         = Seguranca.CargoId
            },
                new Funcionario
            {
                Nome            = "Rony Dias",
                Endereco        = "Travessa do Açougue a São Vicente  nº 45",
                CodigoPostal    = "1100 - 005 LISBOA",
                Data_Nascimento = new DateTime(1979, 2, 23),
                Contacto        = "967378563",
                Email           = "*****@*****.**",
                CargoId         = Empregados.CargoId
            },
                new Funcionario
            {
                Nome            = "Francisco Sá ",
                Endereco        = " Resi Masculina 1 Rua Soeirov Viegas Nº6",
                CodigoPostal    = "6300-758 Guarda",
                Data_Nascimento = new DateTime(1975, 1, 29),
                Contacto        = "937378563",
                Email           = "*****@*****.**",
                CargoId         = Empregados.CargoId
            },
                new Funcionario
            {
                Nome            = "Bárbara Carneiro",
                Endereco        = " Resi Masculina 1 Rua Soeirov Viegas Nº6",
                CodigoPostal    = "6300-758 Guarda",
                Data_Nascimento = new DateTime(1983, 3, 12),
                Contacto        = "912378563",
                Email           = "*****@*****.**",
                CargoId         = Empregados.CargoId
            },
                new Funcionario
            {
                Nome            = "Gustavo Carneiro",
                Endereco        = " Resi Masculina 1 Rua Soeirov Viegas Nº6",
                CodigoPostal    = "6300-758 Guarda",
                Data_Nascimento = new DateTime(1969, 07, 18),
                Contacto        = "918878563",
                Email           = "*****@*****.**",
                CargoId         = Seguranca.CargoId
            },
                new Funcionario
            {
                Nome            = "João Carneiro",
                Endereco        = "Rua Francisco Sá Carneiro Nº6",
                CodigoPostal    = "6300-225 Guarda",
                Data_Nascimento = new DateTime(1980, 8, 19),
                Contacto        = "91098563",
                Email           = "*****@*****.**",
                CargoId         = Seguranca.CargoId
            },
                new Funcionario
            {
                Nome            = "Bárbara Sousa",
                Endereco        = " Rua da Boa Vista Nº76",
                CodigoPostal    = "3000-105 Coimbra",
                Data_Nascimento = new DateTime(1992, 10, 30),
                Contacto        = "967878563",
                Email           = "*****@*****.**",
                CargoId         = Empregados.CargoId
            }
                );

            db.SaveChanges();
        }
예제 #6
0
 public static void Populate(GestaoDeTarefasDbContext db)
 {
     SeedDataFuncionarios(db);
     SeedDataCargo(db);
     SeedDataUnidadeOrganizacional(db);
 }
예제 #7
0
 public UnidadeOrganizacionalsController(GestaoDeTarefasDbContext context)
 {
     _context = context;
 }
 public CargosController(GestaoDeTarefasDbContext context)
 {
     _context = context;
 }
예제 #9
0
 public ServicoesController(GestaoDeTarefasDbContext context)
 {
     _context = context;
 }
 public FuncionariosController(GestaoDeTarefasDbContext context)
 {
     _context = context;
 }