Exemple #1
0
 public Pet DeletePet(int id)
 {
     if (_petRepository.DeletePet(id) == null)
     {
         throw new InvalidDataException("No pet with id: " + id + " exist");
     }
     return(_petRepository.DeletePet(id));
 }
 public Pet DeletePet(int id)
 {
     /*if (!IdVerifier(id))
      * {
      *  throw new InvalidDataException($"The Id you entered does NOT exist");
      * }*/
     return(_petRepo.DeletePet(id));
 }
Exemple #3
0
 public Pet Delete(Pet petToDelete)
 {
     if (petToDelete != null)
     {
         return(_petRepository.DeletePet(petToDelete.Id));
     }
     throw new InvalidDataException($"The pet you are trying to delete does not exist!");
 }
Exemple #4
0
 public Pet DeletePet(int id)
 {
     if (id < 1)
     {
         throw new InvalidDataException("ID cannot be lower than 1");
     }
     return(_petRepository.DeletePet(id));
 }
Exemple #5
0
 public bool RemovePet(int id)
 {
     if (!_petRepo.DeletePet(id))
     {
         throw new Exception("The pet hasn't been removed!");
     }
     return(true);
 }
Exemple #6
0
 public ActionResult Delete(Guid id)
 {
     if (id != Guid.Empty)
     {
         _petRepository.DeletePet(id);
         return(RedirectToAction("Index"));
     }
     throw new HttpException(404, "Pet Not Found");
 }
        public Pet DeletePetByID(int theId)
        {
            List <Pet> toBeDeletedPets = _petRepo.FindPetByID(theId);

            if (toBeDeletedPets.Count != 1 || toBeDeletedPets[0] == null)
            {
                throw new InvalidDataException(message: "Could not find that pet Id to delete.");
            }
            return(_petRepo.DeletePet(toBeDeletedPets[0]));
        }
        public void DeletePetById(int id)
        {
            var pet = GetPetById(id);

            if (pet == null)
            {
                throw new ArgumentException("No pet with this id");
            }
            _PetRepo.DeletePet(pet);
        }
Exemple #9
0
        public async Task <ActionResult <PetViewModel> > DeletePet(int id)
        {
            Pet pet = await _petRepository.DeletePet(id);

            if (pet == null)
            {
                return(NotFound());
            }

            return(_mapper.Map <PetViewModel>(pet));
        }
 public void DeletePet(int id)
 {
     try
     {
         _petRepository.DeletePet(id);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #11
0
        public Pet DeletePet(int id)
        {
            servicePetLst = _petRepo.GetAllPets();
            if (id == 0)
            {
                throw new Exception("Invalid ID");
            }
            Pet petForOwnerID = _petRepo.ReadPetById(id);

            return(_petRepo.DeletePet(id));
        }
Exemple #12
0
 public bool DeletePet(int Id)
 {
     if (Id > -1)
     {
         return(_petRepository.DeletePet(Id));
     }
     else
     {
         throw new InvalidDataException("Id must be greater or equal to zero");
     }
 }
Exemple #13
0
        public IActionResult Delete(Pet pet)
        {
            Pet deletedPet = repository.DeletePet(pet);

            if (deletedPet != null)
            {
                TempData["message"] = $"Usunięto {deletedPet.Name}.";
            }

            return(RedirectToAction("Index"));
        }
Exemple #14
0
        public override async Task <ActionResult <Pet> > DeletePet(int id, CancellationToken cancellationToken)
        {
            Core.Pet pet = await _petRepository.DeletePet(id);

            if (pet == null)
            {
                return(NotFound());
            }

            return(_mapper.Map <Pet>(pet));
        }
Exemple #15
0
 public Pet DeletePet(int ID)
 {
     if (ID <= 0)
     {
         throw new ArgumentException("Incorrect ID entered");
     }
     if (GetPetByID(ID) == null)
     {
         throw new ArgumentException("No pet with such ID found");
     }
     return(PetRepository.DeletePet(ID));
 }
        public Pet DeletePet(int id)
        {
            Pet petToDelete;

            if (!_petRepository.GetAllPets().Exists(x => x.PetId == id))
            {
                throw new KeyNotFoundException("A pet with this ID does not exist");
            }

            petToDelete = _petRepository.GetAllPets().Find(x => x.PetId == id);
            return(_petRepository.DeletePet(petToDelete));
        }
Exemple #17
0
 public void DeletePet(int id)
 {
     _log.Info($"DeletePet, id: {id}");
     try
     {
         _repository.DeletePet(id);
     }
     catch (Exception e)
     {
         _log.Error($"Failure to delete pet: {id}", e);
         throw;
     }
 }
Exemple #18
0
        public async Task <ActionResult> DeletePet(Guid petId)
        {
            var petFromRepo = await _petRepository.GetPetAsync(petId);

            if (petFromRepo == null)
            {
                return(NotFound());
            }

            _petRepository.DeletePet(petFromRepo);
            await _petRepository.SaveAsync();

            return(NoContent());
        }
Exemple #19
0
        public Pet DeletePet(int id)
        {
            Pet petToDelete;

            if (!_petRepository.ReadPets().Exists(x => x.ID == id))
            {
                throw new InvalidDataException("A pet with this ID does not exist");
            }
            else
            {
                petToDelete = _petRepository.ReadPets().Find(x => x.ID == id);
                return(_petRepository.DeletePet(petToDelete));
            }
        }
Exemple #20
0
        public ICommandResult handle(CommandDeletePet command)
        {
            command.Validate();

            if (command.Invalid)
            {
                return(new CommandResult("Command Invalid delete a Pet", false, command));
            }

            var pet = _petRepository.GetPetById(command.Id);

            _petRepository.DeletePet(pet);

            return(new CommandResult("Pet Deleted", true, command));
        }
Exemple #21
0
        public Pet DeletePet(int id)
        {
            if (id <= 0)
            {
                throw new InvalidDataException("ID can not be 0 or lower");
            }

            var pet = petRepository.GetPetByID(id);

            if (pet == null)
            {
                throw new ArgumentNullException("Pet Could not be found");
            }
            petRepository.DeletePet(petRepository.GetPetByID(id));
            return(pet);
        }
Exemple #22
0
 public void DeletePet(int id)
 {
     _repository.DeletePet(id);
 }
 public void DeletePet(int id)
 {
     _petRepo.DeletePet(id);
 }
Exemple #24
0
 public bool DeletePet(int id)
 {
     return(_petRepo.DeletePet(id));
 }
Exemple #25
0
 public bool DeletePet(int petId)
 {
     return(petRepository.DeletePet(petId));
 }
 /// <summary>
 /// Delete a pet
 /// </summary>
 /// <param name="Petid"></param>
 /// <returns></returns>
 public Pet DeletePet(int Petid)
 {
     return(_petRepo.DeletePet(Petid));
 }
 public Pet DeletePet(int petId)
 {
     return(_petRepository.DeletePet(petId));
 }
Exemple #28
0
 public void DeletePet(int Id)
 {
     _petRepository.DeletePet(Id);
 }
Exemple #29
0
 public Pet DeletePet(Pet pet)
 {
     return(_petRepo.DeletePet(pet));
 }
Exemple #30
0
        public Pet DeletePet(int id)
        {
            var deletePet = _petRepository.ReadById(id);

            return(_petRepository.DeletePet(deletePet));
        }