コード例 #1
0
        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());
        }
コード例 #2
0
        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));
        }