public async Task Update(int id, EditAnimalDto updateData)
        {
            if (updateData == null)
            {
                throw new ArgumentNullException(nameof(updateData));
            }

            var itemToUpdate = await _repository.GetById(id);

            if (itemToUpdate == null)
            {
                throw new InvalidOperationException($"Animal {id} was not found");
            }

            //var modificationDate = _timeService.GetCurrentTime();
            itemToUpdate.Status = await _statusRepository.GetById(updateData.StatusID);

            if (itemToUpdate.Status == null)
            {
                throw new InvalidOperationException($"Status {updateData.StatusID} was not found");
            }
            _mapper.Map(updateData, itemToUpdate);
            //itemToUpdate.LastModified = modificationDate;
            await _repository.Update(itemToUpdate);
        }
Beispiel #2
0
        public async Task <IActionResult> Put(int id, [FromBody] EditAnimalDto newAnimal)
        {
            await _animalService.Update(id, newAnimal);

            return(NoContent());
        }