public async Task <IActionResult> PutGardenTask([FromRoute] int id, [FromBody] GardenTask gardenTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gardenTask.Id) { return(BadRequest()); } _context.Entry(gardenTask).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GardenTaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostGardenTask([FromBody] GardenTask gardenTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.GardenTask.Add(gardenTask); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGardenTask", new { id = gardenTask.Id }, gardenTask)); }