コード例 #1
0
        public FilteredList <PetType> GetPetTypes(Filter filter)
        {
            FilteredList <PetType> filteredPetTypes;

            if (!string.IsNullOrEmpty(filter.SearchText) && string.IsNullOrEmpty(filter.SearchField))
            {
                filter.SearchField = "Name";
            }

            if (filter.CurrentPage < 0 || filter.ItemsPrPage < 0)
            {
                throw new InvalidDataException("CurrentPage and ItemsPrPage must be zero or more");
            }

            if ((filter.CurrentPage - 1 * filter.ItemsPrPage) >= _petTypeRepository.GetAllPetTypes().Count)
            {
                throw new InvalidDataException("Index out of bounds, CurrentPage is to high");
            }

            filteredPetTypes = _petTypeRepository.GetAllPetTypesFiltered(filter);

            if (filteredPetTypes.List.Count < 1)
            {
                throw new KeyNotFoundException("Could not find petTypes that satisfy the filter");
            }

            return(filteredPetTypes);
        }
コード例 #2
0
        public PetType DeletePetType(int id)
        {
            PetType petTypeToDelete;

            if (!_petTypeRepository.GetAllPetTypes().Exists(x => x.ID == id))
            {
                throw new KeyNotFoundException("A pet with this ID does not exist");
            }
            else
            {
                petTypeToDelete = _petTypeRepository.GetAllPetTypes().Find(x => x.ID == id);
                return(_petTypeRepository.DeletePetType(petTypeToDelete));
            }
        }
コード例 #3
0
 public List <PetType> GetAllPetTypes()
 {
     return(_petTypeRepository.GetAllPetTypes());
 }
コード例 #4
0
 public List <PetType> ListPetTypes()
 {
     return(_petTypeRepo.GetAllPetTypes());
 }
コード例 #5
0
 public List <PetType> GetALlPetTypes()
 {
     return(_petTypeRepo.GetAllPetTypes().ToList());
 }