Example #1
0
        public async Task <ActionResult <Nutritions> > PostNutritions(Nutritions nutritions)
        {
            _context.Nutritions.Add(nutritions);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNutritions", new { id = nutritions.Id }, nutritions));
        }
Example #2
0
        public async Task <IActionResult> PutNutritions(long id, Nutritions nutritions)
        {
            if (id != nutritions.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }