public Animal UpdateAnimal(string shelterId, string animalId, Shelter.shared.Animal animal) { Animal reference = _context.Animals.Find <Animal>(x => x.ShelterId == shelterId && x.Id == animalId).FirstOrDefault(); if (animal.Name != reference.Name) { reference.Name = animal.Name; } if (animal.DateOfBirth != reference.DateOfBirth) { reference.DateOfBirth = animal.DateOfBirth; } if (animal.IsChecked != reference.IsChecked) { reference.IsChecked = animal.IsChecked; } if (animal.KidFriendly != reference.KidFriendly) { reference.KidFriendly = animal.KidFriendly; } _context.Animals.ReplaceOne(x => x.ShelterId == shelterId && x.Id == animalId, reference); return(reference); }
public IActionResult UpdateAnimal(string shelterId, string animalId, [FromBody] Shelter.shared.Animal animal) { animal = _dataAccess.UpdateAnimal(shelterId, animalId, animal); return(Ok(animal)); }