public async Task <Pie> GetPieAsync(int id) { using (var dbContext = new PieshopContext()) { return(await dbContext.Pies.FindAsync(id)); } }
public async Task <T> FindItemAsync(int id) { using (var dbContext = new PieshopContext()) { return(await dbContext.FindAsync <T>(id)); } }
public async Task <List <Pie> > GetAllPiesAsync() { using (var dbContext = new PieshopContext()) { return(await dbContext.Pies.ToListAsync()); } }
public async Task <Coffee> GetCoffeeAsync(int id) { using (var dbContext = new PieshopContext()) { return(await dbContext.Coffees.FindAsync()); } }
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(); } }
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(); } }
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(); } }