public PetType DeletePetType(int id) { /* * PetType petType = _petTypeRepository.GetPetTypes(new Filter()).List.Find(x => x.ColourId == id); * if (petType != null) * { * _petTypeRepository.GetPetTypes(new Filter()).List.Remove(petType); * * //delete all the pets with the deleted petType. * foreach (Pet pet in _petRepository.GetPets(new Filter()).List.Where(pet => pet.PetType.ColourId == petType.ColourId).ToList()) * { * _petRepository.GetPets(new Filter()).List.Remove(pet); * * } * * return petType; * * } * else * { * throw new KeyNotFoundException("Could not find an owner to delete "); * } */ return(_petTypeRepository.DeletePetType(id)); }
public PetType DeletePetType(int id) { if (id < 1) { throw new InvalidDataException("ID cannot be lower than 1"); } return _petTypeRepository.DeletePetType(id); }
public PetType DeletePetType(int id) { if (!_petTypeRepository.ReadPetTypes().Exists(x => x.PetTypeId.Equals(id))) { throw new KeyNotFoundException("pet type could not be deleted"); } return(_petTypeRepository.DeletePetType(id)); }
public PetType DeletePetType(int ID) { if (ID <= 0) { throw new ArgumentException("Incorrect ID entered"); } if (GetPetTypeByID(ID) == null) { throw new ArgumentException("No pet type with such ID found"); } return(PetTypeRepository.DeletePetType(ID)); }
public PetType DeletePetType(int id) { PetType petTypeToDelete; if (!_petTypeRepository.GetAllPetTypes().Exists(x => x.PetTypeId == id)) { throw new KeyNotFoundException("A pet with this ID does not exist"); } else { petTypeToDelete = _petTypeRepository.GetAllPetTypes().Find(x => x.PetTypeId == id); return(_petTypeRepository.DeletePetType(petTypeToDelete)); } }
public PetType DeleteType(int id) { return(_typeRepo.DeletePetType(id)); }
public PetType DeletePetType(int id) { return(_petTypeRepository.DeletePetType(id)); }
public PetType DeletePetType(int id) { PetType petTypeForDeletion = FindPetTypeById(id); return(_petTypeRepo.DeletePetType(petTypeForDeletion)); }
public PetType DeletePetType(int id) { PetType toBeDeleted = FindPetTypeById(id); return(_petTypeRepo.DeletePetType(toBeDeleted)); }