Beispiel #1
0
        public PetType DeletePetType(int id)
        {
            if (id <= 0)
            {
                throw new InvalidDataException("id must be above 0");
            }
            var pettype = petTypeRepo.GetPetTypeById(id);

            if (pettype == null)
            {
                throw new ArgumentNullException("PetType is null");
            }
            petTypeRepo.DeletePetType(pettype);
            return(pettype);
        }
Beispiel #2
0
        public Pet AddNewPet(Pet TheNewPet)
        {
            if (TheNewPet.Name.Length <= 2)
            {
                throw new InvalidDataException("Name must be longer than 2 letters");
            }
            var pettypeFromDb = petTypeRepo.GetPetTypeById(TheNewPet.Type.id);

            TheNewPet.Type = pettypeFromDb;


            return(petRepository.CreatePet(TheNewPet));
        }