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(); }
public MealsService() { Context = new MealsContext(); }
public ShoppingListController(MealsContext context) { _context = context; }
public IngredientsController(MealsContext context) { _context = context; }
public StoresController(MealsContext context) { _context = context; }
public RepositoryBase(MealsContext mealsContext) { MealsContext = mealsContext; }
public RepositoryWrapper(MealsContext mealsContext) { this.mealsContext = mealsContext; }
public UnitsController(MealsContext context) { _context = context; }
public RecipesController(MealsContext context) { _context = context; }
public MealRepository(MealsContext mealsContext) : base(mealsContext) { }
public IngredientRepository(MealsContext mealsContext) : base(mealsContext) { }