public List <Pet> GetPets(Filter filter) { if (filter == null) { return(_petRepo.ReadPets(null).ToList()); } if (filter.CurrentPage < 0 || filter.ItemsPrPage < 0) { _errorFactory.Invalid(message: "Current page and items per page index must be 0 or more"); } if ((filter.CurrentPage - 1 * filter.ItemsPrPage) >= _petRepo.Count()) { _errorFactory.Invalid(message: "Index out of bounds. Current page is too high"); } return(_petRepo.ReadPets(filter).ToList()); }
public List <Owner> GetAllOwners(Filter filter) { if (filter == null) { return(_ownerRepo.ReadOwners(filter).ToList()); } if (filter.CurrentPage < 0 || filter.ItemsPrPage < 0) { _errorFactory.Invalid("Current page or items per page can not be below 0"); } if ((filter.CurrentPage - 1) * filter.ItemsPrPage >= _ownerRepo.Count()) { _errorFactory.Invalid("Index out of bounds. Current page is too high"); } return(_ownerRepo.ReadOwners(filter).ToList()); }