public async Task <ActionResult <Edible> > PostEdible(EdibleDto edible) { //Create a new edible value based on the DTO provided Edible newEdible = new Edible(); newEdible.EdibleS = edible.info; _context.Edibles.Add(newEdible); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEdible", new { id = newEdible.EdibleID }, newEdible)); }
public async Task <IActionResult> PutEdible(int id, EdibleDto edible) { //Update an edible value, at the Id with the information provided var result = await _context.Edibles.SingleOrDefaultAsync(e => e.EdibleID == id); if (result != null) { result.EdibleS = edible.info; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }