/// <summary>
        /// Prepare paged recurring payment list model
        /// </summary>
        /// <param name="searchModel">Recurring payment search model</param>
        /// <returns>Recurring payment list model</returns>
        public virtual RecurringPaymentListModel PrepareRecurringPaymentListModel(RecurringPaymentSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get recurringPayments
            var recurringPayments = _orderService.SearchRecurringPayments(showHidden: true,
                                                                          pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare list model
            var model = new RecurringPaymentListModel
            {
                Data = recurringPayments.Select(recurringPayment =>
                {
                    //fill in model values from the entity
                    var recurringPaymentModel = new RecurringPaymentModel
                    {
                        Id              = recurringPayment.Id,
                        CycleLength     = recurringPayment.CycleLength,
                        CyclePeriodId   = recurringPayment.CyclePeriodId,
                        TotalCycles     = recurringPayment.TotalCycles,
                        IsActive        = recurringPayment.IsActive,
                        CyclesRemaining = recurringPayment.CyclesRemaining,
                        CustomerId      = recurringPayment.InitialOrder.CustomerId
                    };

                    //convert dates to the user time
                    if (recurringPayment.NextPaymentDate.HasValue)
                    {
                        recurringPaymentModel.NextPaymentDate = _dateTimeHelper
                                                                .ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture);
                    }

                    recurringPaymentModel.StartDate = _dateTimeHelper
                                                      .ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture);

                    //fill in additional values (not existing in the entity)
                    recurringPaymentModel.CyclePeriodStr = _localizationService.GetLocalizedEnum(recurringPayment.CyclePeriod);
                    recurringPaymentModel.CustomerEmail  = recurringPayment.InitialOrder.Customer.IsRegistered()
                        ? recurringPayment.InitialOrder.Customer.Email : _localizationService.GetResource("Admin.Customers.Guest");

                    return(recurringPaymentModel);
                }),
                Total = recurringPayments.TotalCount
            };

            return(model);
        }
        /// <summary>
        /// Prepare paged recurring payment list model
        /// </summary>
        /// <param name="searchModel">Recurring payment search model</param>
        /// <returns>Recurring payment list model</returns>
        public virtual RecurringPaymentListModel PrepareRecurringPaymentListModel(RecurringPaymentSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get recurringPayments
            var recurringPayments = _orderService.SearchRecurringPayments(showHidden: true,
                                                                          pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize);

            //prepare list model
            var model = new RecurringPaymentListModel().PrepareToGrid(searchModel, recurringPayments, () =>
            {
                return(recurringPayments.Select(recurringPayment =>
                {
                    //fill in model values from the entity
                    var recurringPaymentModel = recurringPayment.ToModel <RecurringPaymentModel>();

                    var order = _orderService.GetOrderById(recurringPayment.InitialOrderId);
                    var customer = _customerService.GetCustomerById(order.CustomerId);

                    //convert dates to the user time
                    if (_orderProcessingService.GetNextPaymentDate(recurringPayment) is DateTime nextPaymentDate)
                    {
                        recurringPaymentModel.NextPaymentDate = _dateTimeHelper
                                                                .ConvertToUserTime(nextPaymentDate, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture);
                        recurringPaymentModel.CyclesRemaining = _orderProcessingService.GetCyclesRemaining(recurringPayment);
                    }

                    recurringPaymentModel.StartDate = _dateTimeHelper
                                                      .ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture);

                    //fill in additional values (not existing in the entity)
                    recurringPaymentModel.CustomerId = customer.Id;
                    recurringPaymentModel.InitialOrderId = order.Id;
                    recurringPaymentModel.CyclePeriodStr = _localizationService.GetLocalizedEnum(recurringPayment.CyclePeriod);
                    recurringPaymentModel.CustomerEmail = _customerService.IsRegistered(customer)
                        ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest");

                    return recurringPaymentModel;
                }));
            });