Exemplo n.º 1
0
 public async Task <Pie> GetPieAsync(int id)
 {
     using (var dbContext = new PieshopContext())
     {
         return(await dbContext.Pies.FindAsync(id));
     }
 }
Exemplo n.º 2
0
 public async Task <T> FindItemAsync(int id)
 {
     using (var dbContext = new PieshopContext())
     {
         return(await dbContext.FindAsync <T>(id));
     }
 }
Exemplo n.º 3
0
 public async Task <List <Pie> > GetAllPiesAsync()
 {
     using (var dbContext = new PieshopContext())
     {
         return(await dbContext.Pies.ToListAsync());
     }
 }
Exemplo n.º 4
0
 public async Task <Coffee> GetCoffeeAsync(int id)
 {
     using (var dbContext = new PieshopContext())
     {
         return(await dbContext.Coffees.FindAsync());
     }
 }
Exemplo n.º 5
0
        public async Task AddCoffeeAsync(Coffee coffee)
        {
            using (var dbContext = new PieshopContext())
            {
                if (coffee.ID == 0)
                {
                    await dbContext.Coffees.AddAsync(coffee);
                }
                else
                {
                    dbContext.Coffees.Update(coffee);
                }

                await dbContext.SaveChangesAsync();
            }
        }
Exemplo n.º 6
0
        public async Task AddItem(T product)
        {
            using (var dbContext = new PieshopContext())
            {
                if (product.ID == 0)
                {
                    await dbContext.AddAsync(product);
                }
                else
                {
                    dbContext.Update(product);
                }

                // Don't forget to save changes after operating.
                await dbContext.SaveChangesAsync();
            }
        }
Exemplo n.º 7
0
        public async Task SavePieAsync(Pie pie)
        {
            using (var dbContext = new PieshopContext())
            {
                if (pie.ID == 0)
                {
                    await dbContext.Pies.AddAsync(pie);
                }
                else
                {
                    dbContext.Pies.Update(pie);
                }

                // Don't forget to save changes after operating.
                await dbContext.SaveChangesAsync();
            }
        }