protected CrudController(Func <AllergyAppDb, DbSet <T> > entityGetter, Func <int, Expression <Func <T, bool> > > idComparatorFactory, Action <T, T> dataUpdater) { _context = new AllergyAppDb(); _entities = entityGetter(_context); _idComparatorFactory = idComparatorFactory; _dataUpdater = dataUpdater; }
public IHttpActionResult GetRestaurantDishes(int restaurantId) { using (var entities = new AllergyAppDb()) { if (entities.Restaurants.Where(r => r.restaurant_id == restaurantId).Count() == 0) { return(BadRequest("No restaurant matches the provided Id")); } return(Ok(entities.Dishes.Where(d => d.restaurant_id == restaurantId).ToList())); } }
private static DbSet <Allergen> EntityGetter(AllergyAppDb context) { return(context.Allergens); }
private static DbSet <Dish> EntityGetter(AllergyAppDb context) { return(context.Dishes); }
private static DbSet <Ingredient> EntityGetter(AllergyAppDb context) { return(context.Ingredients); }
private static DbSet <Restaurant> EntityGetter(AllergyAppDb context) { return(context.Restaurants); }