Ejemplo n.º 1
0
        protected CustomerOrderListModel PrepareCustomerOrderListModel(CustomerOrderPagingFilteringModel command)
        {
            int?orderId = null;

            if (!string.IsNullOrEmpty(command.q))
            {
                int temp = 0;
                if (int.TryParse(command.q, out temp))
                {
                    orderId = temp;
                }
            }
            var profileId = _workContext.CurrentProfile.Id;
            var model     = new CustomerOrderListModel();
            var result    = _orderService.GetPagedOrderOverviewModel(
                pageIndex: command.PageNumber - 1,
                pageSize: command.PageSize,
                profileIds: new int[] { profileId },
                orderIds: orderId.HasValue ? new int[] { orderId.Value } : null,
                statusCodes: ValidOrderStatus.VALID_CUSTOMER_STATUSES,
                orderBy: OrderSortingType.OrderPlacedDesc);

            for (int i = 0; i < result.Items.Count; i++)
            {
                var order = result.Items[i];

                var orderModel = new OrderSummaryModel
                {
                    Id              = order.Id,
                    CreatedOn       = order.OrderPlaced.Value,
                    OrderStatusCode = order.StatusCode,
                    OrderStatus     = order.OrderStatus
                };

                // To avoid customer frustration, ON HOLD will be changed to ORDER PLACED
                if (orderModel.OrderStatusCode == OrderStatusCode.ON_HOLD)
                {
                    orderModel.OrderStatusCode = OrderStatusCode.ORDER_PLACED;
                    orderModel.OrderStatus     = _orderService.GetOrderStatusByCode(OrderStatusCode.ORDER_PLACED);
                }

                orderModel.OrderTotal = _priceFormatter.FormatValue(order.GrandTotal, order.CurrencyCode);

                model.Orders.Add(orderModel);
            }

            model.PagingFilteringContext.LoadPagedList(result);
            model.PagingFilteringContext.q = command.q;

            if (model.Orders.Count > 0)
            {
                model.Orders[0].Chosen = true;
            }

            return(model);
        }
Ejemplo n.º 2
0
        public ActionResult InvoicePayment(string k)
        {
            if (string.IsNullOrEmpty(k))
            {
                return(InvokeHttp400());
            }

            string encodedKey = k.ToLower();

            var emailInvoice = _orderService.GetEmailInvoiceByEncodedKey(encodedKey);

            // Not found
            // Expired
            if (emailInvoice == null || emailInvoice.EndDate.CompareTo(DateTime.Now) < 0)
            {
                return(InvokeHttp400());
            }

            // Paid
            if (emailInvoice.Paid)
            {
                return(InvokeHttp410());
            }

            var paymentModel = new CheckoutPaymentModel
            {
                CardTypes    = PrepareCardTypes(),
                ExpireYears  = PrepareCardYears(),
                ExpireMonths = PrepareCardMonths(),
                OrderTotal   = _priceFormatter.FormatValue(emailInvoice.Amount * emailInvoice.ExchangeRate, emailInvoice.CurrencyCode)
            };

            if (string.IsNullOrEmpty(_session["PaymentErrorMessage"] as string) == false)
            {
                ViewBag.ErrorMessage            = _session["PaymentErrorMessage"].ToString();
                _session["PaymentErrorMessage"] = null;
            }

            var model = new InvoicePaymentModel
            {
                EmailInvoiceId = emailInvoice.Id,
                Payment        = paymentModel
            };

            // countries and states
            var countries = _shippingService.GetActiveCountries();
            var states    = _shippingService.GetUSStates();

            model.BillingAddress.AvailableCountries = countries.PrepareCountries();
            model.BillingAddress.AvailableStates    = states.PrepareStates();

            return(View(model));
        }