Exemplo n.º 1
0
        public void DeleteMeal()
        {
            Meal toDelete = ctx.MealSet.FirstOrDefault(p => p.Title == "Meal1");

            repo.Delete(toDelete);
            repo.Save();

            Assert.IsNull(ctx.MealSet.FirstOrDefault(p => p.Title == "Meal1"));
            Assert.IsNotNull(ctx.MealCategorySet.FirstOrDefault(p => p.Label == "meal category 1"));
        }
Exemplo n.º 2
0
        public ActionResult <Meal> Delete(int id)
        {
            try
            {
                Meal meal = mealRepository.Delete(id);
                if (meal == null)
                {
                    logger.Info("Meal is not found: " + id + ".");
                    return(NotFound());
                }

                return(NoContent());
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(BadRequest(ex));
            }
        }
Exemplo n.º 3
0
 public void Delete([FromBody] Meal meal)
 {
     mealRepository.Delete(meal);
 }