public static PagedResponse <TEntity> Ensure <TEntity>(this PagedResponse <TEntity> response, Func <IEnumerable <TEntity>, bool> func, string message = "") { if (response.NotOk) { return(response); } if (!func(response.Payload)) { return(PagedResponse <TEntity> .BadRequest(message)); } return(response); }