public UserIdentity(System.Web.Security.FormsAuthenticationTicket ticket) { string[] a = ticket.UserData.Split('|'); Name = ticket.Name; // WebIdentity Variables CustomerID = int.Parse(GlobalUtilities.Coalesce(a[0], "0")); FirstName = GlobalUtilities.Coalesce(a[1], ""); LastName = GlobalUtilities.Coalesce(a[2], ""); Company = GlobalUtilities.Coalesce(a[3], ""); Country = GlobalUtilities.Coalesce(a[4], ""); EnrollerID = Convert.ToInt32(a[5]); SponsorID = Convert.ToInt32(a[6]); LanguageID = int.Parse(GlobalUtilities.Coalesce(a[7], Languages.English.ToString())); CustomerTypeID = int.Parse(GlobalUtilities.Coalesce(a[8], CustomerTypes.Distributor.ToString())); CustomerStatusID = int.Parse(GlobalUtilities.Coalesce(a[9], CustomerStatusTypes.Active.ToString())); DefaultWarehouseID = int.Parse(GlobalUtilities.Coalesce(a[10], Warehouses.Default.ToString())); PriceTypeID = int.Parse(GlobalUtilities.Coalesce(a[11], PriceTypes.Distributor.ToString())); CurrencyCode = GlobalUtilities.Coalesce(a[12], "usd"); CreatedDate = Convert.ToDateTime(a[13]); Expires = ticket.Expiration; }
public Rank GetCurrentRank(int CustomerID, int PeriodTypeID) { var result = new Rank(); var response = GetContext().PeriodVolumes .Where(c => c.CustomerID == CustomerID) .Where(c => c.PeriodTypeID == PeriodTypeID) .Where(c => c.Period.IsCurrentPeriod) .Select(c => new { RankID = c.PaidRankID, RankDescription = c.PaidRank.RankDescription }) .FirstOrDefault(); if (response == null) { return(null); } result.RankID = response.RankID; result.RankDescription = GlobalUtilities.Coalesce(response.RankDescription, "Unknown"); return(result); }
public ShoppingCartItem(IShoppingCartItem item) { ID = (item.ID != Guid.Empty) ? item.ID : Guid.NewGuid(); ItemCode = GlobalUtilities.Coalesce(item.ItemCode); Quantity = item.Quantity; GroupMasterItemCode = GlobalUtilities.Coalesce(item.GroupMasterItemCode); Type = item.Type; Children = item.Children; }
public ShoppingCartItem(IShoppingCartItem item) { ID = (item.ID != Guid.Empty) ? item.ID : Guid.NewGuid(); ItemCode = GlobalUtilities.Coalesce(item.ItemCode); Quantity = item.Quantity; ParentItemCode = GlobalUtilities.Coalesce(item.ParentItemCode); DynamicKitCategory = GlobalUtilities.Coalesce(item.DynamicKitCategory); GroupMasterItemCode = GlobalUtilities.Coalesce(item.GroupMasterItemCode); Type = item.Type; }
private ShoppingCartItem(IShoppingCartItem item) { ID = (item.ID != Guid.Empty) ? item.ID : Guid.NewGuid(); ItemCode = GlobalUtilities.Coalesce(item.ItemCode); ParentItemCode = GlobalUtilities.Coalesce(item.ParentItemCode); Description = item.ItemDescription; ItemDescription = item.ItemDescription; Quantity = item.Quantity; DynamicKitCategory = GlobalUtilities.Coalesce(item.DynamicKitCategory); GroupMasterItemCode = GlobalUtilities.Coalesce(item.GroupMasterItemCode); Type = item.Type; Category = item.Category; PriceTypeID = item.PriceTypeID; Price = item.Price; PriceEachOverride = item.PriceEachOverride; BusinessVolumeEachOverride = item.BusinessVolumeEachOverride; CommissionableVolumeEachOverride = item.CommissionableVolumeEachOverride; ApplyDiscountType = item.ApplyDiscountType; AppliedAmount = item.AppliedAmount; InventoryStatus = item.InventoryStatus; OtherCheck1 = item.OtherCheck1; OtherCheck2 = item.OtherCheck2; OtherCheck3 = item.OtherCheck3; OtherCheck4 = item.OtherCheck4; OtherCheck5 = item.OtherCheck5; Field1 = item.Field1; Field2 = item.Field2; if (item.ApplyDiscountType == DiscountType.Unknown) { Discounts = new List <Discount>(); } else { var factory = new DiscountFactory(); Discounts = new List <Discount> { factory.CreateDiscount(ApplyDiscountType, item.AppliedAmount) }; } }
public Rank GetHighestRankAchieved(int CustomerID) { var result = new Rank(); var response = GetContext().Customers .Where(c => c.CustomerID == CustomerID) .Select(c => new { RankID = c.RankID, RankDescription = c.Rank.RankDescription }) .FirstOrDefault(); if (response == null) { return(null); } result.RankID = response.RankID; result.RankDescription = GlobalUtilities.Coalesce(response.RankDescription, "Unknown"); return(result); }
public void Fail(string errormessage = "") { Status = false; ErrorMessage = GlobalUtilities.Coalesce(errormessage, "Invalid username/password"); }
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)); }
/// <summary> /// Gets a formatted display name based on the company's rules. The default setting is that if a company name is found display the company name; otherwise, display the first and last name. /// </summary> /// <returns>The formatted display name.</returns> public static string GetDisplayName(string companyName, string firstName, string lastName) { return(GlobalUtilities.Coalesce(companyName, firstName + " " + lastName)); }
public void Fail(string errorMessage = "") { this.Success = false; this.ErrorMessage = GlobalUtilities.Coalesce(errorMessage, "Failed"); }