protected virtual void PrepareRecurringPaymentModel(RecurringPaymentModel model,
                                                            RecurringPayment recurringPayment)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (recurringPayment == null)
            {
                throw new ArgumentNullException("recurringPayment");
            }

            model.Id              = recurringPayment.Id;
            model.CycleLength     = recurringPayment.CycleLength;
            model.CyclePeriodId   = recurringPayment.CyclePeriodId;
            model.CyclePeriodStr  = recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext);
            model.TotalCycles     = recurringPayment.TotalCycles;
            model.StartDate       = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString();
            model.IsActive        = recurringPayment.IsActive;
            model.NextPaymentDate = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "";
            model.CyclesRemaining = recurringPayment.CyclesRemaining;
            model.InitialOrderId  = recurringPayment.InitialOrder.Id;
            var customer = EngineContext.Current.Resolve <ICustomerService>().GetCustomerById(recurringPayment.InitialOrder.CustomerId);

            model.CustomerId                = customer.Id;
            model.CustomerEmail             = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest");
            model.PaymentType               = _paymentService.GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName).GetLocalizedEnum(_localizationService, _workContext);
            model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment);
        }
        private void PrepareRecurringPaymentModel(RecurringPaymentModel model, RecurringPayment recurringPayment, bool includeHistory)
        {
            Guard.NotNull(model, nameof(model));
            Guard.NotNull(recurringPayment, nameof(recurringPayment));

            model.Id              = recurringPayment.Id;
            model.CycleLength     = recurringPayment.CycleLength;
            model.CyclePeriodId   = recurringPayment.CyclePeriodId;
            model.CyclePeriodStr  = recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext);
            model.TotalCycles     = recurringPayment.TotalCycles;
            model.StartDate       = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString();
            model.IsActive        = recurringPayment.IsActive;
            model.NextPaymentDate = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "";
            model.CyclesRemaining = recurringPayment.CyclesRemaining;
            model.InitialOrderId  = recurringPayment.InitialOrder.Id;

            var customer = recurringPayment.InitialOrder.Customer;

            model.CustomerId                = customer.Id;
            model.CustomerEmail             = customer.IsGuest() ? T("Admin.Customers.Guest").Text : customer.Email;
            model.PaymentType               = _paymentService.GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName).GetLocalizedEnum(_localizationService, _workContext);
            model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment);

            if (includeHistory)
            {
                foreach (var rph in recurringPayment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc))
                {
                    var rphModel = new RecurringPaymentModel.RecurringPaymentHistoryModel();
                    PrepareRecurringPaymentHistoryModel(rphModel, rph);
                    model.History.Add(rphModel);
                }
            }
        }
        /// <summary>
        /// Prepare recurring payment model
        /// </summary>
        /// <param name="model">Recurring payment model</param>
        /// <param name="recurringPayment">Recurring payment</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Recurring payment model</returns>
        public virtual RecurringPaymentModel PrepareRecurringPaymentModel(RecurringPaymentModel model,
                                                                          RecurringPayment recurringPayment, bool excludeProperties = false)
        {
            if (recurringPayment == null)
            {
                return(model);
            }

            //fill in model values from the entity
            if (model == null)
            {
                model = recurringPayment.ToModel <RecurringPaymentModel>();
            }

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

            model.CustomerId     = recurringPayment.InitialOrder.CustomerId;
            model.InitialOrderId = recurringPayment.InitialOrder.Id;
            model.CustomerEmail  = recurringPayment.InitialOrder.Customer.IsRegistered()
                ? recurringPayment.InitialOrder.Customer.Email : _localizationService.GetResource("Admin.Customers.Guest");
            model.PaymentType = _localizationService.GetLocalizedEnum(_paymentService
                                                                      .GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName));
            model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment);

            //prepare nested search model
            PrepareRecurringPaymentHistorySearchModel(model.RecurringPaymentHistorySearchModel, recurringPayment);

            return(model);
        }
Ejemplo n.º 4
0
        protected virtual CustomerOrderListModel PrepareCustomerOrderListModel()
        {
            var model  = new CustomerOrderListModel();
            var orders = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id,
                                                    customerId: _workContext.CurrentCustomer.Id);

            foreach (var order in orders)
            {
                var orderModel = new CustomerOrderListModel.OrderDetailsModel
                {
                    Id                     = order.Id,
                    CreatedOn              = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
                    OrderStatusEnum        = order.OrderStatus,
                    OrderStatus            = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                    PaymentStatus          = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                    ShippingStatus         = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                    IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order),
                    CanCancelOrder         = _orderProcessingService.CanCancelOrderForCustomer(order), //NOP 3.823
                };
                var orderTotalInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderTotal, order.CurrencyRate);
                orderModel.OrderTotal = _priceFormatter.FormatPrice(orderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage);

                model.Orders.Add(orderModel);
            }

            var recurringPayments = _orderService.SearchRecurringPayments(_storeContext.CurrentStore.Id,
                                                                          _workContext.CurrentCustomer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel
                {
                    Id              = recurringPayment.Id,
                    StartDate       = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo       = string.Format("{0} {1}", recurringPayment.CycleLength, recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext)),
                    NextPayment     = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "",
                    TotalCycles     = recurringPayment.TotalCycles,
                    CyclesRemaining = recurringPayment.CyclesRemaining,
                    InitialOrderId  = recurringPayment.InitialOrder.Id,
                    CanCancel       = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment),
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }

            return(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Prepare the customer order list model
        /// </summary>
        /// <returns>Customer order list model</returns>
        public virtual CustomerOrderListModel PrepareCustomerOrderListModel()
        {
            var model  = new CustomerOrderListModel();
            var orders = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id,
                                                    customerId: _workContext.CurrentCustomer.Id);

            foreach (var order in orders)
            {
                var orderModel = new CustomerOrderListModel.OrderDetailsModel
                {
                    Id                     = order.Id,
                    CreatedOn              = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
                    OrderStatusEnum        = order.OrderStatus,
                    OrderStatus            = _localizationService.GetLocalizedEnum(order.OrderStatus),
                    PaymentStatus          = _localizationService.GetLocalizedEnum(order.PaymentStatus),
                    ShippingStatus         = _localizationService.GetLocalizedEnum(order.ShippingStatus),
                    IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order),
                    CustomOrderNumber      = order.CustomOrderNumber
                };
                var orderTotalInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderTotal, order.CurrencyRate);
                orderModel.OrderTotal = _priceFormatter.FormatPrice(orderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage.Id);

                model.Orders.Add(orderModel);
            }

            var recurringPayments = _orderService.SearchRecurringPayments(_storeContext.CurrentStore.Id,
                                                                          _workContext.CurrentCustomer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var order = _orderService.GetOrderById(recurringPayment.InitialOrderId);

                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel
                {
                    Id          = recurringPayment.Id,
                    StartDate   = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo   = $"{recurringPayment.CycleLength} {_localizationService.GetLocalizedEnum(recurringPayment.CyclePeriod)}",
                    NextPayment = _orderProcessingService.GetNextPaymentDate(recurringPayment) is DateTime nextPaymentDate?_dateTimeHelper.ConvertToUserTime(nextPaymentDate, DateTimeKind.Utc).ToString() : "",
                                      TotalCycles         = recurringPayment.TotalCycles,
                                      CyclesRemaining     = _orderProcessingService.GetCyclesRemaining(recurringPayment),
                                      InitialOrderId      = order.Id,
                                      InitialOrderNumber  = order.CustomOrderNumber,
                                      CanCancel           = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment),
                                      CanRetryLastPayment = _orderProcessingService.CanRetryLastRecurringPayment(_workContext.CurrentCustomer, recurringPayment)
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }

            return(model);
        }
Ejemplo n.º 6
0
        public virtual async Task <IActionResult> CancelRecurringPayment(IFormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Challenge());
            }

            //get recurring payment identifier
            string recurringPaymentId = "";

            foreach (var formValue in form.Keys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.OrdinalIgnoreCase))
                {
                    recurringPaymentId = formValue.Substring("cancelRecurringPayment".Length);
                }
            }

            var recurringPayment = await _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (await _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = await _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = await _mediator.Send(new GetCustomerOrderList()
                {
                    Customer = _workContext.CurrentCustomer,
                    Language = _workContext.WorkingLanguage,
                    Store    = _storeContext.CurrentStore
                });

                model.CancelRecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
Ejemplo n.º 7
0
        private async Task PrepareRecurringPayments(CustomerOrderListModel model, GetCustomerOrderList request)
        {
            var recurringPayments = await _orderService.SearchRecurringPayments(request.Store.Id,
                                                                                request.Customer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel {
                    Id              = recurringPayment.Id,
                    StartDate       = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo       = string.Format("{0} {1}", recurringPayment.CycleLength, recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, request.Language.Id)),
                    NextPayment     = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "",
                    TotalCycles     = recurringPayment.TotalCycles,
                    CyclesRemaining = recurringPayment.CyclesRemaining,
                    InitialOrderId  = recurringPayment.InitialOrder.Id,
                    CanCancel       = await _orderProcessingService.CanCancelRecurringPayment(request.Customer, recurringPayment),
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }
        }
Ejemplo n.º 8
0
        public virtual ActionResult CancelRecurringPayment(FormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }

            //get recurring payment identifier
            int recurringPaymentId = 0;

            foreach (var formValue in form.AllKeys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.InvariantCultureIgnoreCase))
                {
                    recurringPaymentId = Convert.ToInt32(formValue.Substring("cancelRecurringPayment".Length));
                }
            }

            var recurringPayment = _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (_orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = _orderModelFactory.PrepareCustomerOrderListModel();
                model.RecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
Ejemplo n.º 9
0
        public virtual IActionResult CancelRecurringPayment(IFormCollection form)
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Challenge());
            }

            //get recurring payment identifier
            string recurringPaymentId = "";

            foreach (var formValue in form.Keys)
            {
                if (formValue.StartsWith("cancelRecurringPayment", StringComparison.OrdinalIgnoreCase))
                {
                    recurringPaymentId = formValue.Substring("cancelRecurringPayment".Length);
                }
            }

            var recurringPayment = _orderService.GetRecurringPaymentById(recurringPaymentId);

            if (recurringPayment == null)
            {
                return(RedirectToRoute("CustomerOrders"));
            }

            if (_orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment))
            {
                var errors = _orderProcessingService.CancelRecurringPayment(recurringPayment);

                var model = _orderWebService.PrepareCustomerOrderList();
                model.CancelRecurringPaymentErrors = errors;

                return(View(model));
            }
            else
            {
                return(RedirectToRoute("CustomerOrders"));
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Prepare the customer order list model
        /// </summary>
        /// <returns>Customer order list model</returns>
        public virtual CustomerOrderListModel PrepareCustomerOrderListModel(int?page)
        {
            var model    = new CustomerOrderListModel();
            var pageSize = 5;
            var orders   = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id,
                                                      customerId: _workContext.CurrentCustomer.Id, pageIndex: --page ?? 0, pageSize: pageSize);

            foreach (var order in orders)
            {
                var orderModel = new CustomerOrderListModel.OrderDetailsModel
                {
                    Id                     = order.Id,
                    CreatedOn              = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
                    OrderStatusEnum        = order.OrderStatus,
                    OrderStatus            = _localizationService.GetLocalizedEnum(order.OrderStatus),
                    PaymentStatus          = _localizationService.GetLocalizedEnum(order.PaymentStatus),
                    ShippingStatus         = _localizationService.GetLocalizedEnum(order.ShippingStatus),
                    IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order),
                    CustomOrderNumber      = order.CustomOrderNumber
                };
                var orderTotalInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderTotal, order.CurrencyRate);
                orderModel.OrderTotal = _priceFormatter.FormatPrice(orderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage);

                model.Orders.Add(orderModel);
            }


            model.PagerModel = new PagerModel
            {
                PageSize         = orders.PageSize,
                TotalRecords     = orders.TotalCount,
                PageIndex        = orders.PageIndex,
                ShowTotalSummary = false,
                RouteActionName  = "CustomerOrdersListPaged",
                UseRouteLinks    = true,
                RouteValues      = new OrdersListRouteValues {
                    pageNumber = page ?? 0
                }
            };


            var recurringPayments = _orderService.SearchRecurringPayments(_storeContext.CurrentStore.Id,
                                                                          _workContext.CurrentCustomer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel
                {
                    Id                  = recurringPayment.Id,
                    StartDate           = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo           = $"{recurringPayment.CycleLength} {_localizationService.GetLocalizedEnum(recurringPayment.CyclePeriod)}",
                    NextPayment         = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "",
                    TotalCycles         = recurringPayment.TotalCycles,
                    CyclesRemaining     = recurringPayment.CyclesRemaining,
                    InitialOrderId      = recurringPayment.InitialOrder.Id,
                    InitialOrderNumber  = recurringPayment.InitialOrder.CustomOrderNumber,
                    CanCancel           = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment),
                    CanRetryLastPayment = _orderProcessingService.CanRetryLastRecurringPayment(_workContext.CurrentCustomer, recurringPayment)
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }

            return(model);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Prepare the customer order list model
        /// </summary>
        /// <returns>Customer order list model</returns>
        public virtual CustomerOrderListModel PrepareCustomerOrderListModel(string status, int?page, int?pageSize)
        {
            if (page == 0)
            {
                page = null;
            }

            List <int> statusList = new List <int>();

            if (!string.IsNullOrEmpty(status))
            {
                if (status == ((int)OrderStatus.Cancelled).ToString())
                {
                    statusList.Add((int)OrderStatus.Cancelled);
                }

                if (status == ((int)OrderStatus.Pending).ToString())
                {
                    statusList.Add((int)OrderStatus.Pending);
                    statusList.Add((int)OrderStatus.Processing);
                }
            }

            var model  = new CustomerOrderListModel();
            var orders = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id,
                                                    customerId: _workContext.CurrentCustomer.Id, osIds: statusList); //pageIndex: --page ?? 0, pageSize: 5,

            List <CustomerOrderListModel.OrderDetailsModel> allOrders = new List <CustomerOrderListModel.OrderDetailsModel>();

            foreach (var order in orders)
            {
                var orderModel = new CustomerOrderListModel.OrderDetailsModel
                {
                    Id                     = order.Id,
                    CreatedOn              = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc),
                    OrderStatusEnum        = order.OrderStatus,
                    OrderStatus            = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                    PaymentStatus          = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                    ShippingStatus         = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                    IsReturnRequestAllowed = _orderProcessingService.IsReturnRequestAllowed(order),
                    CustomOrderNumber      = order.CustomOrderNumber
                };
                var orderTotalInCustomerCurrency = _currencyService.ConvertCurrency(order.OrderTotal, order.CurrencyRate);
                orderModel.OrderTotal = _priceFormatter.FormatPrice(orderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage);

                allOrders.Add(orderModel);
            }

            List <CustomerOrderListModel.OrderDetailsModel> legacyOrders = null;
            var miscPlugins = _pluginFinder.GetPlugins <MyOrderServicePlugin>(storeId: EngineContext.Current.Resolve <IStoreContext>().CurrentStore.Id).ToList();

            if (miscPlugins.Count > 0 && _gbsOrderSettings.LegacyOrdersInOrderHistory)
            {
                legacyOrders = new Orders.OrderExtensions().getLegacyOrders();
                if (!string.IsNullOrEmpty(status))
                {
                    legacyOrders = legacyOrders.Where(x => statusList.Contains((int)x.OrderStatusEnum)).ToList();
                }

                if (legacyOrders != null && legacyOrders.Count() > 0)
                {
                    allOrders.AddRange(legacyOrders);
                }
                allOrders.Sort((x, y) => y.CreatedOn.CompareTo(x.CreatedOn));
            }

            var ordersPaging = new PagedList <CustomerOrderListModel.OrderDetailsModel>(allOrders, pageIndex: --page ?? 0, pageSize: pageSize ?? 5);

            model.Orders = ordersPaging.ToList();

            // do paging on orders

            var recurringPayments = _orderService.SearchRecurringPayments(_storeContext.CurrentStore.Id,
                                                                          _workContext.CurrentCustomer.Id);

            foreach (var recurringPayment in recurringPayments)
            {
                var recurringPaymentModel = new CustomerOrderListModel.RecurringOrderModel
                {
                    Id                  = recurringPayment.Id,
                    StartDate           = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(),
                    CycleInfo           = string.Format("{0} {1}", recurringPayment.CycleLength, recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext)),
                    NextPayment         = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : "",
                    TotalCycles         = recurringPayment.TotalCycles,
                    CyclesRemaining     = recurringPayment.CyclesRemaining,
                    InitialOrderId      = recurringPayment.InitialOrder.Id,
                    InitialOrderNumber  = recurringPayment.InitialOrder.CustomOrderNumber,
                    CanCancel           = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment),
                    CanRetryLastPayment = _orderProcessingService.CanRetryLastRecurringPayment(_workContext.CurrentCustomer, recurringPayment)
                };

                model.RecurringOrders.Add(recurringPaymentModel);
            }

            model.CustomProperties["PagerModel"] = new PagerModel
            {
                PageSize         = ordersPaging.PageSize,
                TotalRecords     = ordersPaging.TotalCount,
                PageIndex        = ordersPaging.PageIndex,
                ShowTotalSummary = true,
                RouteActionName  = "CustomerOrders",
                UseRouteLinks    = true,
                RouteValues      = new OrderRouteValues {
                    page = page ?? 0, status = status, pageSize = pageSize
                }
            };

            if (model.Orders.Any())
            {
                model.Orders.FirstOrDefault().CustomProperties["PagerModel"] = new PagerModel
                {
                    PageSize         = ordersPaging.PageSize,
                    TotalRecords     = ordersPaging.TotalCount,
                    PageIndex        = ordersPaging.PageIndex,
                    ShowTotalSummary = true,
                    RouteActionName  = "CustomerOrders",
                    UseRouteLinks    = true,
                    RouteValues      = new OrderRouteValues {
                        page = page ?? 0, status = status, pageSize = pageSize
                    }
                };
            }

            return(model);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets a value indicating whether a customer can cancel recurring payment
 /// </summary>
 /// <param name="customerToValidate">Customer</param>
 /// <param name="recurringPayment">Recurring Payment</param>
 /// <returns>value indicating whether a customer can cancel recurring payment</returns>
 public bool CanCancelRecurringPayment(Customer customerToValidate, RecurringPayment recurringPayment)
 {
     return(_orderProcessingService.CanCancelRecurringPayment(customerToValidate, recurringPayment));
 }