コード例 #1
0
 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;
 }
コード例 #2
0
        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()));
            }
        }
コード例 #3
0
 private static DbSet <Allergen> EntityGetter(AllergyAppDb context)
 {
     return(context.Allergens);
 }
コード例 #4
0
 private static DbSet <Dish> EntityGetter(AllergyAppDb context)
 {
     return(context.Dishes);
 }
コード例 #5
0
 private static DbSet <Ingredient> EntityGetter(AllergyAppDb context)
 {
     return(context.Ingredients);
 }
コード例 #6
0
 private static DbSet <Restaurant> EntityGetter(AllergyAppDb context)
 {
     return(context.Restaurants);
 }