/// <param name="guid"> guid </param> public async Task <IGeoCountry> FetchCountry(Guid guid) { using (DbDataReader reader = dbGeoCountry.GetOne(guid)) { if (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); LoadFromReader(reader, geoCountry); return(geoCountry); } } return(null); }
public async Task <IGeoCountry> FetchCountry(string isoCode2) { using (DbDataReader reader = dbGeoCountry.GetByISOCode2(isoCode2)) { if (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); LoadFromReader(reader, geoCountry); return(geoCountry); } } return(null); }
public async Task <IGeoCountry> FetchCountry(string isoCode2, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); using (DbDataReader reader = await dbGeoCountry.GetByISOCode2(isoCode2)) { if (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); LoadFromReader(reader, geoCountry); return(geoCountry); } } return(null); }
/// <param name="guid"> guid </param> public async Task <IGeoCountry> FetchCountry(Guid guid, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); using (DbDataReader reader = dbGeoCountry.GetOne(guid)) { if (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); LoadFromReader(reader, geoCountry); return(geoCountry); } } return(null); }
private List <IGeoCountry> LoadCountryListFromReader(DbDataReader reader) { List <IGeoCountry> geoCountryList = new List <IGeoCountry>(); using (reader) { while (reader.Read()) { GeoCountry geoCountry = new GeoCountry(); LoadFromReader(reader, geoCountry); geoCountryList.Add(geoCountry); } } return(geoCountryList); }
public void CalculateTax(Cart cart) { // TODO: this doesn't take into account discounts decimal taxAmount = 0; if (cart.OrderInfo.TaxZoneGuid == Guid.Empty) { GeoCountry country = new GeoCountry(cart.OrderInfo.BillingCountry); GeoZone taxZone = GeoZone.GetByCode(country.Guid, cart.OrderInfo.BillingState); if (taxZone != null) { cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } if (cart.OrderInfo.TaxZoneGuid != Guid.Empty) { Collection <TaxRate> taxRates = TaxRate.GetTaxRates(this.SiteGuid, cart.OrderInfo.TaxZoneGuid); if (taxRates.Count > 0) { foreach (CartOffer offer in cart.CartOffers) { offer.Tax = 0; foreach (TaxRate taxRate in taxRates) { if (offer.TaxClassGuid == taxRate.TaxClassGuid) { offer.Tax += (taxRate.Rate * (offer.OfferPrice * offer.Quantity)); offer.Save(); taxAmount += offer.Tax; //break; } } } } } cart.TaxTotal = Math.Round(taxAmount, this.RoundingDecimalPlaces, this.RoundingMode); if (cart.TaxTotal < 0) { cart.TaxTotal = 0; } cart.Save(); }
private void LoadDemoCustomer() { // this is for the demo site so users don't have to fill out customer info to try the store if (cart.OrderInfo.CustomerFirstName.Length > 0) { return; } //data already initialized GeoCountry country; GeoZone taxZone; cart.OrderInfo.CustomerFirstName = "John"; cart.OrderInfo.CustomerLastName = "Doe"; cart.OrderInfo.CustomerEmail = "*****@*****.**"; cart.OrderInfo.CustomerAddressLine1 = "123 Any St."; cart.OrderInfo.CustomerCity = "Anytown"; cart.OrderInfo.CustomerPostalCode = "12345"; cart.OrderInfo.CustomerState = "NC"; cart.OrderInfo.CustomerCountry = "US"; cart.OrderInfo.CustomerTelephoneDay = "123-234-3456"; if (cart.OrderInfo.CustomerState.Length > 0) { country = new GeoCountry(cart.OrderInfo.CustomerCountry); taxZone = GeoZone.GetByCode(country.Guid, cart.OrderInfo.CustomerState); if (taxZone != null) { cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } cart.CopyCustomerToShipping(); cart.CopyCustomerToBilling(); cart.OrderInfo.Save(); cart.RefreshTotals(); }
private void BindCountryList() { DataTable dataTable = GeoCountry.GetList(); ddCountry.DataSource = dataTable; ddCountry.DataBind(); if ((!Page.IsPostBack) && (countryGuid != Guid.Empty) ) { ListItem listItem = ddCountry.Items.FindByValue(countryGuid.ToString()); if (listItem != null) { ddCountry.ClearSelection(); listItem.Selected = true; } } }
public async Task GetGeoCountry_ShouldReturnGeoCountryDetails() { // Arrange var id = 1; var geoCountry = new GeoCountry { CountryName = "Australia" }; Mock.Mock <IGeoLocationService>().Setup(x => x.GetGeoCountry(id)).ReturnsAsync(geoCountry); // Act var results = await Controller.GetGeoCountry(id); // Assert Assert.That(results, Is.Not.Null); Assert.That(results, Is.TypeOf <OkNegotiatedContentResult <GeoCountryViewModel> >()); var content = ((OkNegotiatedContentResult <GeoCountryViewModel>)results).Content; Assert.That(content.CountryName, Is.EqualTo(geoCountry.CountryName)); }
private async Task InsertAsync(uint count, List <string> usersId, GeoCountry geo) { var jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = false, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic) }; var discountData = new FakeDiscounts().Get(count, usersId, geo); foreach (var dbDiscount in discountData) { var value = JsonSerializer.Serialize(dbDiscount, jsonSerializerOptions).Replace("\"id\":", "\"_id\":") + ","; await File.AppendAllTextAsync(FullName, value); _counter++; } }
public async Task <bool> Update(IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return(false); } GeoCountry country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry bool tracking = dbContext.ChangeTracker.Entries <GeoCountry>().Any(x => x.Entity.Guid == country.Guid); if (!tracking) { dbContext.Countries.Update(country); } int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return(rowsAffected > 0); }
public async Task <bool> Add(IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken)) { if (geoCountry == null) { return(false); } GeoCountry country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry if (country.Guid == Guid.Empty) { country.Guid = Guid.NewGuid(); } dbContext.Countries.Add(country); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken); return(rowsAffected > 0); }
private void BindCustomerGeoZoneList() { if ((ddCustomerCountry.SelectedIndex > -1) && (ddCustomerCountry.SelectedValue.Length > 0) ) { GeoCountry country = new GeoCountry(ddCustomerCountry.SelectedValue); if (country.Guid == Guid.Empty) { return; } using (IDataReader reader = GeoZone.GetByCountry(country.Guid)) { ddCustomerGeoZone.DataSource = reader; ddCustomerGeoZone.DataBind(); } divCustomerState.Visible = (ddCustomerGeoZone.Items.Count > 0); } }
public async Task Add( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoCountry == null) { throw new ArgumentException("geoCountry must not be null"); } if (geoCountry.Id == Guid.Empty) { throw new ArgumentException("geoCountry must have a non-empty id"); } var country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry dbContext.Countries.Add(country); int rowsAffected = await dbContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }
public static string Name(this GeoCountry value) { return(XEnum <GeoCountry> .Name((int)value)); }
private void LoadSettings() { store = StoreHelper.GetStore(); if (store == null) { return; } commerceConfig = SiteUtils.GetCommerceConfig(); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); storeCountry = new GeoCountry(siteSettings.DefaultCountryGuid); if (Request.IsAuthenticated) { siteUser = SiteUtils.GetCurrentSiteUser(); } if (StoreHelper.UserHasCartCookie(store.Guid)) { cart = StoreHelper.GetCart(); if (cart != null) { if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0)) { StoreHelper.EnsureValidDiscounts(store, cart); } if (siteUser != null) { if (cart.UserGuid == Guid.Empty) { // take ownership of anonymous cart cart.UserGuid = siteUser.UserGuid; cart.Save(); StoreHelper.InitializeOrderInfo(cart, siteUser); } else { // cart already has a user guid but // check if it matches the current user // cart cookie could have been left behind by a previous user // on shared computers // if cart user guid doesn't match reset billing shipping info // and any other identifiers // but leave items in cart if (cart.UserGuid != siteUser.UserGuid) { cart.ResetUserInfo(); cart.UserGuid = siteUser.UserGuid; cart.Save(); StoreHelper.InitializeOrderInfo(cart, siteUser); } } } if (WebStoreConfiguration.IsDemo) { LoadDemoCustomer(); } canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart); // disable till I finish //canCheckoutWithoutAuthentication = false; } AddClassToBody("webstore webstoreconfirmorder"); } pnlRequireLogin.Visible = !Request.IsAuthenticated; if ((canCheckoutWithoutAuthentication) || (Request.IsAuthenticated)) { pnlOrderDetail.Visible = commerceConfig.CanProcessStandardCards || (commerceConfig.WorldPayInstallationId.Length > 0); pnlRequireLogin.Visible = true; pnlShippingTotal.Visible = false; pnlTaxTotal.Visible = false; pnlOrderTotal.Visible = false; } if ((cart != null) && (cart.SubTotal == 0) && (cart.CartOffers.Count > 0)) { // free checkout pnlOrderDetail.Visible = true; } if (pnlOrderDetail.Visible) { tblCountryList = GeoCountry.GetList(); } ConfigureCheckoutButtons(); //if (!Page.IsPostBack) //{ // if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard)) // { // if (Request.IsAuthenticated) // { // SetupPayPalStandardForm(); // } // else // { // // we need the user to be signed in before we send them to paypal if using PayPal Standard // // because we want to return them to their order summary and that requires login // // so we need to know who the user is before sending them to PayPal // litOr.Visible = false; // btnPayPal.Visible = false; // btnGoogleCheckout.Visible = false; // } // } //} //if (!Request.IsAuthenticated) //{ // pnlOrderDetail.Visible = false; // pnlRequireLogin.Visible = true; // pnlShippingTotal.Visible = false; // pnlTaxTotal.Visible = false; // pnlOrderTotal.Visible = false; // if (commerceConfig.GoogleCheckoutIsEnabled) // { // if ( // (!commerceConfig.Is503TaxExempt) // && ((cart != null) && (cart.HasDonations())) // ) // { // //btnGoogleCheckout.Visible = false; // lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage; // lblGoogleMessage.Visible = true; // PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1; // mark.SuppressGoogleCheckout = true; // mark = (PaymentAcceptanceMark)PaymentAcceptanceMark1; // mark.SuppressGoogleCheckout = true; // btnGoogleCheckout.Visible = true; // btnGoogleCheckout.Enabled = false; // } // } //} //else //{ // if ( // (!commerceConfig.Is503TaxExempt) // && ((cart != null)&& (cart.HasDonations())) // && (commerceConfig.GoogleCheckoutIsEnabled) // ) // { // btnGoogleCheckout.Visible = true; // btnGoogleCheckout.Enabled = false; // lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage; // lblGoogleMessage.Visible = true; // } //} }
public IEnumerable <DbDiscount> Get(uint count, List <string> listUserId, GeoCountry geo) { var locationGenerator = new Faker <DbLocation>("ru") .RuleFor(x => x.Latitude, f => f.Address.Latitude()) .RuleFor(x => x.Longitude, f => f.Address.Longitude()) ; var dbLocation = locationGenerator.Generate(); var companyGenerator = new Faker <DbCompany>("ru") .RuleFor(x => x.Name, f => f.Company.CompanyName()) .RuleFor(x => x.Description, f => string.Join(" ", f.Commerce.Categories(15).Distinct().ToList())) .RuleFor(x => x.PhoneNumber, f => f.Phone.PhoneNumber("+!!! !! !!!-!!-!!")) .RuleFor(x => x.Mail, f => f.Person.Email) ; var streetRu = new Faker <ValueString>("ru") .RuleFor(x => x.Value, x => x.Address.StreetAddress()) .Generate(); var addressRu = new DbAddress() { Country = geo.CountryRu, City = geo.CityRu, Street = streetRu.Value, Location = dbLocation } ; var dbUserGenerator = new Faker <DbUser>("ru") .RuleFor(x => x.Id, f => Guid.NewGuid().ToString()) .RuleFor(x => x.Name, f => f.Person.FirstName) .RuleFor(x => x.Surname, f => f.Person.LastName) .RuleFor(x => x.PhoneNumber, f => f.Phone.PhoneNumber("+!!! !! !!!-!!-!!")) .RuleFor(x => x.Mail, f => f.Person.Email) ; var companyTranslationGenerator = new Faker <DbTranslationCompany>("en") .RuleFor(x => x.Name, f => f.Company.CompanyName()) .RuleFor(x => x.Description, f => f.Commerce.ProductDescription()) ; var streetEn = new Faker <ValueString>("en") .RuleFor(x => x.Value, x => x.Address.StreetAddress()) .Generate(); var addressEn = new DbTranslationAddress() { Country = geo.CountryEn, City = geo.CityEn, Street = streetEn.Value } ; var translationGenerator = new Faker <DbTranslation>("en") .RuleFor(x => x.Language, f => "english") .RuleFor(x => x.Name, f => f.Commerce.ProductName()) .RuleFor(x => x.Description, f => f.Commerce.ProductDescription()) .RuleFor(x => x.Address, f => addressEn) .RuleFor(x => x.Company, f => companyTranslationGenerator.Generate()) .RuleFor(x => x.Tags, f => f.Commerce.Categories(15).Distinct().ToList()) ; var promocodeOptionGenerator = new Faker <DbPromocodeOptions>() .RuleFor(x => x.EnabledPromocodes, f => f.Random.Bool()) .RuleFor(x => x.CountActivePromocodePerUser, f => f.Random.Int(1, 5)) .RuleFor(x => x.CountSymbolsPromocode, f => f.Random.Int(4, 7)) .RuleFor(x => x.DaysDurationPromocode, f => f.Random.Int(5, 15)) .RuleFor(x => x.TimeLimitAddingInSeconds, f => f.Random.Int(1, 5)) ; var discountGenerator = new Faker <DbDiscount>("ru") .StrictMode(true) .RuleFor(x => x.Id, f => Guid.NewGuid().ToString()) .RuleFor(x => x.Name, f => f.Commerce.ProductName()) .RuleFor(x => x.Description, f => string.Join(" ", f.Commerce.Categories(15).Distinct().ToList())) .RuleFor(x => x.AmountOfDiscount, f => f.Random.Int(500, 7000) / 100) .RuleFor(x => x.StartDate, f => f.Date.Between(DateTime.Now - TimeSpan.FromDays(700), DateTime.Now)) .RuleFor(x => x.EndDate, f => f.Date.Between(DateTime.Now + TimeSpan.FromDays(1), DateTime.Now + TimeSpan.FromDays(700))) .RuleFor(x => x.Address, f => addressRu) .RuleFor(x => x.Company, f => companyGenerator.Generate()) .RuleFor(x => x.PictureUrl, f => f.Image.LoremFlickrUrl()) .RuleFor(x => x.WorkingDaysOfTheWeek, f => string.Join("", f.Random.Int(0, 1), f.Random.Int(0, 1), f.Random.Int(0, 1), f.Random.Int(0, 1), f.Random.Int(0, 1), f.Random.Int(0, 1), f.Random.Int(0, 1))) .RuleFor(x => x.Tags, f => f.Commerce.Categories(15).Distinct().ToList()) .RuleFor(x => x.RatingTotal, f => f.Random.Int(0, 4) + f.Random.Int(1, 9) / 10) .RuleFor(x => x.ViewsTotal, f => f.Random.Int(0, 100)) .RuleFor(x => x.UsersSubscriptionTotal, f => f.Random.Int(0, 50)) .RuleFor(x => x.SubscriptionsTotal, f => f.Random.Int(0, 50)) .RuleFor(x => x.Language, f => "russian") .RuleFor(x => x.Deleted, f => false) .RuleFor(x => x.CreateDate, f => f.Date.Between(DateTime.Now - TimeSpan.FromDays(700), DateTime.Now - TimeSpan.FromDays(60))) .RuleFor(x => x.LastChangeDate, f => f.Date.Between(DateTime.Now - TimeSpan.FromDays(60), DateTime.Now)) .RuleFor(x => x.UserCreateDate, f => dbUserGenerator.Generate()) .RuleFor(x => x.UserLastChangeDate, f => dbUserGenerator.Generate()) .RuleFor(x => x.UsersPromocodes, f => null) .RuleFor(x => x.FavoritesUsersId, f => RandomFromListUserId(listUserId, 3)) .RuleFor(x => x.RatingUsersId, f => RandomFromListUserId(listUserId, 5)) .RuleFor(x => x.Translations, f => translationGenerator.Generate(1)) .RuleFor(x => x.PromocodeOptions, f => promocodeOptionGenerator.Generate()) ; for (var i = 0; i < count; i++) { yield return(discountGenerator.Generate()); } }
public override string HandleRequestAndReturnUrlForRedirect( HttpContext context, string payPalToken, string payPalPayerId, PayPalLog setExpressCheckoutLog) { string redirectUrl = string.Empty; if ((payPalToken == null) || (payPalToken.Length == 0)) { log.Error("WebStorePayPalReturnHandler received empty payPalToken"); return(redirectUrl); } if (setExpressCheckoutLog == null) { log.Error("WebStorePayPalReturnHandler received null setExpressCheckoutLog for payPalToken " + payPalToken); return(redirectUrl); } if (setExpressCheckoutLog.SerializedObject.Length == 0) { log.Error("WebStorePayPalReturnHandler cart was not previously serialized for payPalToken " + payPalToken); return(redirectUrl); } if (setExpressCheckoutLog.CreatedUtc.AddHours(4) < DateTime.UtcNow) { log.Error("payPalToken " + payPalToken + " was more than 4 hours old, it should expire after 3 hours "); return(redirectUrl); } CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); PayPalExpressGateway gateway = new PayPalExpressGateway( commerceConfig.PayPalAPIUsername, commerceConfig.PayPalAPIPassword, commerceConfig.PayPalAPISignature, commerceConfig.PayPalStandardEmailAddress); gateway.UseTestMode = commerceConfig.PaymentGatewayUseTestMode; gateway.PayPalToken = payPalToken; gateway.PayPalPayerId = payPalPayerId; Cart savedCart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), setExpressCheckoutLog.SerializedObject); savedCart.DeSerializeCartOffers(); string siteRoot = SiteUtils.GetNavigationSiteRoot(); gateway.MerchantCartId = savedCart.CartGuid.ToString(); gateway.ChargeTotal = savedCart.OrderTotal; gateway.ReturnUrl = siteRoot + "/Services/PayPalReturnHandler.ashx"; gateway.CancelUrl = siteRoot; //gateway.PayPalPayerId = payPalPayerId; gateway.CallGetExpressCheckoutDetails(); PayPalLog payPalLog = new PayPalLog(); payPalLog.ProviderName = WebStorePayPalReturnHandler.ProviderName; payPalLog.SerializedObject = setExpressCheckoutLog.SerializedObject; payPalLog.ReturnUrl = setExpressCheckoutLog.ReturnUrl; payPalLog.RawResponse = gateway.RawResponse; payPalLog.TransactionId = gateway.TransactionId; payPalLog.CurrencyCode = gateway.CurrencyCode; // TODO: add versions to gateways //log.ApiVersion = gateway. payPalLog.CartGuid = savedCart.CartGuid; Store store = new Store(savedCart.StoreGuid); payPalLog.Token = payPalToken; payPalLog.PayerId = payPalPayerId; payPalLog.RequestType = "GetExpressCheckoutDetails"; payPalLog.SiteGuid = store.SiteGuid; payPalLog.StoreGuid = store.Guid; payPalLog.UserGuid = savedCart.UserGuid; // update the order with customer shipping info savedCart.OrderInfo.DeliveryCompany = gateway.ShipToCompanyName; savedCart.OrderInfo.DeliveryAddress1 = gateway.ShipToAddress; savedCart.OrderInfo.DeliveryAddress2 = gateway.ShipToAddress2; savedCart.OrderInfo.DeliveryCity = gateway.ShipToCity; savedCart.OrderInfo.DeliveryFirstName = gateway.ShipToFirstName; savedCart.OrderInfo.DeliveryLastName = gateway.ShipToLastName; savedCart.OrderInfo.DeliveryPostalCode = gateway.ShipToPostalCode; savedCart.OrderInfo.DeliveryState = gateway.ShipToState; savedCart.OrderInfo.DeliveryCountry = gateway.ShipToCountry; //Note that PayPal only returns a phone number if your Merchant accounts is configured to require the // buyer to provide it. if (gateway.ShipToPhone.Length > 0) { savedCart.OrderInfo.CustomerTelephoneDay = gateway.ShipToPhone; } if (gateway.BuyerEmail.Length > 0) { savedCart.OrderInfo.CustomerEmail = gateway.BuyerEmail; } // if customer and billing aren't populated already, user was anonymous when checkout began, make them the same as shipping //if (savedCart.UserGuid == Guid.Empty) //{ //2013-12-23 since all we get is shipping address this can be considered as the same thing as billing address for paypal purposes so always use it // especially because we may need to calculate tax for express checkout // based on the address provided by paypal savedCart.CopyShippingToBilling(); savedCart.CopyShippingToCustomer(); //} GeoCountry country = new GeoCountry(savedCart.OrderInfo.DeliveryCountry); GeoZone taxZone = GeoZone.GetByCode(country.Guid, savedCart.OrderInfo.DeliveryState); savedCart.OrderInfo.TaxZoneGuid = taxZone.Guid; savedCart.OrderInfo.Save(); // refresh totals to calculate tax or shipping now that we have an address savedCart.RefreshTotals(); savedCart.Save(); savedCart.SerializeCartOffers(); payPalLog.SerializedObject = SerializationHelper.SerializeToString(savedCart); payPalLog.Save(); if (gateway.Response == PaymentGatewayResponse.Error) { redirectUrl = siteRoot + "/WebStore/PayPalGatewayError.aspx?plog=" + payPalLog.RowGuid.ToString(); return(redirectUrl); } if (gateway.PayPalPayerId.Length == 0) { redirectUrl = siteRoot + "/WebStore/PayPalGatewayError.aspx?plog=" + payPalLog.RowGuid.ToString(); return(redirectUrl); } int pageId = -1; List <PageModule> pageModules = PageModule.GetPageModulesByModule(store.ModuleId); foreach (PageModule pm in pageModules) { // use first pageid found, really a store should only // be on one page pageId = pm.PageId; break; } // after the CallGetExpressCheckoutDetails // we have the option of directing to a final review page before // calling CallDoExpressCheckoutPayment redirectUrl = siteRoot + "/WebStore/PayPalExpressCheckout.aspx?pageid=" + pageId.ToString(CultureInfo.InvariantCulture) + "&mid=" + store.ModuleId.ToString(CultureInfo.InvariantCulture) + "&plog=" + payPalLog.RowGuid.ToString(); return(redirectUrl); }
private void SaveCartDetail() { if (cart == null) { return; } GeoCountry country; GeoZone taxZone; cart.OrderInfo.CustomerFirstName = txtCustomerFirstName.Text; cart.OrderInfo.CustomerLastName = txtCustomerLastName.Text; cart.OrderInfo.CustomerCompany = txtCustomerCompany.Text; cart.OrderInfo.CustomerAddressLine1 = txtCustomerAddressLine1.Text; cart.OrderInfo.CustomerAddressLine2 = txtCustomerAddressLine2.Text; cart.OrderInfo.CustomerSuburb = txtCustomerSuburb.Text; cart.OrderInfo.CustomerCity = txtCustomerCity.Text; cart.OrderInfo.CustomerPostalCode = txtCustomerPostalCode.Text; if (ddCustomerGeoZone.SelectedIndex > -1) { cart.OrderInfo.CustomerState = ddCustomerGeoZone.SelectedItem.Value; } else { cart.OrderInfo.CustomerState = string.Empty; } cart.OrderInfo.CustomerCountry = ddCustomerCountry.SelectedItem.Value; cart.OrderInfo.CustomerTelephoneDay = txtCustomerTelephoneDay.Text; cart.OrderInfo.CustomerTelephoneNight = txtCustomerTelephoneNight.Text; cart.OrderInfo.CustomerEmail = txtCustomerEmail.Text; if (ddCustomerGeoZone.SelectedIndex > -1) { country = new GeoCountry(cart.OrderInfo.CustomerCountry); taxZone = GeoZone.GetByCode(country.Guid, ddCustomerGeoZone.SelectedValue); cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } if (pnlShipping.Visible) { cart.OrderInfo.DeliveryFirstName = txtDeliveryFirstName.Text; cart.OrderInfo.DeliveryLastName = txtDeliveryLastName.Text; cart.OrderInfo.DeliveryCompany = txtDeliveryCompany.Text; cart.OrderInfo.DeliveryAddress1 = txtDeliveryAddress1.Text; cart.OrderInfo.DeliveryAddress2 = txtDeliveryAddress2.Text; cart.OrderInfo.DeliverySuburb = txtDeliverySuburb.Text; cart.OrderInfo.DeliveryCity = txtDeliveryCity.Text; cart.OrderInfo.DeliveryPostalCode = txtDeliveryPostalCode.Text; if (ddDeliveryGeoZone.SelectedIndex > -1) { cart.OrderInfo.DeliveryState = ddDeliveryGeoZone.SelectedItem.Value; } else { cart.OrderInfo.DeliveryState = string.Empty; } cart.OrderInfo.DeliveryCountry = ddDeliveryCountry.SelectedItem.Value; if (ddDeliveryGeoZone.SelectedIndex > -1) { country = new GeoCountry(cart.OrderInfo.DeliveryCountry); taxZone = GeoZone.GetByCode(country.Guid, ddDeliveryGeoZone.SelectedValue); cart.OrderInfo.TaxZoneGuid = taxZone.Guid; } } else { cart.CopyCustomerToShipping(); } cart.CopyCustomerToBilling(); cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); cart.OrderInfo.Save(); cart.RefreshTotals(); }
private static void InitCountryEnum(ref IDictionary <string, GeoCountry> allCountryNamesDict) { var _d = new Dictionary <GeoCountry, string>(240) { { GeoCountry.None, "None" }, { GeoCountry.Afghanistan, "Afghanistan" }, { GeoCountry.Albania, "Albania" }, { GeoCountry.Algeria, "Algeria" }, { GeoCountry.American_Samoa, "American Samoa" }, { GeoCountry.Andorra, "Andorra" }, { GeoCountry.Angola, "Angola" }, { GeoCountry.Anguilla, "Anguilla" }, { GeoCountry.Antarctica, "Antarctica" }, { GeoCountry.Antigua_and_Barbuda, "Antigua and Barbuda" }, { GeoCountry.Argentina, "Argentina" }, { GeoCountry.Armenia, "Armenia" }, { GeoCountry.Aruba, "Aruba" }, { GeoCountry.Australia, "Australia" }, { GeoCountry.Austria, "Austria" }, { GeoCountry.Azerbaijan, "Azerbaijan" }, { GeoCountry.Bahamas, "Bahamas" }, { GeoCountry.Bahrain, "Bahrain" }, { GeoCountry.Bangladesh, "Bangladesh" }, { GeoCountry.Barbados, "Barbados" }, { GeoCountry.Belarus, "Belarus" }, { GeoCountry.Belgium, "Belgium" }, { GeoCountry.Belize, "Belize" }, { GeoCountry.Benin, "Benin" }, { GeoCountry.Bermuda, "Bermuda" }, { GeoCountry.Bhutan, "Bhutan" }, { GeoCountry.Bolivia, "Bolivia" }, { GeoCountry.Bosnia_and_Herzegovina, "Bosnia and Herzegovina" }, { GeoCountry.Botswana, "Botswana" }, { GeoCountry.Bouvet_Island, "Bouvet Island" }, { GeoCountry.Brazil, "Brazil" }, { GeoCountry.British_Indian_Ocean_Territory, "British Indian Ocean Territory" }, { GeoCountry.Brunei_Darussalam, "Brunei Darussalam" }, { GeoCountry.Bulgaria, "Bulgaria" }, { GeoCountry.Burkina_Faso, "Burkina Faso" }, { GeoCountry.Burundi, "Burundi" }, { GeoCountry.Cambodia, "Cambodia" }, { GeoCountry.Cameroon, "Cameroon" }, { GeoCountry.Canada, "Canada" }, { GeoCountry.Cape_Verde, "Cape Verde" }, { GeoCountry.Cayman_Islands, "Cayman Islands" }, { GeoCountry.Central_African_Republic, "Central African Republic" }, { GeoCountry.Chad, "Chad" }, { GeoCountry.Chile, "Chile" }, { GeoCountry.China, "China" }, { GeoCountry.Christmas_Island, "Christmas Island" }, { GeoCountry.Cocos_Keeling_Islands, "Cocos (Keeling Islands)" }, { GeoCountry.Colombia, "Colombia" }, { GeoCountry.Comoros, "Comoros" }, { GeoCountry.Congo, "Congo" }, { GeoCountry.Cook_Islands, "Cook Islands" }, { GeoCountry.Costa_Rica, "Costa Rica" }, { GeoCountry.Cote_DIvoire_Ivory_Coast, "Cote D'Ivoire (Ivory Coast)" }, { GeoCountry.Croatia_Hrvatska, "Croatia (Hrvatska)" }, { GeoCountry.Cuba, "Cuba" }, { GeoCountry.Cyprus, "Cyprus" }, { GeoCountry.Czech_Republic, "Czech Republic" }, { GeoCountry.Denmark, "Denmark" }, { GeoCountry.Djibouti, "Djibouti" }, { GeoCountry.Dominica, "Dominica" }, { GeoCountry.Dominican_Republic, "Dominican Republic" }, { GeoCountry.East_Timor, "East Timor" }, { GeoCountry.Ecuador, "Ecuador" }, { GeoCountry.Egypt, "Egypt" }, { GeoCountry.El_Salvador, "El Salvador" }, { GeoCountry.Equatorial_Guinea, "Equatorial Guinea" }, { GeoCountry.Eritrea, "Eritrea" }, { GeoCountry.Estonia, "Estonia" }, { GeoCountry.Ethiopia, "Ethiopia" }, { GeoCountry.Falkland_Islands_Malvinas, "Falkland Islands (Malvinas)" }, { GeoCountry.Faroe_Islands, "Faroe Islands" }, { GeoCountry.Fiji, "Fiji" }, { GeoCountry.Finland, "Finland" }, { GeoCountry.France, "France" }, { GeoCountry.France_Metropolitan, "France, Metropolitan" }, { GeoCountry.French_Guiana, "French Guiana" }, { GeoCountry.French_Polynesia, "French Polynesia" }, { GeoCountry.French_Southern_Territories, "French Southern Territories" }, { GeoCountry.Gabon, "Gabon" }, { GeoCountry.Gambia, "Gambia" }, { GeoCountry.Georgia, "Georgia" }, { GeoCountry.Germany, "Germany" }, { GeoCountry.Ghana, "Ghana" }, { GeoCountry.Gibraltar, "Gibraltar" }, { GeoCountry.Greece, "Greece" }, { GeoCountry.Greenland, "Greenland" }, { GeoCountry.Grenada, "Grenada" }, { GeoCountry.Guadeloupe, "Guadeloupe" }, { GeoCountry.Guam, "Guam" }, { GeoCountry.Guatemala, "Guatemala" }, { GeoCountry.Guinea, "Guinea" }, { GeoCountry.GuineaBissau, "Guinea-Bissau" }, { GeoCountry.Guyana, "Guyana" }, { GeoCountry.Haiti, "Haiti" }, { GeoCountry.Heard_and_McDonald_Islands, "Heard and McDonald Islands" }, { GeoCountry.Honduras, "Honduras" }, { GeoCountry.Hong_Kong, "Hong Kong" }, { GeoCountry.Hungary, "Hungary" }, { GeoCountry.Iceland, "Iceland" }, { GeoCountry.India, "India" }, { GeoCountry.Indonesia, "Indonesia" }, { GeoCountry.Iran, "Iran" }, { GeoCountry.Iraq, "Iraq" }, { GeoCountry.Ireland, "Ireland" }, { GeoCountry.Israel, "Israel" }, { GeoCountry.Italy, "Italy" }, { GeoCountry.Jamaica, "Jamaica" }, { GeoCountry.Japan, "Japan" }, { GeoCountry.Jordan, "Jordan" }, { GeoCountry.Kazakhstan, "Kazakhstan" }, { GeoCountry.Kenya, "Kenya" }, { GeoCountry.Kiribati, "Kiribati" }, { GeoCountry.Kuwait, "Kuwait" }, { GeoCountry.Kyrgyzstan, "Kyrgyzstan" }, { GeoCountry.Laos, "Laos" }, { GeoCountry.Latvia, "Latvia" }, { GeoCountry.Lebanon, "Lebanon" }, { GeoCountry.Lesotho, "Lesotho" }, { GeoCountry.Liberia, "Liberia" }, { GeoCountry.Libya, "Libya" }, { GeoCountry.Liechtenstein, "Liechtenstein" }, { GeoCountry.Lithuania, "Lithuania" }, { GeoCountry.Luxembourg, "Luxembourg" }, { GeoCountry.Macau, "Macau" }, { GeoCountry.Macedonia, "Macedonia" }, { GeoCountry.Madagascar, "Madagascar" }, { GeoCountry.Malawi, "Malawi" }, { GeoCountry.Malaysia, "Malaysia" }, { GeoCountry.Maldives, "Maldives" }, { GeoCountry.Mali, "Mali" }, { GeoCountry.Malta, "Malta" }, { GeoCountry.Marshall_Islands, "Marshall Islands" }, { GeoCountry.Martinique, "Martinique" }, { GeoCountry.Mauritania, "Mauritania" }, { GeoCountry.Mauritius, "Mauritius" }, { GeoCountry.Mayotte, "Mayotte" }, { GeoCountry.Mexico, "Mexico" }, { GeoCountry.Micronesia, "Micronesia" }, { GeoCountry.Moldova, "Moldova" }, { GeoCountry.Monaco, "Monaco" }, { GeoCountry.Mongolia, "Mongolia" }, { GeoCountry.Montserrat, "Montserrat" }, { GeoCountry.Morocco, "Morocco" }, { GeoCountry.Mozambique, "Mozambique" }, { GeoCountry.Myanmar, "Myanmar" }, { GeoCountry.Namibia, "Namibia" }, { GeoCountry.Nauru, "Nauru" }, { GeoCountry.Nepal, "Nepal" }, { GeoCountry.Netherlands, "Netherlands" }, { GeoCountry.Netherlands_Antilles, "Netherlands Antilles" }, { GeoCountry.New_Caledonia, "New Caledonia" }, { GeoCountry.New_Zealand, "New Zealand" }, { GeoCountry.Nicaragua, "Nicaragua" }, { GeoCountry.Niger, "Niger" }, { GeoCountry.Nigeria, "Nigeria" }, { GeoCountry.Niue, "Niue" }, { GeoCountry.Norfolk_Island, "Norfolk Island" }, { GeoCountry.North_Korea, "North Korea" }, { GeoCountry.Northern_Mariana_Islands, "Northern Mariana Islands" }, { GeoCountry.Norway, "Norway" }, { GeoCountry.Oman, "Oman" }, { GeoCountry.Pakistan, "Pakistan" }, { GeoCountry.Palau, "Palau" }, { GeoCountry.Panama, "Panama" }, { GeoCountry.Papua_New_Guinea, "Papua New Guinea" }, { GeoCountry.Paraguay, "Paraguay" }, { GeoCountry.Peru, "Peru" }, { GeoCountry.Philippines, "Philippines" }, { GeoCountry.Pitcairn, "Pitcairn" }, { GeoCountry.Poland, "Poland" }, { GeoCountry.Portugal, "Portugal" }, { GeoCountry.Puerto_Rico, "Puerto Rico" }, { GeoCountry.Qatar, "Qatar" }, { GeoCountry.Reunion, "Reunion" }, { GeoCountry.Romania, "Romania" }, { GeoCountry.Russian_Federation, "Russian Federation" }, { GeoCountry.Rwanda, "Rwanda" }, { GeoCountry.S_Georgia_and_S_Sandwich_Isls, "S. Georgia and S. Sandwich Isls." }, { GeoCountry.Saint_Kitts_and_Nevis, "Saint Kitts and Nevis" }, { GeoCountry.Saint_Lucia, "Saint Lucia" }, { GeoCountry.Saint_Vincent_and_The_Grenadines, "Saint Vincent and The Grenadines" }, { GeoCountry.Samoa, "Samoa" }, { GeoCountry.San_Marino, "San Marino" }, { GeoCountry.Sao_Tome_and_Principe, "Sao Tome and Principe" }, { GeoCountry.Saudi_Arabia, "Saudi Arabia" }, { GeoCountry.Senegal, "Senegal" }, { GeoCountry.Seychelles, "Seychelles" }, { GeoCountry.Sierra_Leone, "Sierra Leone" }, { GeoCountry.Singapore, "Singapore" }, { GeoCountry.Slovak_Republic, "Slovak Republic" }, { GeoCountry.Slovenia, "Slovenia" }, { GeoCountry.Solomon_Islands, "Solomon Islands" }, { GeoCountry.Somalia, "Somalia" }, { GeoCountry.Sourth_Korea, "Sourth Korea" }, { GeoCountry.South_Africa, "South Africa" }, { GeoCountry.Spain, "Spain" }, { GeoCountry.Sri_Lanka, "Sri Lanka" }, { GeoCountry.St_Helena, "St. Helena" }, { GeoCountry.St_Pierre_and_Miquelon, "St. Pierre and Miquelon" }, { GeoCountry.Sudan, "Sudan" }, { GeoCountry.Suriname, "Suriname" }, { GeoCountry.Svalbard_and_Jan_Mayen_Islands, "Svalbard and Jan Mayen Islands" }, { GeoCountry.Swaziland, "Swaziland" }, { GeoCountry.Sweden, "Sweden" }, { GeoCountry.Switzerland, "Switzerland" }, { GeoCountry.Syria, "Syria" }, { GeoCountry.Taiwan, "Taiwan" }, { GeoCountry.Tajikistan, "Tajikistan" }, { GeoCountry.Tanzania, "Tanzania" }, { GeoCountry.Thailand, "Thailand" }, { GeoCountry.Togo, "Togo" }, { GeoCountry.Tokelau, "Tokelau" }, { GeoCountry.Tonga, "Tonga" }, { GeoCountry.Trinidad_and_Tobago, "Trinidad and Tobago" }, { GeoCountry.Tunisia, "Tunisia" }, { GeoCountry.Turkey, "Turkey" }, { GeoCountry.Turkmenistan, "Turkmenistan" }, { GeoCountry.Turks_and_Caicos_Islands, "Turks and Caicos Islands" }, { GeoCountry.Tuvalu, "Tuvalu" }, { GeoCountry.Uganda, "Uganda" }, { GeoCountry.Ukraine, "Ukraine" }, { GeoCountry.United_Arab_Emirates, "United Arab Emirates" }, { GeoCountry.United_Kingdom, "United Kingdom" }, { GeoCountry.United_States, "United States" }, { GeoCountry.Uruguay, "Uruguay" }, { GeoCountry.US_Minor_Outlying_Islands, "US Minor Outlying Islands" }, { GeoCountry.Uzbekistan, "Uzbekistan" }, { GeoCountry.Vanuatu, "Vanuatu" }, { GeoCountry.Vatican_City_State_Holy_See, "Vatican City State (Holy See)" }, { GeoCountry.Venezuela, "Venezuela" }, { GeoCountry.Viet_Nam, "Viet Nam" }, { GeoCountry.Virgin_Islands_British, "Virgin Islands (British)" }, { GeoCountry.Virgin_Islands_US, "Virgin Islands (US)" }, { GeoCountry.Wallis_and_Futuna_Islands, "Wallis and Futuna Islands" }, { GeoCountry.Western_Sahara, "Western Sahara" }, { GeoCountry.Yemen, "Yemen" }, { GeoCountry.Yugoslavia, "Yugoslavia" }, { GeoCountry.Zaire, "Zaire" }, { GeoCountry.Zambia, "Zambia" }, { GeoCountry.Zimbabwe, "Zimbabwe" } }; XEnum <GeoCountry> .SetNames(_d); XEnum <GeoCountry> .CaseInsensitive = true; // --- var alld = allCountryNamesDict; foreach (var kv in XEnum <GeoCountry> .ValuesDict) { int intVal = kv.Key; string flNm = kv.Value; GeoCountry gcVal = (GeoCountry)intVal; string enumNm = gcVal.ToString(); string enumNm_NoUnderscores = enumNm.Replace("_", ""); if (gcVal == GeoCountry.None) { continue; } // Add full country name if (!alld.ContainsKey(flNm)) { alld.Add(flNm, gcVal); } // Add raw enum country name (underscores) if (enumNm != flNm && !alld.ContainsKey(enumNm)) { alld.Add(enumNm, gcVal); } // Add enum country name removed underscores if (enumNm_NoUnderscores != enumNm && !alld.ContainsKey(enumNm_NoUnderscores)) { alld.Add(enumNm_NoUnderscores, gcVal); } } // Add abbreviations foreach (var kv in GeoCountriesByAbbreviationDict) { string abbr = kv.Key; string fnm = kv.Value; GeoCountry val = XEnum <GeoCountry> .Value(fnm); if (!alld.ContainsKey(abbr)) { alld.Add(abbr, val); } } }
private async Task InsertAsync(uint count, List <string> usersId, GeoCountry geo) { var discountData = new FakeDiscounts().Get(count, usersId, geo); await Collection.InsertManyAsync(discountData); }