Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, Data.InfoWinDevDataContext ctx)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                Data.DbInitializer.Init(ctx);
            }

            app.UseStaticFiles();
            app.UseNodeModules(env.ContentRootPath);

            app.UseAuthentication();
            app.UseMvcWithDefaultRoute();

            app.Run(async(context) =>
            {
                context.Response.StatusCode = 404;
                await context.Response.WriteAsync("Recurso não encontrado.");
            });
        }
Example #2
0
        public static void Init(InfoWinDevDataContext ctx)
        {
            ctx.Database.EnsureCreated();

            if (!ctx.Produtos.Any())
            {
                var alimentacao = new TipoProduto()
                {
                    Nome = "Alimentação"
                };
                var higiene = new TipoProduto()
                {
                    Nome = "Higiene"
                };
                var vestuario = new TipoProduto()
                {
                    Nome = "Vestuário"
                };

                var produtos = new List <Produto>()
                {
                    new Produto()
                    {
                        Nome = "Picanha", Tipo = alimentacao, Valor = 80.99M
                    },
                    new Produto()
                    {
                        Nome = "Fralda", Tipo = higiene, Valor = 50.99M
                    },
                    new Produto()
                    {
                        Nome = "Pasta de Dente", Tipo = higiene, Valor = 10.50M
                    },
                    new Produto()
                    {
                        Nome = "Iogurte", Tipo = alimentacao, Valor = 9.99M
                    },
                    new Produto()
                    {
                        Nome = "Camisa Polo", Tipo = vestuario, Valor = 100.99M
                    },
                };

                ctx.Produtos.AddRange(produtos);
                ctx.SaveChanges();
            }

            if (!ctx.Usuarios.Any())
            {
                ctx.Usuarios.AddRange(new List <Usuario>
                {
                    new Usuario {
                        Nome = "Gabriel Rodrigues", Email = "*****@*****.**", Senha = "123456".Encrypt()
                    },
                    new Usuario {
                        Nome = "Maria Graça", Email = "*****@*****.**", Senha = "789012".Encrypt()
                    }
                });
                ctx.SaveChanges();
            }
        }