public async Task <IActionResult> PutPlantModel(long id, PlantModel plantModel) { if (id != plantModel.Id) { return(BadRequest()); } if (!await _plantService.EditPlantAsync(plantModel)) { if (!_plantService.PlantExists(id)) { return(NotFound()); } } return(NoContent()); }
public void EditPlant(long existingId, string newFriendlyName, string newSciName) { bool result = _service.EditPlantAsync(new PlantModel() { Id = existingId, FriendlyName = newFriendlyName, ScientificName = newSciName }).Result; Assert.IsTrue(result); PlantModel editedPlant = _service.GetPlant(existingId); Console.WriteLine($"editedPlant: {editedPlant.Id}, {editedPlant.FriendlyName}, {editedPlant.ScientificName} "); Assert.IsTrue(editedPlant.Id == existingId); Assert.IsTrue(editedPlant.FriendlyName.Equals(newFriendlyName)); Assert.IsTrue(editedPlant.ScientificName.Equals(newSciName)); }