Exemple #1
0
        /// <summary>
        /// Lists all records of type `TResult`.
        /// </summary>
        /// <exception cref="UnsupportedTransactionException">
        /// Thrown when gateway does not support retrieving recurring records.
        /// </exception>
        public static List <TResult> FindAll(string configName = "default")
        {
            var client = ServicesContainer.Instance.GetRecurringClient(configName);

            if (client.SupportsRetrieval)
            {
                return(RecurringService.Search <List <TResult> >().Execute());
            }
            throw new UnsupportedTransactionException();
        }
Exemple #2
0
        /// <summary>
        /// Searches for a specific record by `id`.
        /// </summary>
        /// <param name="id">The ID of the record to find</summary>
        /// <returns>`TResult` or `null` if the record cannot be found.</returns>
        /// <exception cref="UnsupportedTransactionException">
        /// Thrown when gateway does not support retrieving recurring records.
        /// </exception>
        public static TResult Find(string id, string configName = "default")
        {
            var client = ServicesContainer.Instance.GetRecurringClient(configName);

            if (client.SupportsRetrieval)
            {
                var identifier = GetIdentifierName();
                var response   = RecurringService.Search <List <TResult> >()
                                 .AddSearchCriteria(identifier, id)
                                 .Execute();
                var entity = response.FirstOrDefault();
                if (entity != null)
                {
                    return(RecurringService.Get <TResult>(entity.Key));
                }
                return(null);
            }
            throw new UnsupportedTransactionException();
        }