Exemplo n.º 1
0
        public IEnumerable <ChecksViewModel> GetChecks(string filter, string schoolCode)
        {
            try
            {
                db = new CheckDatabase();

                Check[] checks;

                if (filter != string.Empty)
                {
                    checks = db.Checks.Where(c =>
                                             c.Bank.Contains(filter) || c.Deliverer.Contains(filter) ||
                                             c.Number.Contains(filter) || c.PayCode.Contains(filter) ||
                                             c.StudentName.Contains(filter)).ToArray();
                }

                else
                {
                    checks = db.Checks.ToArray();
                }

                if (schoolCode != string.Empty)
                {
                    checks = checks.Where(c => c.SchoolCode == schoolCode).ToArray();
                }


                return(Array.ConvertAll(checks, c => (ChecksViewModel)c));
            }
            catch (Exception ex)
            {
                return(new ChecksViewModel[1]);
            }
        }
Exemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();


            string conexao = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <testeimdbContext>(a => a.UseSqlServer(conexao));

            // Checa se o Banco existe/Cria antes de executar as Migrations
            CheckDatabase.DatabaseExist(conexao);

            // configuração do Identity
            services.AddIdentityConfig(Configuration);

            // Injeção de dependencias
            services.AddDependenciasConfig();

            // Adiciona as instancias de alguns serviços
            services.AddIntanciaServiceConfig();

            //Rodas as Migraçoes do Identity
            InicializaDatabase.ExecutaIdentityMigrations();

            // Roda os Migrations
            MigrationsDataBase.RunMigration(conexao);

            services.AddCors(o => o.AddPolicy("EnableCors", builder => {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            //Swagger
            services.ConfiguraSwagger();

            services.AddMvc();
            services.AddControllers()
            .AddNewtonsoftJson();
        }