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

            if (!context.MedicoTable.Any())
            {
                var medicos = new MedicoModel[]
                {
                    new MedicoModel {
                        Nome = "Neymar Junior", CRM = "123456", Especialidade = "Clinico"
                    },
                    new MedicoModel {
                        Nome = "Gabriel Jesus", CRM = "654321", Especialidade = "Otorrino"
                    },
                    new MedicoModel {
                        Nome = "Tiago Silva", CRM = "321654", Especialidade = "Clinico"
                    },
                    new MedicoModel {
                        Nome = "Daniel Alves", CRM = "321456", Especialidade = "Gastro"
                    },
                    new MedicoModel {
                        Nome = "Ronaldo Fenomeno", CRM = "456321", Especialidade = "Clinico"
                    }
                };
                context.MedicoTable.AddRange(medicos);
                context.SaveChanges();
            }

            if (!context.UsuarioTable.Any())
            {
                var usuarios = new UsuarioModel[]
                {
                    new UsuarioModel {
                        Nome = "Administrador", Login = "******"
                    },
                    new UsuarioModel {
                        Nome = "Usuario Padrao", Login = "******"
                    },
                };
                context.UsuarioTable.AddRange(usuarios);
                context.SaveChanges();
            }

            if (!context.PacienteTable.Any())
            {
                var pacientes = new PacienteModel[]
                {
                    new PacienteModel {
                        Nome = "Paciente 1", Cpf = "11111111111"
                    },
                    new PacienteModel {
                        Nome = "Paciente 2", Cpf = "22222222222"
                    },
                };
                context.PacienteTable.AddRange(pacientes);
                context.SaveChanges();
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DoutorAgendaContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

            app.UseMvc();
            DbInitializer.Initialize(context);
        }
 public MedicoController(DoutorAgendaContext context)
 {
     _context = context;
 }
Exemplo n.º 4
0
 public AgendamentoController(DoutorAgendaContext context)
 {
     _context = context;
 }