Пример #1
0
        public IHttpActionResult CreateMeal(Meal meal)
        {
            mealService.CreateMeal(meal);
            mealService.SaveMeals();

            return(Content(HttpStatusCode.Accepted, "Meal created"));
        }
Пример #2
0
        public IHttpActionResult PostMeal(Meal m)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            msvc.CreateMeal(m);
            uow.Save();

            return(CreatedAtRoute("DefaultApi", new { id = m.ID }, MealDto.FromMeal(m)));
        }
Пример #3
0
        public async Task <IActionResult> Create([FromBody] MealDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _service.CreateMeal(model);

            return(Ok(result));
        }
 public IActionResult Create(CreateMealModel model)
 {
     if (ModelState.IsValid)
     {
         Meal meal = new Meal()
         {
             DateValid = model.DateForMeal
         };
         Dish start   = _dishService.Dish.First(d => d.Id == model.StarterId);
         Dish main    = _dishService.Dish.First(d => d.Id == model.MainId);
         Dish dessert = _dishService.Dish.First(d => d.Id == model.DessertId);
         var  dishes  = new Dish[] { start, main, dessert };
         _mealService.CreateMeal(meal, dishes);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(model));
 }
Пример #5
0
        public async Task <IActionResult> CreateMeal(MealDto mealDto)
        {
            var result = await _mealService.CreateMeal(mealDto);

            return(Ok(result));
        }