public async Task <IHttpActionResult> Get()
 {
     using (var context = new MealsContext())
     {
         return(Ok(await context.Meals.Include(meal => meal.Reviews).ToListAsync()));
     }
 }
        public async Task <IHttpActionResult> Delete(int id)
        {
            using (var context = new MealsContext())
            {
                var review = await context.Reviews.FirstOrDefaultAsync(r => r.Id == id);

                if (review == null)
                {
                    return(NotFound());
                }

                context.Reviews.Remove(review);
                await context.SaveChangesAsync();
            }
            return(Ok());
        }
        public async Task <IHttpActionResult> Post([FromBody] ReviewViewModel review)
        {
            using (var context = new MealsContext())
            {
                var meal = await context.Meals.FirstOrDefaultAsync(b => b.Id == review.MealId);

                if (meal == null)
                {
                    return(NotFound());
                }

                var newReview = context.Reviews.Add(new Review
                {
                    MealId      = meal.Id,
                    Description = review.Description,
                    Rating      = review.Rating
                });

                await context.SaveChangesAsync();

                return(Ok(new ReviewViewModel(newReview)));
            }
        }
 public HomeController()
 {
     _context = new MealsContext();
 }
Example #5
0
 public MealsService()
 {
     Context = new MealsContext();
 }
Example #6
0
 public ShoppingListController(MealsContext context)
 {
     _context = context;
 }
Example #7
0
 public IngredientsController(MealsContext context)
 {
     _context = context;
 }
Example #8
0
 public StoresController(MealsContext context)
 {
     _context = context;
 }
Example #9
0
 public RepositoryBase(MealsContext mealsContext)
 {
     MealsContext = mealsContext;
 }
Example #10
0
 public RepositoryWrapper(MealsContext mealsContext)
 {
     this.mealsContext = mealsContext;
 }
Example #11
0
 public UnitsController(MealsContext context)
 {
     _context = context;
 }
Example #12
0
 public RecipesController(MealsContext context)
 {
     _context = context;
 }
Example #13
0
 public MealRepository(MealsContext mealsContext)
     : base(mealsContext)
 {
 }
Example #14
0
 public IngredientRepository(MealsContext mealsContext)
     : base(mealsContext)
 {
 }