public async Task <IActionResult> Putvegetables([FromRoute] int id, [FromBody] vegetables vegetables) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vegetables.id) { return(BadRequest()); } _context.Entry(vegetables).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!vegetablesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Postvegetables([FromBody] vegetables vegetables) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.vegetables.Add(vegetables); await _context.SaveChangesAsync(); return(CreatedAtAction("Getvegetables", new { id = vegetables.id }, vegetables)); }