Beispiel #1
0
        public async Task <IActionResult> PutMenuItem_Ingredient([FromRoute] int id, [FromBody] MenuItem_Ingredient menuItem_Ingredient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != menuItem_Ingredient.Id)
            {
                return(BadRequest());
            }

            _context.Entry(menuItem_Ingredient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MenuItem_IngredientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PostMenuItem_Ingredient([FromBody] MenuItem_Ingredient menuItem_Ingredient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MenuItems_Ingredients.Add(menuItem_Ingredient);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMenuItem_Ingredient", new { id = menuItem_Ingredient.Id }, menuItem_Ingredient));
        }