public IActionResult Index(SubscriptionDetailPage currentPage, int paymentPlanId = 0)
        {
            var paymentDetail = OrderContext.Current.Get <PaymentPlan>(paymentPlanId);

            var viewModel = new SubscriptionDetailViewModel(currentPage)
            {
                CurrentContent = currentPage,
                PaymentPlan    = paymentDetail
            };

            //Get order that created by
            var purchaseOrders = OrderContext.Current.LoadByCustomerId <PurchaseOrder>(PrincipalInfo.CurrentPrincipal.GetContactId())
                                 .OrderByDescending(x => x.Created)
                                 .Where(x => x.ParentOrderGroupId.Equals(paymentPlanId))
                                 .ToList();

            var orders = new OrderHistoryViewModel
            {
                Orders = new List <OrderViewModel>()
            };

            foreach (var purchaseOrder in purchaseOrders)
            {
                // Assume there is only one form per purchase.
                var form           = purchaseOrder.GetFirstForm();
                var billingAddress = new AddressModel();
                var payment        = form.Payments.FirstOrDefault();
                if (payment != null)
                {
                    billingAddress = _addressBookService.ConvertToModel(payment.BillingAddress);
                }
                var orderViewModel = new OrderViewModel
                {
                    PurchaseOrder = purchaseOrder,
                    Items         = form.GetAllLineItems().Select(lineItem => new OrderHistoryItemViewModel
                    {
                        LineItem = lineItem,
                    }).GroupBy(x => x.LineItem.Code).Select(group => group.First()),
                    BillingAddress    = billingAddress,
                    ShippingAddresses = new List <AddressModel>()
                };

                foreach (var orderAddress in purchaseOrder.OrderForms.Cast <IOrderForm>().SelectMany(x => x.Shipments).Select(s => s.ShippingAddress))
                {
                    var shippingAddress = _addressBookService.ConvertToModel(orderAddress);
                    orderViewModel.ShippingAddresses.Add(shippingAddress);
                }

                orders.Orders.Add(orderViewModel);
            }
            orders.OrderDetailsPageUrl =
                UrlResolver.Current.GetUrl(_settingsService.GetSiteSettings <ReferencePageSettings>()?.OrderDetailsPage ?? ContentReference.StartPage);

            viewModel.Orders = orders;

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult GetSubscriptionDetail(int SubscriptionId)
        {
            var subscription = _entities.TipoSuscripcion.Find(SubscriptionId);

            if (subscription != null)
            {
                SubscriptionDetailViewModel model = new SubscriptionDetailViewModel();
                model._subscriptionTitle = subscription.nombre;
                model._price             = subscription.precio.Value;
                model._period            = "MES";
                model._features          = subscription.descripcion.Split('/');

                return(PartialView("_GetSubscriptionDetail", model));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Пример #3
0
 public SubscriptionDetailPage()
 {
     InitializeComponent();
     BindingContext = new SubscriptionDetailViewModel();
 }