Exemple #1
0
            private async Task <HungryPizzaAPIContext> GetDatabaseContext()
            {
                var options = new DbContextOptionsBuilder <HungryPizzaAPIContext>()
                              .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                              .Options;
                var databaseContext = new HungryPizzaAPIContext(options);

                databaseContext.Database.EnsureCreated();
                if (await databaseContext.Pizza.CountAsync() <= 0)
                {
                    databaseContext.Pizza.Add(new Pizza()
                    {
                        Id        = 1,
                        Sabor     = "Sabor teste",
                        Descricao = "Descrição teste"
                    });
                    await databaseContext.SaveChangesAsync();
                }
                return(databaseContext);
            }
            private async Task <HungryPizzaAPIContext> GetDatabaseContext()
            {
                var options = new DbContextOptionsBuilder <HungryPizzaAPIContext>()
                              .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                              .Options;
                var databaseContext = new HungryPizzaAPIContext(options);

                databaseContext.Database.EnsureCreated();
                if (await databaseContext.Pedido.CountAsync() <= 0)
                {
                    for (int i = 1; i <= 10; i++)
                    {
                        databaseContext.Pedido.Add(new Pedido()
                        {
                            Id = i
                        });
                        await databaseContext.SaveChangesAsync();
                    }
                }
                return(databaseContext);
            }
Exemple #3
0
 public PizzasController(HungryPizzaAPIContext context)
 {
     _context = context;
 }
Exemple #4
0
 public ClientesController(HungryPizzaAPIContext context)
 {
     _context = context;
 }
Exemple #5
0
 public EnderecoEntregaController(HungryPizzaAPIContext context)
 {
     _context = context;
 }