public ActionResult EnrollmentComplete(string token) { var model = new EnrollmentCompleteViewModel(); var args = Security.Decrypt(token); var hasOrder = args["OrderID"] != null; var hasAutoOrder = args["AutoOrderID"] != null; model.CustomerID = Convert.ToInt32(args["CustomerID"]); if (hasOrder) { model.OrderID = Convert.ToInt32(args["OrderID"]); model.Order = Exigo.GetCustomerOrders(new GetCustomerOrdersRequest { CustomerID = model.CustomerID, OrderID = model.OrderID, IncludeOrderDetails = true, IncludePayments = true }).FirstOrDefault(); } if (hasAutoOrder) { model.AutoOrderID = Convert.ToInt32(args["AutoOrderID"]); try { model.AutoOrder = Exigo.GetCustomerAutoOrders(Identity.Customer.CustomerID, model.AutoOrderID).FirstOrDefault(); } catch { } } return(View(model)); }
public bool HasMaxAutoOrders() { using (var context = Exigo.Sql()) { var autoOrders = context.Query <AutoOrder>(@" select * from AutoOrders where CustomerID = @customerID and AutoOrderStatusID = 0 ", new { customerID = Identity.Customer.CustomerID }).ToList(); if (autoOrders.Count() >= GlobalSettings.AutoOrders.MaxAutoOrderCount) { return(true); } else { // Try once more just to make sure that they haven't recently paused an auto order var _autoOrders = Exigo.GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest { CustomerID = Identity.Customer.CustomerID }); if (_autoOrders.Count() >= GlobalSettings.AutoOrders.MaxAutoOrderCount) { return(true); } return(false); } } }
public ActionResult AutoOrderList() { var viewModel = new AutoOrderListViewModel(); viewModel.AutoOrders = Exigo.GetCustomerAutoOrders(Identity.Customer.CustomerID, includePaymentMethods: false); if (!viewModel.AutoOrders.Any()) { return(RedirectToAction("NoActiveAutoOrdersFound")); } return(View(viewModel)); }
public ActionResult AutoOrderPreferences() { var context = Exigo.OData(); var model = Exigo.GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest { CustomerID = Identity.Customer.CustomerID, IncludeDetails = true, IncludePaymentMethods = true, IncludeInactiveAutoOrders = true }); return(View(model)); }
public ActionResult AutoOrderPreferences() { var context = Exigo.OData(); var model = Exigo.GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest { CustomerID = Identity.Current.CustomerID, IncludeDetails = true, IncludePaymentMethods = true, IncludeInactiveAutoOrders = true }).Where(v => !v.Details.Any(d => d.ItemCode == "IAANNUALRENEWAL")); return(View(model)); }
public ActionResult ManageAutoOrder(int id) { var viewModel = new ManageAutoOrderViewModel(); var customerID = Identity.Customer.CustomerID; var customer = Exigo.GetCustomer(customerID); var autoOrder = Exigo.GetCustomerAutoOrders(customerID, id).FirstOrDefault(); var market = GlobalSettings.Markets.AvailableMarkets.Where(c => c.Countries.Contains(Identity.Customer.Country)).FirstOrDefault(); var configuration = market.GetConfiguration().AutoOrders; var isExistingAutoOrder = id != 0; if (isExistingAutoOrder) { viewModel.AutoOrder = autoOrder; viewModel.AutoOrder.StartDate = Exigo.GetNextAvailableAutoOrderStartDate(viewModel.AutoOrder.NextRunDate ?? DateTime.Now); // Fill in any blanks in the recipient viewModel.AutoOrder.ShippingAddress.FirstName = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.FirstName, customer.FirstName); viewModel.AutoOrder.ShippingAddress.MiddleName = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.MiddleName, customer.MiddleName); viewModel.AutoOrder.ShippingAddress.LastName = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.LastName, customer.LastName); viewModel.AutoOrder.ShippingAddress.Company = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.Company, customer.Company); viewModel.AutoOrder.ShippingAddress.Email = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.Email, customer.Email); viewModel.AutoOrder.ShippingAddress.Phone = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.Phone, customer.PrimaryPhone, customer.SecondaryPhone, customer.MobilePhone); } else { var customerShippingAddress = customer.ShippingAddresses.Where(a => a.IsComplete && a.Country == Identity.Customer.Country).FirstOrDefault(); viewModel.AutoOrder = new AutoOrder() { FrequencyTypeID = FrequencyTypes.Monthly, CurrencyCode = configuration.CurrencyCode, AutoOrderPaymentTypeID = AutoOrderPaymentTypes.PrimaryCreditCardOnFile, StartDate = Exigo.GetNextAvailableAutoOrderStartDate(DateTime.Now), ShippingAddress = (customerShippingAddress != null) ? customerShippingAddress : new ShippingAddress() { Country = Identity.Customer.Country }, ShipMethodID = configuration.DefaultShipMethodID }; viewModel.AutoOrder.ShippingAddress.Phone = GlobalUtilities.Coalesce(viewModel.AutoOrder.ShippingAddress.Phone, customer.PrimaryPhone, customer.SecondaryPhone, customer.MobilePhone); viewModel.UsePointAccount = false; } // Get Available Ship Methods, if we are managing an existing auto order if (isExistingAutoOrder) { var calculateOrderResponse = Exigo.CalculateOrder(new OrderCalculationRequest { Address = viewModel.AutoOrder.ShippingAddress, ShipMethodID = viewModel.AutoOrder.ShipMethodID, ReturnShipMethods = true, Configuration = Identity.Customer.Market.Configuration.AutoOrders, CustomerID = Identity.Customer.CustomerID, Items = viewModel.AutoOrder.Details.Select(i => new ShoppingCartItem { ItemCode = i.ItemCode, Quantity = i.Quantity }) }); viewModel.AvailableShipMethods = calculateOrderResponse.ShipMethods.ToList(); } else { // Give the View a default ship method for display only viewModel.AvailableShipMethods = new List <ShipMethod> { new ShipMethod { Price = 0, Selected = true, ShipMethodDescription = "---", ShipMethodID = 0 } }; } InflateManageAutoOrderViewModel(customerID, market, configuration, ref viewModel); return(View(viewModel)); }
public ActionResult Index() { var model = new AccountOverviewViewModel(); var customer = Exigo.GetCustomer(Identity.Current.CustomerID); model.Enroller = customer.Enroller; model.Sponsor = customer.Sponsor; var website = Exigo.GetCustomerSite(Identity.Current.CustomerID); var socialNetworksResponse = Exigo.WebService().GetCustomerSocialNetworks(new GetCustomerSocialNetworksRequest() { CustomerID = Identity.Current.CustomerID }); // Social NetWorks foreach (var network in socialNetworksResponse.CustomerSocialNetwork) { switch (network.SocialNetworkID) { case (int)SocialNetworks.Facebook: model.FacebookUrl = network.Url; break; case (int)SocialNetworks.Twitter: model.TwitterUrl = network.Url; break; case (int)SocialNetworks.YouTube: model.YouTubeUrl = network.Url; break; case (int)SocialNetworks.Blog: model.BlogUrl = network.Url; break; } } //Basic Info model.CustomerID = customer.CustomerID; model.FirstName = customer.FirstName; model.LastName = customer.LastName; model.Email = customer.Email; model.WebAlias = website.WebAlias; model.LoginName = customer.LoginName; model.LanguageID = customer.LanguageID; model.CreatedDate = customer.CreatedDate; // Team Placement var currentPeriod = Exigo.GetCurrentPeriod(PeriodTypes.Default); var placementOptions = new List <SelectListItem>(); var volumes = Exigo.GetCustomerVolumes(new GetCustomerVolumesRequest() { CustomerID = Identity.Current.CustomerID, PeriodID = currentPeriod.PeriodID, PeriodTypeID = PeriodTypes.Default }); var canSeeTeamOne = (volumes.Volume50 > 0); var canSeeTeamTwo = (volumes.Volume51 > 0); var canSeeTeamThree = (volumes.Volume52 > 0); var canSeeTeamFour = (volumes.Volume53 > 0); var canSeeTeamFive = (volumes.Volume54 > 0); model.TeamPlacementPreferenceID = customer.Field1; // Only show available teams. If none available, default to team one if (canSeeTeamOne || (canSeeTeamOne == false && canSeeTeamTwo == false && canSeeTeamThree == false && canSeeTeamFour == false && canSeeTeamFive == false)) { placementOptions.Add(new SelectListItem { Text = Resources.Common.Team + " 1", Value = "1" }); } if (canSeeTeamTwo) { placementOptions.Add(new SelectListItem { Text = Resources.Common.Team + " 2", Value = "2" }); } if (canSeeTeamThree) { placementOptions.Add(new SelectListItem { Text = Resources.Common.Team + " 3", Value = "3" }); } if (canSeeTeamFour) { placementOptions.Add(new SelectListItem { Text = Resources.Common.Team + " 4", Value = "4" }); } if (canSeeTeamFive) { placementOptions.Add(new SelectListItem { Text = Resources.Common.Team + " 5", Value = "5" }); } model.TeamPlacementPreferenceOptions = placementOptions; // Set the description for the user's team to be displayed if (model.TeamPlacementPreferenceID != "") { model.TeamPlacementPreference = Resources.Common.Team + " " + model.TeamPlacementPreferenceID; } // If somehow the customer does not have a value in thier Field1, default the description to the first available option else { var firstAvailableTeamNumber = placementOptions.OrderBy(c => c.Value).FirstOrDefault().Value; model.TeamPlacementPreference = Resources.Common.Team + " " + firstAvailableTeamNumber; } // Tax ID - Added try catch around this because it fails from time to time and kills the entire page - Mike M. try { var request = new Common.Api.ExigoWebService.GetCustomReportRequest(); request.ReportID = 3; request.Parameters = new List <ParameterRequest> { new ParameterRequest { ParameterName = "CustomerID", Value = Identity.Current.CustomerID } }.ToArray(); var taxIDResponse = Exigo.WebService().GetCustomReport(request); var taxId = taxIDResponse.ReportData.Tables[0].Rows[0][0].ToString(); model.TaxIDIsSet = (taxId != ""); model.MaskedTaxID = taxId; } catch (Exception ex) { } // Contact model.PrimaryPhone = customer.PrimaryPhone; model.SecondaryPhone = customer.SecondaryPhone; model.MobilePhone = customer.MobilePhone; model.Fax = customer.Fax; model.Addresses = customer.Addresses; // Customer Site model.CustomerSite.FirstName = website.FirstName; model.CustomerSite.LastName = website.LastName; model.CustomerSite.Email = website.Email; model.CustomerSite.PrimaryPhone = website.PrimaryPhone; model.CustomerSite.SecondaryPhone = website.SecondaryPhone; model.CustomerSite.Fax = website.Fax; model.CustomerSite.Notes1 = website.Notes1; model.CustomerSite.Notes2 = website.Notes2; model.CustomerSite.Notes3 = website.Notes3; model.CustomerSite.Notes4 = website.Notes4; model.CustomerSite.Address.Address1 = website.Address.Address1; model.CustomerSite.Address.Address2 = website.Address.Address2; model.CustomerSite.Address.Country = website.Address.Country; model.CustomerSite.Address.City = website.Address.City; model.CustomerSite.Address.State = website.Address.State; model.CustomerSite.Address.Zip = website.Address.Zip; // Opt in model.IsOptedIn = customer.IsOptedIn; // Annual Membership model.Membership = Exigo.GetCustomerAutoOrders(new GetCustomerAutoOrdersRequest { CustomerID = Identity.Current.CustomerID, IncludeDetails = true, IncludePaymentMethods = true, IncludeInactiveAutoOrders = true }).Where(v => v.Details.Any(d => d.ItemCode == "IAANNUALRENEWAL")).FirstOrDefault(); model.ActiveMembership = model.Membership != null ? "Scheduled" + @model.Membership.NextRunDate : "No Renewal Scheduled"; // Get the available languages model.Languages = Exigo.GetLanguages(); return(View(model)); }