public async Task <ActionResult <PlantType> > PostPlantType(PlantTypeDto plantType) { //Create a new plant type based on the provided plant type DTO PlantType newType = new PlantType(); newType.PType = plantType.info; _context.PlantTypes.Add(newType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPlantType", new { id = newType.PlantTypeID }, newType)); }
public async Task <IActionResult> PutPlantType(int id, PlantTypeDto plantType) { //Update the plant type var result = await _context.PlantTypes.SingleOrDefaultAsync(t => t.PlantTypeID == id); if (result != null) { result.PType = plantType.info; await _context.SaveChangesAsync(); return(Ok()); } return(NotFound()); }