Ejemplo n.º 1
0
        public async Task <IActionResult> PutFrigFood(int id, FrigFood frigFood)
        {
            if (id != frigFood.FrigFoodId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <FrigFood> > PostFrigFood(FrigFood frigFood)
        {
            _context.FrigFoods.Add(frigFood);
            await _context.SaveChangesAsync();

            //return CreatedAtAction("GetFrigFood", new { id = frigFood.FrigFoodId }, frigFood);
            return(CreatedAtAction(nameof(GetFrigFood), new { id = frigFood.FrigFoodId }, frigFood));
        }