コード例 #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"));
        }
コード例 #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));
            }
        }
コード例 #3
0
 public void Delete([FromBody] Meal meal)
 {
     mealRepository.Delete(meal);
 }