public ActionResult Index() { var model = new BackofficeSubscriptionsViewModel(); // Get the customer's subscriptions model.Subscriptions = Exigo.GetCustomerSubscriptions(CurrentCustomerID).ToList(); // If we have any expired subscriptions, we need to calculate how much they are going to cost to catch them up today if (model.Subscriptions.Where(c => c.SubscriptionID == Subscriptions.BackofficeFeatures).FirstOrDefault() == null || model.Subscriptions.Where(c => c.SubscriptionID == Subscriptions.BackofficeFeatures).Any(s => s.IsExpired)) { var customer = Exigo.GetCustomer(Identity.Current.CustomerID); if (customer.CreatedDate >= DateTimeExtensions.ToCST(DateTime.Now.AddMinutes(-30)) && customer.CustomerTypeID == CustomerTypes.Associate) { var cookie = new HttpCookie(GlobalSettings.Backoffices.MonthlySubscriptionCookieName); cookie.Value = "true"; cookie.Expires = DateTime.Now.AddMinutes(15); HttpContext.Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Dashboard")); } // Set up our request to get the order totals on the subscriptions that are required var request = new OrderCalculationRequest(); // We pull the customer's addresses first, if there are none we calculate with the corp address var customerAddresses = Exigo.GetCustomerAddresses(CurrentCustomerID); var address = (customerAddresses.Count() > 0 && customerAddresses.Where(c => c.IsComplete == true).Count() > 0) ? customerAddresses.Where(c => c.IsComplete == true).FirstOrDefault() : GlobalSettings.Company.Address; // Find which subscriptions are expired and add the appropriate items to those where needed var itemsToCalculate = new List <ShoppingCartItem>(); itemsToCalculate.Add(new ShoppingCartItem { ItemCode = GlobalSettings.Backoffices.MonthlySubscriptionItemCode, Quantity = 1 }); model.PaymentMethods = Exigo.GetCustomerPaymentMethods(new GetCustomerPaymentMethodsRequest { CustomerID = CurrentCustomerID, ExcludeIncompleteMethods = true, ExcludeInvalidMethods = true }); request.Configuration = OrderConfiguration; request.Address = address; request.Items = itemsToCalculate; request.ShipMethodID = OrderConfiguration.DefaultShipMethodID; //82774 Ivan S. 11/24/2016 //The Commissions page was displaying an OOPS error when clicking on it, because //we were not passing in the CustomerID, and it was generating a null exception //Therefore I added this line of code: request.CustomerID = Identity.Current.CustomerID; model.OrderCalcResponse = Exigo.CalculateOrder(request); } return(View(model)); }
public void Initialize(int customerID) { var subscriptions = Exigo.GetCustomerSubscriptions(customerID); this.AllSubscriptions = subscriptions.ToList(); }