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); }
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)); } }
public List <PetType> GetAllPetTypes() { return(_petTypeRepository.GetAllPetTypes()); }
public List <PetType> ListPetTypes() { return(_petTypeRepo.GetAllPetTypes()); }
public List <PetType> GetALlPetTypes() { return(_petTypeRepo.GetAllPetTypes().ToList()); }