public StateProvinceProtocol(StateProvince state)
 {
     this.Name = state.Name;
     this.FullName = state.FullName;
     this.IsDefault = state.IsDefault;
     this.ObjectID = state.ObjectID;
 }
        // PUT api/awbuildversion/5
        public void Put(StateProvince value)
        {
            var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault();

            if (GetActionType.Key != null)
            {
                if (GetActionType.Value.ToList()[0].Equals("DELETE"))
                    adventureWorks_BC.StateProvinceDelete(value);
                if (GetActionType.Value.ToList()[0].Equals("UPDATE"))
                    adventureWorks_BC.StateProvinceUpdate(value);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes a state/province
        /// </summary>
        /// <param name="stateProvince">The state/province</param>
        public virtual void DeleteStateProvince(StateProvince stateProvince)
        {
            if (stateProvince == null)
                throw new ArgumentNullException("stateProvince");

            _stateProvinceRepository.Delete(stateProvince);

            _cacheManager.RemoveByPattern(STATEPROVINCES_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityDeleted(stateProvince);
        }
Exemplo n.º 4
0
        public object Any(ResetDb request)
        {
            Db.CreateTableIfNotExists<StateProvince>();
            Db.CreateTableIfNotExists<OrganizationCategory>();
            Db.CreateTableIfNotExists<Organization>();
            Db.CreateTableIfNotExists<User>();
            Db.CreateTableIfNotExists<OrganizationAlly>();
            Db.CreateTableIfNotExists<OrganizationNews>();
            Db.CreateTableIfNotExists<OrganizationComment>();
            //Db.CreateTableIfNotExists<EventCategory>();
            //Db.CreateTableIfNotExists<Event>();

            if (Db.Select<StateProvince>().Count == 0)
            {
                var newYork = new StateProvince
                {
                    Abbreviation = "NY",
                    Name = "New York"
                };

                var california = new StateProvince
                {
                    Abbreviation = "CA",
                    Name = "California"
                };

                Db.Insert(newYork);
                Db.Insert(california);
            }

            //if (Db.Select<EventCategory>().Count == 0)
            //{
            //    var eventCategories = new List<EventCategory>
            //                              {
            //                                  new EventCategory {Name = "Demo"},
            //                                  new EventCategory {Name = "Dinner"},
            //                                  new EventCategory {Name = "Film Screening"},
            //                                  new EventCategory {Name = "Fundraiser"},
            //                                  new EventCategory {Name = "Info Session"},
            //                                  new EventCategory {Name = "Meeting"},
            //                                  new EventCategory {Name = "Outreach"},
            //                                  new EventCategory {Name = "Party"},
            //                                  new EventCategory {Name = "Potluck"},
            //                                  new EventCategory {Name = "Protest"},
            //                                  new EventCategory {Name = "Social"}
            //                              };

            //    Db.InsertAll(eventCategories);
            //}

            return new ResetDbResponse();
        }
Exemplo n.º 5
0
		private StateProvince GivenStateProvince(string code, string name, bool isOnlyStateProvince, CountryRegion country, SalesTerritory territory)
		{
			var state = new StateProvince
				{
					Code = code,
					Name = name,
					IsOnlyStateProvince = isOnlyStateProvince,
					SalesTerritory = territory,
					Country = country
				};

			Inject(state);

			return state;
		}
Exemplo n.º 6
0
 public static StateProvince ToEntity(this StateProvinceModel model, StateProvince destination)
 {
     return(Mapper.Map(model, destination));
 }
Exemplo n.º 7
0
        /// <summary>
        /// Import states from TXT file
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <returns>Number of imported states</returns>
        public virtual int ImportStatesFromTxt(Stream stream)
        {
            int count = 0;

            using (var reader = new StreamReader(stream))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    if (String.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    string[] tmp = line.Split(',');

                    if (tmp.Length != 5)
                    {
                        throw new NopException("Wrong file format");
                    }

                    //parse
                    var  countryTwoLetterIsoCode = tmp[0].Trim();
                    var  name         = tmp[1].Trim();
                    var  abbreviation = tmp[2].Trim();
                    bool published    = Boolean.Parse(tmp[3].Trim());
                    int  displayOrder = Int32.Parse(tmp[4].Trim());

                    var country = _countryService.GetCountryByTwoLetterIsoCode(countryTwoLetterIsoCode);
                    if (country == null)
                    {
                        //country cannot be loaded. skip
                        continue;
                    }

                    //import
                    var states = _stateProvinceService.GetStateProvincesByCountryId(country.Id, showHidden: true);
                    var state  = states.FirstOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

                    if (state != null)
                    {
                        state.Abbreviation = abbreviation;
                        state.Published    = published;
                        state.DisplayOrder = displayOrder;
                        _stateProvinceService.UpdateStateProvince(state);
                    }
                    else
                    {
                        state = new StateProvince
                        {
                            CountryId    = country.Id,
                            Name         = name,
                            Abbreviation = abbreviation,
                            Published    = published,
                            DisplayOrder = displayOrder,
                        };
                        _stateProvinceService.InsertStateProvince(state);
                    }
                    count++;
                }
            }

            return(count);
        }
Exemplo n.º 8
0
 public static StateProvince ToEntity(this StateProvinceModel model, StateProvince destination)
 {
     return(model.MapTo(destination));
 }
Exemplo n.º 9
0
 public static StateProvinceModel ToModel(this StateProvince entity)
 {
     return(Mapper.Map <StateProvince, StateProvinceModel>(entity));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Assigns the birth state province.
 /// </summary>
 /// <param name="birthStateProvince">The birth state province.</param>
 /// <returns>A PatientBirthInfoBuilder.</returns>
 public PatientBirthInfoBuilder WithBirthStateProvince(StateProvince birthStateProvince)
 {
     _birthStateProvince = birthStateProvince;
     return(this);
 }
Exemplo n.º 11
0
        public virtual void PrepareVendorAddressModel(VendorAddressModel model,
                                                      Address address, bool excludeProperties,
                                                      Func <IList <Country> > loadCountries = null,
                                                      bool prePopulateWithCustomerFields    = false,
                                                      Customer customer             = null,
                                                      VendorSettings vendorSettings = null)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (!excludeProperties && address != null)
            {
                model.Company   = address.Company;
                model.CountryId = address.CountryId;
                Country country = null;
                if (!String.IsNullOrEmpty(address.CountryId))
                {
                    country = _countryService.GetCountryById(address.CountryId);
                }
                model.CountryName = country != null?country.GetLocalized(x => x.Name) : null;

                model.StateProvinceId = address.StateProvinceId;
                StateProvince state = null;
                if (!String.IsNullOrEmpty(address.StateProvinceId))
                {
                    state = _stateProvinceService.GetStateProvinceById(address.StateProvinceId);
                }
                model.StateProvinceName = state != null?state.GetLocalized(x => x.Name) : null;

                model.City          = address.City;
                model.Address1      = address.Address1;
                model.Address2      = address.Address2;
                model.ZipPostalCode = address.ZipPostalCode;
                model.PhoneNumber   = address.PhoneNumber;
                model.FaxNumber     = address.FaxNumber;
            }

            if (address == null && prePopulateWithCustomerFields)
            {
                if (customer == null)
                {
                    throw new Exception("Customer cannot be null when prepopulating an address");
                }
                model.Company       = customer.GetAttribute <string>(SystemCustomerAttributeNames.Company);
                model.Address1      = customer.GetAttribute <string>(SystemCustomerAttributeNames.StreetAddress);
                model.Address2      = customer.GetAttribute <string>(SystemCustomerAttributeNames.StreetAddress2);
                model.ZipPostalCode = customer.GetAttribute <string>(SystemCustomerAttributeNames.ZipPostalCode);
                model.City          = customer.GetAttribute <string>(SystemCustomerAttributeNames.City);
                model.PhoneNumber   = customer.GetAttribute <string>(SystemCustomerAttributeNames.Phone);
                model.FaxNumber     = customer.GetAttribute <string>(SystemCustomerAttributeNames.Fax);

                if (vendorSettings.CountryEnabled)
                {
                    model.CountryId = customer.GetAttribute <string>(SystemCustomerAttributeNames.CountryId);
                }

                if (vendorSettings.StateProvinceEnabled)
                {
                    model.StateProvinceId = customer.GetAttribute <string>(SystemCustomerAttributeNames.StateProvinceId);
                }
            }

            //countries and states
            if (vendorSettings.CountryEnabled && loadCountries != null)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = _localizationService.GetResource("Address.SelectCountry"), Value = ""
                });
                foreach (var c in loadCountries())
                {
                    model.AvailableCountries.Add(new SelectListItem
                    {
                        Text     = c.GetLocalized(x => x.Name),
                        Value    = c.Id.ToString(),
                        Selected = c.Id == model.CountryId
                    });
                }

                if (vendorSettings.StateProvinceEnabled)
                {
                    var languageId = _workContext.WorkingLanguage.Id;
                    var states     = _stateProvinceService
                                     .GetStateProvincesByCountryId(!String.IsNullOrEmpty(model.CountryId) ? model.CountryId : "", languageId)
                                     .ToList();
                    if (states.Any())
                    {
                        model.AvailableStates.Add(new SelectListItem {
                            Text = _localizationService.GetResource("Address.SelectState"), Value = ""
                        });

                        foreach (var s in states)
                        {
                            model.AvailableStates.Add(new SelectListItem
                            {
                                Text     = s.GetLocalized(x => x.Name),
                                Value    = s.Id.ToString(),
                                Selected = (s.Id == model.StateProvinceId)
                            });
                        }
                    }
                    else
                    {
                        bool anyCountrySelected = model.AvailableCountries.Any(x => x.Selected);
                        model.AvailableStates.Add(new SelectListItem
                        {
                            Text  = _localizationService.GetResource(anyCountrySelected ? "Address.OtherNonUS" : "Address.SelectState"),
                            Value = ""
                        });
                    }
                }
            }

            //form fields
            model.CompanyEnabled         = vendorSettings.CompanyEnabled;
            model.CompanyRequired        = vendorSettings.CompanyRequired;
            model.StreetAddressEnabled   = vendorSettings.StreetAddressEnabled;
            model.StreetAddressRequired  = vendorSettings.StreetAddressRequired;
            model.StreetAddress2Enabled  = vendorSettings.StreetAddress2Enabled;
            model.StreetAddress2Required = vendorSettings.StreetAddress2Required;
            model.ZipPostalCodeEnabled   = vendorSettings.ZipPostalCodeEnabled;
            model.ZipPostalCodeRequired  = vendorSettings.ZipPostalCodeRequired;
            model.CityEnabled            = vendorSettings.CityEnabled;
            model.CityRequired           = vendorSettings.CityRequired;
            model.CountryEnabled         = vendorSettings.CountryEnabled;
            model.StateProvinceEnabled   = vendorSettings.StateProvinceEnabled;
            model.PhoneEnabled           = vendorSettings.PhoneEnabled;
            model.PhoneRequired          = vendorSettings.PhoneRequired;
            model.FaxEnabled             = vendorSettings.FaxEnabled;
            model.FaxRequired            = vendorSettings.FaxRequired;
        }
Exemplo n.º 12
0
        public string GetRequest(int orderId, bool CheckOrder, bool RejectedOrder)
        {
            String strXml = String.Empty;

            using (StringWriter str = new StringWriter())
            {
                using (XmlTextWriter xml = new XmlTextWriter(str))
                {
                    //root node
                    xml.WriteStartDocument();
                    xml.WriteWhitespace("\n");
                    xml.WriteStartElement("UDOARequest");
                    xml.WriteAttributeString("version", "2.00");
                    xml.WriteWhitespace("\n");
                    xml.WriteStartElement("UDIParameter");
                    xml.WriteWhitespace("\n");

                    xml.WriteStartElement("Parameter");
                    xml.WriteAttributeString("key", "UDIAuthToken");
                    xml.WriteValue(config.Attributes["OMXBizzId"].Value);
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");
                    Order  orderItem = new OrderManager().GetBatchProcessOrder(orderId);
                    string keycode   = "";
                    foreach (Sku Item in orderItem.SkuItems)
                    {
                        keycode = Item.OfferCode;
                    }
                    xml.WriteStartElement("Parameter");
                    xml.WriteAttributeString("key", "Keycode"); // Dont hard code. Should be a value at SKU Category level
                    xml.WriteValue(keycode);
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteStartElement("Parameter");
                    xml.WriteAttributeString("key", "VerifyFlag");
                    if (CheckOrder)
                    {
                        xml.WriteValue("True"); // This means that we are not posting order to OMX, we just need the tax info from them.
                    }
                    else
                    {
                        xml.WriteValue("False"); // This means we are posting the order to OMX.
                    }
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteStartElement("Parameter");
                    xml.WriteAttributeString("key", "QueueFlag");
                    xml.WriteValue("True");
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    //xml.WriteStartElement("Parameter");
                    //xml.WriteAttributeString("key", "OriginalEntryKeycode");
                    //xml.WriteValue(keycode);
                    //xml.WriteEndElement();
                    //xml.WriteWhitespace("\n");

                    //xml.WriteStartElement("Parameter");
                    //xml.WriteAttributeString("key", "CallToAction");
                    //xml.WriteEndElement();
                    //xml.WriteWhitespace("\n");

                    //xml.WriteStartElement("Parameter");
                    //xml.WriteAttributeString("key", "Vendor");
                    //xml.WriteValue("DIRECT");
                    //xml.WriteEndElement();
                    //xml.WriteWhitespace("\n");

                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteWhitespace("\n");



                    //Write HeadTag
                    xml.WriteStartElement("Header");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("OrderDate", orderItem.CreatedDate.ToString());
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("OriginType", config.Attributes["OriginType"].Value);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("OrderID", config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString());
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("StoreCode", config.Attributes["StoreCode"].Value);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("CustomerIP", orderItem.IpAddress);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Username", config.Attributes["UserName"].Value);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Reference", "");
                    xml.WriteWhitespace("\n");
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");
                    List <StateProvince> states = StateManager.GetAllStates(0);

                    //Customer section
                    xml.WriteStartElement("Customer");
                    xml.WriteWhitespace("\n");
                    xml.WriteStartElement("Address");
                    xml.WriteAttributeString("type", "BillTo");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("TitleCode", "0");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Company", "");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Firstname", orderItem.CustomerInfo.BillingAddress.FirstName);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("MidInitial", "");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Lastname", orderItem.CustomerInfo.BillingAddress.LastName);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Address1", orderItem.CustomerInfo.BillingAddress.Address1);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Address2", orderItem.CustomerInfo.BillingAddress.Address2);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("City", orderItem.CustomerInfo.BillingAddress.City);
                    xml.WriteWhitespace("\n");
                    //xml.WriteElementString("State", orderItem.CustomerInfo.BillingAddress.StateProvinceName);
                    //xml.WriteWhitespace("\n");
                    StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId));
                    if (itemBillingStateProvince != null)
                    {
                        xml.WriteElementString("State", itemBillingStateProvince.Abbreviation);
                        xml.WriteWhitespace("\n");
                    }
                    else
                    {
                        xml.WriteElementString("State", string.Empty);
                        xml.WriteWhitespace("\n");
                    }
                    xml.WriteElementString("ZIP", orderItem.CustomerInfo.BillingAddress.ZipPostalCode);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("TLD", orderItem.CustomerInfo.BillingAddress.CountryCode.Trim());
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("PhoneNumber", orderItem.CustomerInfo.BillingAddress.PhoneNumber);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Email", orderItem.Email);
                    xml.WriteWhitespace("\n");
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    //Shipping information
                    xml.WriteStartElement("ShippingInformation");
                    xml.WriteWhitespace("\n");
                    xml.WriteStartElement("Address");
                    xml.WriteAttributeString("type", "ShipTo");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("TitleCode", "0");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Firstname", orderItem.CustomerInfo.ShippingAddress.FirstName);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Lastname", orderItem.CustomerInfo.ShippingAddress.LastName);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Address1", orderItem.CustomerInfo.ShippingAddress.Address1);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("Address2", orderItem.CustomerInfo.ShippingAddress.Address2);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("City", orderItem.CustomerInfo.ShippingAddress.City);
                    xml.WriteWhitespace("\n");

                    StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId));
                    if (itemShippingStateProvince != null)
                    {
                        xml.WriteElementString("State", itemShippingStateProvince.Abbreviation);
                        xml.WriteWhitespace("\n");
                    }
                    else
                    {
                        xml.WriteElementString("State", string.Empty);
                        xml.WriteWhitespace("\n");
                    }

                    xml.WriteElementString("ZIP", orderItem.CustomerInfo.ShippingAddress.ZipPostalCode);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("TLD", orderItem.CustomerInfo.ShippingAddress.CountryCode.Trim());
                    xml.WriteWhitespace("\n");
                    xml.WriteEndElement(); // CLose Address Tag
                    xml.WriteWhitespace("\n");

                    xml.WriteElementString("MethodCode", config.Attributes["MethodCode"].Value); //Dont want to harcode this
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("MethodName", "");                                    //Dont want to harcode this
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("ShippingAmount", orderItem.ShippingCost.ToString());
                    xml.WriteWhitespace("\n");

                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");


                    //Payment informaiton
                    xml.WriteStartElement("Payment");
                    xml.WriteAttributeString("type", "1");
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("CardNumber", orderItem.CreditInfo.CreditCardNumber);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("CardVerification", orderItem.CreditInfo.CreditCardCSC);
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("CardExpDateMonth", orderItem.CreditInfo.CreditCardExpired.ToString("MM"));
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("CardExpDateYear", orderItem.CreditInfo.CreditCardExpired.ToString("yyyy"));
                    xml.WriteWhitespace("\n");
                    xml.WriteElementString("RealTimeCreditCardProcessing", "False");
                    xml.WriteWhitespace("\n");
                    if (!RejectedOrder)
                    {
                        xml.WriteElementString("CardStatus", "11");
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("CardTransactionID", orderItem.CreditInfo.TransactionCode);
                    }
                    else
                    {
                        xml.WriteElementString("CardStatus", "0");
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("CardTransactionID", "");
                    }
                    xml.WriteWhitespace("\n");
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");


                    //SkuItems
                    xml.WriteStartElement("OrderDetail");
                    xml.WriteWhitespace("\n");
                    int lineItemCount = 1;
                    foreach (Sku Item in orderItem.SkuItems)
                    {
                        Item.LoadAttributeValues();
                        xml.WriteStartElement("LineItem");
                        xml.WriteAttributeString("lineNumber", lineItemCount.ToString());
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("PaymentPlanID", Item.AttributeValues["paymentplanid"].Value);
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("ItemCode", Item.SkuCode);
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("Quantity", Item.Quantity.ToString());
                        xml.WriteWhitespace("\n");
                        xml.WriteElementString("UnitPrice", Item.InitialPrice.ToString());
                        xml.WriteWhitespace("\n");
                        if (Item.AttributeValues.ContainsKey("standingorderid"))
                        {
                            if (Item.AttributeValues["standingorderid"].Value != "")
                            {
                                xml.WriteStartElement("StandingOrder");
                                xml.WriteAttributeString("configurationID", Item.AttributeValues["standingorderid"].Value);
                                xml.WriteEndElement();
                            }
                        }
                        xml.WriteEndElement();
                        xml.WriteWhitespace("\n");
                        lineItemCount++;
                    }

                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");



                    //Custom Fields
                    xml.WriteStartElement("CustomFields"); //CustomFields Starts
                    xml.WriteStartElement("Report");       //Report Starts

                    xml.WriteStartElement("Field");
                    xml.WriteAttributeString("fieldName", "OriginalOrderDate");// Dont hard code. Should be a value at DB level
                    xml.WriteValue(orderItem.CreatedDate.ToString());
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteStartElement("Field");
                    xml.WriteAttributeString("fieldName", "URL");// Dont hard code. Should be a value at DB level
                    xml.WriteValue(config.Attributes["SiteUrl"].Value);
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteStartElement("Field");
                    xml.WriteAttributeString("fieldName", "CustomerIP");// Dont hard code. Should be a value at DB level
                    xml.WriteValue(orderItem.IpAddress);
                    xml.WriteEndElement();
                    xml.WriteWhitespace("\n");

                    xml.WriteEndElement(); //Report End
                    xml.WriteEndElement(); //CustomFields End

                    //rootEnd node
                    xml.WriteEndElement();
                    //flush results to string object
                    strXml = str.ToString();
                }
            }
            return(strXml);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            string returnURL = CommonHelper.GetStoreLocation(false) + "TwoCheckoutReturn.aspx";

            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("{0}?id_type=1", serverURL);

            //products
            OrderProductVariantCollection orderProductVariants = order.OrderProductVariants;

            for (int i = 0; i < orderProductVariants.Count; i++)
            {
                int pNum = i + 1;
                OrderProductVariant opv     = orderProductVariants[i];
                ProductVariant      pv      = orderProductVariants[i].ProductVariant;
                Product             product = pv.Product;

                string c_prod       = string.Format("c_prod_{0}", pNum);
                string c_prod_value = string.Format("{0},{1}", pv.SKU, opv.Quantity);
                builder.AppendFormat("&{0}={1}", c_prod, c_prod_value);
                string c_name       = string.Format("c_name_{0}", pNum);
                string c_name_value = pv.FullProductName;
                builder.AppendFormat("&{0}={1}", HttpUtility.UrlEncode(c_name), HttpUtility.UrlEncode(c_name_value));

                string c_description       = string.Format("c_description_{0}", pNum);
                string c_description_value = pv.FullProductName;
                if (!String.IsNullOrEmpty(opv.AttributeDescription))
                {
                    c_description_value = c_description_value + ". " + opv.AttributeDescription;
                    c_description_value = c_description_value.Replace("<br />", ". ");
                }
                builder.AppendFormat("&{0}={1}", HttpUtility.UrlEncode(c_description), HttpUtility.UrlEncode(c_description_value));

                string c_price       = string.Format("c_price_{0}", pNum);
                string c_price_value = opv.UnitPriceInclTax.ToString("0.00", CultureInfo.InvariantCulture);
                builder.AppendFormat("&{0}={1}", c_price, c_price_value);

                string c_tangible       = string.Format("c_tangible_{0}", pNum);
                string c_tangible_value = "Y";
                if (pv.IsDownload)
                {
                    c_tangible_value = "N";
                }
                builder.AppendFormat("&{0}={1}", c_tangible, c_tangible_value);
            }

            builder.AppendFormat("&x_login={0}", vendorID);
            builder.AppendFormat("&x_amount={0}", order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture));
            builder.AppendFormat("&x_invoice_num={0}", order.OrderId);
            //("x_receipt_link_url", returnURL);
            //("x_return_url", returnURL);
            //("x_return", returnURL);
            if (useSandBox)
            {
                builder.AppendFormat("&demo=Y");
            }
            builder.AppendFormat("&x_First_Name={0}", HttpUtility.UrlEncode(order.BillingFirstName));
            builder.AppendFormat("&x_Last_Name={0}", HttpUtility.UrlEncode(order.BillingLastName));
            builder.AppendFormat("&x_Address={0}", HttpUtility.UrlEncode(order.BillingAddress1));
            builder.AppendFormat("&x_City={0}", HttpUtility.UrlEncode(order.BillingCity));
            StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId);

            if (billingStateProvince != null)
            {
                builder.AppendFormat("&x_State={0}", HttpUtility.UrlEncode(billingStateProvince.Abbreviation));
            }
            else
            {
                builder.AppendFormat("&x_State={0}", HttpUtility.UrlEncode(order.BillingStateProvince));
            }
            builder.AppendFormat("&x_Zip={0}", HttpUtility.UrlEncode(order.BillingZipPostalCode));
            Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId);

            if (billingCountry != null)
            {
                builder.AppendFormat("&x_Country={0}", HttpUtility.UrlEncode(billingCountry.ThreeLetterIsoCode));
            }
            else
            {
                builder.AppendFormat("&x_Country={0}", HttpUtility.UrlEncode(order.BillingCountry));
            }
            builder.AppendFormat("&x_EMail={0}", HttpUtility.UrlEncode(order.BillingEmail));
            builder.AppendFormat("&x_Phone={0}", HttpUtility.UrlEncode(order.BillingPhoneNumber));
            HttpContext.Current.Response.Redirect(builder.ToString());
            return(string.Empty);
        }
Exemplo n.º 14
0
        public void WriteAddress(dynamic address, string node)
        {
            if (address == null)
            {
                return;
            }

            Address entity = address.Entity;

            if (node.HasValue())
            {
                _writer.WriteStartElement(node);
            }

            _writer.Write("Id", entity.Id.ToString());
            _writer.Write("FirstName", entity.FirstName);
            _writer.Write("LastName", entity.LastName);
            _writer.Write("Email", entity.Email);
            _writer.Write("Company", entity.Company);
            _writer.Write("CountryId", entity.CountryId.HasValue ? entity.CountryId.Value.ToString() : "");
            _writer.Write("StateProvinceId", entity.StateProvinceId.HasValue ? entity.StateProvinceId.Value.ToString() : "");
            _writer.Write("City", entity.City);
            _writer.Write("Address1", entity.Address1);
            _writer.Write("Address2", entity.Address2);
            _writer.Write("ZipPostalCode", entity.ZipPostalCode);
            _writer.Write("PhoneNumber", entity.PhoneNumber);
            _writer.Write("FaxNumber", entity.FaxNumber);
            _writer.Write("CreatedOnUtc", entity.CreatedOnUtc.ToString(_culture));

            if (address.Country != null)
            {
                dynamic country       = address.Country;
                Country entityCountry = address.Country.Entity;

                _writer.WriteStartElement("Country");
                _writer.Write("Id", entityCountry.Id.ToString());
                _writer.Write("Name", (string)country.Name);
                _writer.Write("AllowsBilling", entityCountry.AllowsBilling.ToString());
                _writer.Write("AllowsShipping", entityCountry.AllowsShipping.ToString());
                _writer.Write("TwoLetterIsoCode", entityCountry.TwoLetterIsoCode);
                _writer.Write("ThreeLetterIsoCode", entityCountry.ThreeLetterIsoCode);
                _writer.Write("NumericIsoCode", entityCountry.NumericIsoCode.ToString());
                _writer.Write("SubjectToVat", entityCountry.SubjectToVat.ToString());
                _writer.Write("Published", entityCountry.Published.ToString());
                _writer.Write("DisplayOrder", entityCountry.DisplayOrder.ToString());
                _writer.Write("LimitedToStores", entityCountry.LimitedToStores.ToString());

                WriteLocalized(country);

                _writer.WriteEndElement();                      // Country
            }

            if (address.StateProvince != null)
            {
                dynamic       stateProvince       = address.StateProvince;
                StateProvince entityStateProvince = address.StateProvince.Entity;

                _writer.WriteStartElement("StateProvince");
                _writer.Write("Id", entityStateProvince.Id.ToString());
                _writer.Write("CountryId", entityStateProvince.CountryId.ToString());
                _writer.Write("Name", (string)stateProvince.Name);
                _writer.Write("Abbreviation", (string)stateProvince.Abbreviation);
                _writer.Write("Published", entityStateProvince.Published.ToString());
                _writer.Write("DisplayOrder", entityStateProvince.DisplayOrder.ToString());

                WriteLocalized(stateProvince);

                _writer.WriteEndElement();                      // StateProvince
            }

            if (node.HasValue())
            {
                _writer.WriteEndElement();
            }
        }
        private async Task PrepareAddressModel(AddressModel model,
                                               Address address, bool excludeProperties,
                                               Func <IList <Country> > loadCountries = null,
                                               bool prePopulateWithCustomerFields    = false,
                                               Customer customer = null,
                                               Language language = null,
                                               Store store       = null)
        {
            if (!excludeProperties && address != null)
            {
                model.Id        = address.Id;
                model.FirstName = address.FirstName;
                model.LastName  = address.LastName;
                model.Email     = address.Email;
                model.Company   = address.Company;
                model.VatNumber = address.VatNumber;
                model.CountryId = address.CountryId;
                Country country = null;
                if (!String.IsNullOrEmpty(address.CountryId))
                {
                    country = await _countryService.GetCountryById(address.CountryId);
                }
                model.CountryName = country != null?country.GetLocalized(x => x.Name, language.Id) : null;

                model.StateProvinceId = address.StateProvinceId;
                StateProvince state = null;
                if (!String.IsNullOrEmpty(address.StateProvinceId))
                {
                    state = await _stateProvinceService.GetStateProvinceById(address.StateProvinceId);
                }
                model.StateProvinceName = state != null?state.GetLocalized(x => x.Name, language.Id) : null;

                model.City          = address.City;
                model.Address1      = address.Address1;
                model.Address2      = address.Address2;
                model.ZipPostalCode = address.ZipPostalCode;
                model.PhoneNumber   = address.PhoneNumber;
                model.FaxNumber     = address.FaxNumber;
            }

            if (address == null && prePopulateWithCustomerFields)
            {
                if (customer == null)
                {
                    throw new Exception("Customer cannot be null when prepopulating an address");
                }
                model.Email           = customer.Email;
                model.FirstName       = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.FirstName);
                model.LastName        = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.LastName);
                model.Company         = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Company);
                model.VatNumber       = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.VatNumber);
                model.Address1        = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StreetAddress);
                model.Address2        = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StreetAddress2);
                model.ZipPostalCode   = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.ZipPostalCode);
                model.City            = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.City);
                model.CountryId       = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.CountryId);
                model.StateProvinceId = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.StateProvinceId);
                model.PhoneNumber     = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Phone);
                model.FaxNumber       = customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.Fax);
            }

            //countries and states
            if (_addressSettings.CountryEnabled && loadCountries != null)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = _localizationService.GetResource("Address.SelectCountry"), Value = ""
                });
                foreach (var c in loadCountries())
                {
                    model.AvailableCountries.Add(new SelectListItem {
                        Text     = c.GetLocalized(x => x.Name, language.Id),
                        Value    = c.Id.ToString(),
                        Selected = !string.IsNullOrEmpty(model.CountryId) ? c.Id == model.CountryId : (c.Id == store.DefaultCountryId)
                    });
                }

                if (_addressSettings.StateProvinceEnabled)
                {
                    var states = await _stateProvinceService
                                 .GetStateProvincesByCountryId(!string.IsNullOrEmpty(model.CountryId)?model.CountryId : store.DefaultCountryId, language.Id);

                    if (states.Any())
                    {
                        model.AvailableStates.Add(new SelectListItem {
                            Text = _localizationService.GetResource("Address.SelectState"), Value = ""
                        });

                        foreach (var s in states)
                        {
                            model.AvailableStates.Add(new SelectListItem {
                                Text     = s.GetLocalized(x => x.Name, language.Id),
                                Value    = s.Id.ToString(),
                                Selected = (s.Id == model.StateProvinceId)
                            });
                        }
                    }
                    else
                    {
                        bool anyCountrySelected = model.AvailableCountries.Any(x => x.Selected);
                        model.AvailableStates.Add(new SelectListItem {
                            Text  = _localizationService.GetResource(anyCountrySelected ? "Address.OtherNonUS" : "Address.SelectState"),
                            Value = ""
                        });
                    }
                }
            }

            //form fields
            model.CompanyEnabled         = _addressSettings.CompanyEnabled;
            model.CompanyRequired        = _addressSettings.CompanyRequired;
            model.VatNumberEnabled       = _addressSettings.VatNumberEnabled;
            model.VatNumberRequired      = _addressSettings.VatNumberRequired;
            model.StreetAddressEnabled   = _addressSettings.StreetAddressEnabled;
            model.StreetAddressRequired  = _addressSettings.StreetAddressRequired;
            model.StreetAddress2Enabled  = _addressSettings.StreetAddress2Enabled;
            model.StreetAddress2Required = _addressSettings.StreetAddress2Required;
            model.ZipPostalCodeEnabled   = _addressSettings.ZipPostalCodeEnabled;
            model.ZipPostalCodeRequired  = _addressSettings.ZipPostalCodeRequired;
            model.CityEnabled            = _addressSettings.CityEnabled;
            model.CityRequired           = _addressSettings.CityRequired;
            model.CountryEnabled         = _addressSettings.CountryEnabled;
            model.StateProvinceEnabled   = _addressSettings.StateProvinceEnabled;
            model.PhoneEnabled           = _addressSettings.PhoneEnabled;
            model.PhoneRequired          = _addressSettings.PhoneRequired;
            model.FaxEnabled             = _addressSettings.FaxEnabled;
            model.FaxRequired            = _addressSettings.FaxRequired;
        }
Exemplo n.º 16
0
        private void reloadGridView()
        {
            if (DropDownListDBTables.SelectedValue == "Administrators")
            {
                //Get all objects
                Administrator        obj  = new Administrator();
                List <Administrator> list = obj.GetAllAdministrators(false);

                //Fill a rendered object list
                List <RenderAdministrator> renderedList = new List <RenderAdministrator>();
                foreach (Administrator x in list)
                {
                    renderedList.Add(new RenderAdministrator(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Audits")
            {
                //Get all objects
                Audit        obj  = new Audit();
                List <Audit> list = obj.GetAllAudits();

                //Fill a rendered object list
                List <RenderAudit> renderedList = new List <RenderAudit>();
                foreach (Audit x in list)
                {
                    renderedList.Add(new RenderAudit(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "AuditTypes")
            {
                //Get all objects
                AuditType        obj  = new AuditType();
                List <AuditType> list = obj.GetAllAuditTypes();

                //Fill a rendered object list
                List <RenderAuditType> renderedList = new List <RenderAuditType>();
                foreach (AuditType x in list)
                {
                    renderedList.Add(new RenderAuditType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            if (DropDownListDBTables.SelectedValue == "Categories")
            {
                //Get all objects
                Category        obj  = new Category();
                List <Category> list = obj.GetAllCategories(false);

                //Fill a rendered object list
                List <RenderCategory> renderedList = new List <RenderCategory>();
                foreach (Category x in list)
                {
                    renderedList.Add(new RenderCategory(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Configurations")
            {
                //Get all objects
                Configuration        obj  = new Configuration();
                List <Configuration> list = obj.GetAllConfigurations();

                //Fill a rendered object list
                List <RenderConfiguration> renderedList = new List <RenderConfiguration>();
                foreach (Configuration x in list)
                {
                    renderedList.Add(new RenderConfiguration(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "DeliveryType")
            {
                //Get all objects
                DeliveryType        obj  = new DeliveryType();
                List <DeliveryType> list = obj.GetAllDeliveryTypes();

                //Fill a rendered object list
                List <RenderDeliveryType> renderedList = new List <RenderDeliveryType>();
                foreach (DeliveryType x in list)
                {
                    renderedList.Add(new RenderDeliveryType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "LangLabels")
            {
                //Get all objects
                LangLabel        obj  = new LangLabel();
                List <LangLabel> list = obj.GetAllLangLabels();

                //Fill a rendered object list
                List <RenderLangLabel> renderedList = new List <RenderLangLabel>();
                foreach (LangLabel x in list)
                {
                    renderedList.Add(new RenderLangLabel(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "OrderItems")
            {
                //Get all objects
                OrderItem        obj  = new OrderItem();
                List <OrderItem> list = obj.GetAllOrderItems();

                //Fill a rendered object list
                List <RenderOrderItem> renderedList = new List <RenderOrderItem>();
                foreach (OrderItem x in list)
                {
                    renderedList.Add(new RenderOrderItem(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Orders")
            {
                //Get all objects
                Order        obj  = new Order();
                List <Order> list = obj.GetAllOrders();

                //Fill a rendered object list
                List <RenderOrder> renderedList = new List <RenderOrder>();
                foreach (Order x in list)
                {
                    renderedList.Add(new RenderOrder(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "ProductDeliveryTypes")
            {
                //Get all objects
                ProductDeliveryType        obj  = new ProductDeliveryType();
                List <ProductDeliveryType> list = obj.GetAllProductDeliveryTypes();

                //Fill a rendered object list
                List <RenderProductDeliveryType> renderedList = new List <RenderProductDeliveryType>();
                foreach (ProductDeliveryType x in list)
                {
                    renderedList.Add(new RenderProductDeliveryType(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Products")
            {
                //Get all objects
                Product        obj  = new Product();
                List <Product> list = obj.GetAllProducts(false);

                //Fill a rendered object list
                List <RenderProduct> renderedList = new List <RenderProduct>();
                foreach (Product x in list)
                {
                    renderedList.Add(new RenderProduct(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "StatesProvinces")
            {
                //Get all objects
                StateProvince        obj  = new StateProvince();
                List <StateProvince> list = obj.GetAllStatesProvinces();

                //Fill a rendered object list
                List <RenderStateProvince> renderedList = new List <RenderStateProvince>();
                foreach (StateProvince x in list)
                {
                    renderedList.Add(new RenderStateProvince(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }
            else if (DropDownListDBTables.SelectedValue == "Users")
            {
                //Get all objects
                User        obj  = new User();
                List <User> list = obj.GetAllUsers();

                //Fill a rendered object list
                List <RenderUser> renderedList = new List <RenderUser>();
                foreach (User x in list)
                {
                    renderedList.Add(new RenderUser(x));
                }

                GridViewDBTable.DataSource = renderedList;
            }

            //Databind the new datasource obtained above
            GridViewDBTable.DataBind();
        }
Exemplo n.º 17
0
 public static StateProvinceLiquidViewModel MapToLiquidVeiwModel(this StateProvince sp)
 {
     return(Mapper.Map <StateProvinceLiquidViewModel>(sp));
 }
Exemplo n.º 18
0
        //address
        /// <summary>
        /// Prepare address model
        /// </summary>
        /// <param name="model">Model</param>
        /// <param name="address">Address</param>
        /// <param name="excludeProperties">A value indicating whether to exclude properties</param>
        /// <param name="addressSettings">Address settings</param>
        /// <param name="localizationService">Localization service (used to prepare a select list)</param>
        /// <param name="stateProvinceService">State service (used to prepare a select list). null to don't prepare the list.</param>
        /// <param name="addressAttributeService">Address attribute service. null to don't prepare the list.</param>
        /// <param name="addressAttributeParser">Address attribute parser. null to don't prepare the list.</param>
        /// <param name="addressAttributeFormatter">Address attribute formatter. null to don't prepare the formatted custom attributes.</param>
        /// <param name="loadCountries">A function to load countries  (used to prepare a select list). null to don't prepare the list.</param>
        /// <param name="prePopulateWithCustomerFields">A value indicating whether to pre-populate an address with customer fields entered during registration. It's used only when "address" parameter is set to "null"</param>
        /// <param name="customer">Customer record which will be used to pre-populate address. Used only when "prePopulateWithCustomerFields" is "true".</param>
        public static void PrepareModel(this AddressModel model,
                                        Address address, bool excludeProperties,
                                        AddressSettings addressSettings,
                                        ILocalizationService localizationService             = null,
                                        IStateProvinceService stateProvinceService           = null,
                                        IAddressAttributeService addressAttributeService     = null,
                                        IAddressAttributeParser addressAttributeParser       = null,
                                        IAddressAttributeFormatter addressAttributeFormatter = null,
                                        Func <IList <Country> > loadCountries = null,
                                        bool prePopulateWithCustomerFields    = false,
                                        Customer customer            = null,
                                        string overrideAttributesXml = "")
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            if (addressSettings == null)
            {
                throw new ArgumentNullException("addressSettings");
            }

            if (!excludeProperties && address != null)
            {
                model.Id        = address.Id;
                model.FirstName = address.FirstName;
                model.LastName  = address.LastName;
                model.Email     = address.Email;
                model.Company   = address.Company;

                model.CountryId = address.CountryId;
                Country country = null;
                if (!String.IsNullOrEmpty(address.CountryId))
                {
                    country = EngineContext.Current.Resolve <ICountryService>().GetCountryById(address.CountryId);
                }
                model.CountryName = country != null?country.GetLocalized(x => x.Name) : null;

                model.StateProvinceId = address.StateProvinceId;
                StateProvince state = null;
                if (!String.IsNullOrEmpty(address.StateProvinceId))
                {
                    state = EngineContext.Current.Resolve <IStateProvinceService>().GetStateProvinceById(address.StateProvinceId);
                }
                model.StateProvinceName = state != null?state.GetLocalized(x => x.Name) : null;

                model.City          = address.City;
                model.Address1      = address.Address1;
                model.Address2      = address.Address2;
                model.ZipPostalCode = address.ZipPostalCode;
                model.PhoneNumber   = address.PhoneNumber;
                model.FaxNumber     = address.FaxNumber;
            }

            if (address == null && prePopulateWithCustomerFields)
            {
                if (customer == null)
                {
                    throw new Exception("Customer cannot be null when prepopulating an address");
                }
                model.Email         = customer.Email;
                model.FirstName     = customer.GetAttribute <string>(SystemCustomerAttributeNames.FirstName);
                model.LastName      = customer.GetAttribute <string>(SystemCustomerAttributeNames.LastName);
                model.Company       = customer.GetAttribute <string>(SystemCustomerAttributeNames.Company);
                model.Address1      = customer.GetAttribute <string>(SystemCustomerAttributeNames.StreetAddress);
                model.Address2      = customer.GetAttribute <string>(SystemCustomerAttributeNames.StreetAddress2);
                model.ZipPostalCode = customer.GetAttribute <string>(SystemCustomerAttributeNames.ZipPostalCode);
                model.City          = customer.GetAttribute <string>(SystemCustomerAttributeNames.City);
                //ignore country and state for prepopulation. it can cause some issues when posting pack with errors, etc
                //model.CountryId = customer.GetAttribute<int>(SystemCustomerAttributeNames.CountryId);
                //model.StateProvinceId = customer.GetAttribute<int>(SystemCustomerAttributeNames.StateProvinceId);
                model.PhoneNumber = customer.GetAttribute <string>(SystemCustomerAttributeNames.Phone);
                model.FaxNumber   = customer.GetAttribute <string>(SystemCustomerAttributeNames.Fax);
            }

            //countries and states
            if (addressSettings.CountryEnabled && loadCountries != null)
            {
                if (localizationService == null)
                {
                    throw new ArgumentNullException("localizationService");
                }

                model.AvailableCountries.Add(new SelectListItem {
                    Text = localizationService.GetResource("Address.SelectCountry"), Value = "0"
                });
                foreach (var c in loadCountries())
                {
                    model.AvailableCountries.Add(new SelectListItem
                    {
                        Text     = c.GetLocalized(x => x.Name),
                        Value    = c.Id.ToString(),
                        Selected = c.Id == model.CountryId
                    });
                }

                if (addressSettings.StateProvinceEnabled)
                {
                    //states
                    if (stateProvinceService == null)
                    {
                        throw new ArgumentNullException("stateProvinceService");
                    }
                    var languageId = EngineContext.Current.Resolve <IWorkContext>().WorkingLanguage.Id;
                    var states     = stateProvinceService
                                     .GetStateProvincesByCountryId(!String.IsNullOrEmpty(model.CountryId) ? model.CountryId : "", languageId)
                                     .ToList();
                    if (states.Any())
                    {
                        model.AvailableStates.Add(new SelectListItem {
                            Text = localizationService.GetResource("Address.SelectState"), Value = "0"
                        });

                        foreach (var s in states)
                        {
                            model.AvailableStates.Add(new SelectListItem
                            {
                                Text     = s.GetLocalized(x => x.Name),
                                Value    = s.Id.ToString(),
                                Selected = (s.Id == model.StateProvinceId)
                            });
                        }
                    }
                    else
                    {
                        bool anyCountrySelected = model.AvailableCountries.Any(x => x.Selected);
                        model.AvailableStates.Add(new SelectListItem
                        {
                            Text  = localizationService.GetResource(anyCountrySelected ? "Address.OtherNonUS" : "Address.SelectState"),
                            Value = "0"
                        });
                    }
                }
            }

            //form fields
            model.CompanyEnabled         = addressSettings.CompanyEnabled;
            model.CompanyRequired        = addressSettings.CompanyRequired;
            model.StreetAddressEnabled   = addressSettings.StreetAddressEnabled;
            model.StreetAddressRequired  = addressSettings.StreetAddressRequired;
            model.StreetAddress2Enabled  = addressSettings.StreetAddress2Enabled;
            model.StreetAddress2Required = addressSettings.StreetAddress2Required;
            model.ZipPostalCodeEnabled   = addressSettings.ZipPostalCodeEnabled;
            model.ZipPostalCodeRequired  = addressSettings.ZipPostalCodeRequired;
            model.CityEnabled            = addressSettings.CityEnabled;
            model.CityRequired           = addressSettings.CityRequired;
            model.CountryEnabled         = addressSettings.CountryEnabled;
            model.StateProvinceEnabled   = addressSettings.StateProvinceEnabled;
            model.PhoneEnabled           = addressSettings.PhoneEnabled;
            model.PhoneRequired          = addressSettings.PhoneRequired;
            model.FaxEnabled             = addressSettings.FaxEnabled;
            model.FaxRequired            = addressSettings.FaxRequired;

            //customer attribute services
            if (addressAttributeService != null && addressAttributeParser != null)
            {
                PrepareCustomAddressAttributes(model, address, addressAttributeService, addressAttributeParser, overrideAttributesXml);
            }
            if (addressAttributeFormatter != null && address != null)
            {
                model.FormattedCustomAddressAttributes = addressAttributeFormatter.FormatAttributes(address.CustomAttributes);
            }
        }
        public override Employee PopulateRecord(SqlDataReader reader)
        {
            AddressType addressType = new AddressType
            {
                Name = reader["AddressType"].ToString()
            };

            CountryRegion country = new CountryRegion
            {
                Name = reader["CountryRegionName"].ToString()
            };

            StateProvince state = new StateProvince
            {
                Name          = reader["StateProvinceName"].ToString(),
                CountryRegion = country
            };

            Address _address = new Address
            {
                AddressLine1    = reader["AddressLine1"].ToString(),
                AddressLine2    = reader["AddressLine2"].ToString(),
                City            = reader["City"].ToString(),
                PostalCode      = reader["PostalCode"].ToString(),
                StateProvinceID = Convert.ToInt32((int)reader["StateProvinceID"]),
                StateProvince   = state
            };
            BusinessEntityAddress entityAddress = new BusinessEntityAddress
            {
                Address     = _address,
                AddressType = addressType
            };

            EmailAddress emailAddress = new EmailAddress
            {
                EmailAddress1 = (string)reader["EmailAddress"]
            };
            PhoneNumberType numberType = new PhoneNumberType
            {
                Name = reader["PhoneType"].ToString()
            };

            PersonPhone phone = new PersonPhone
            {
                PhoneNumber       = (string)reader["PhoneNumber"],
                PhoneNumberTypeID = Convert.ToInt32((int)reader["PhoneNumberTypeID"]),
                PhoneNumberType   = numberType
            };

            Shift shift = new Shift
            {
                Name      = reader["ShiftName"].ToString(),
                StartTime = (TimeSpan)reader["StartTime"],
                EndTime   = (TimeSpan)reader["EndTime"]
            };

            Department department = new Department
            {
                Name      = reader["Department"].ToString(),
                GroupName = reader["GroupName"].ToString()
            };

            EmployeeDepartmentHistory employeeDepartment = new EmployeeDepartmentHistory
            {
                ShiftID      = Convert.ToByte((byte)reader["ShiftID"]),
                DepartmentID = Convert.ToInt16((short)reader["DepartmentID"]),
                Department   = department,
                Shift        = shift
            };

            EmployeePayHistory employeePay = new EmployeePayHistory
            {
                Rate         = Convert.ToDecimal((decimal)reader["Rate"]),
                PayFrequency = Convert.ToByte((byte)reader["PayFrequency"])
            };

            return(new Employee
            {
                BusinessEntityID = Convert.ToInt32((int)reader["BusinessEntityID"]),
                FirstName = reader["FirstName"].ToString(),
                MiddleName = reader["MiddleName"].ToString(),
                LastName = reader["LastName"].ToString(),
                Suffix = reader["Suffix"].ToString(),
                PersonType = reader["PersonType"].ToString(),
                NameStyle = (bool)reader["NameStyle"],
                Title = reader["Title"].ToString(),
                EmailPromotion = Convert.ToInt32((int)reader["EmailPromotion"]),
                ModifiedDate = (DateTime)reader["ModifiedDate"],
                rowguid = (Guid)reader["rowguid"],

                NationalIDNumber = reader["NationalIDNumber"].ToString(),
                LoginID = reader["LoginID"].ToString(),
                JobTitle = reader["JobTitle"].ToString(),
                BirthDate = (DateTime)reader["BirthDate"],
                MaritalStatus = reader["MaritalStatus"].ToString(),
                Gender = reader["Gender"].ToString(),
                HireDate = (DateTime)reader["HireDate"],
                SalariedFlag = (bool)reader["SalariedFlag"],
                VacationHours = Convert.ToInt16((short)reader["VacationHours"]),
                SickLeaveHours = Convert.ToInt16((short)reader["SickLeaveHours"]),
                CurrentFlag = (bool)reader["CurrentFlag"],

                EmailAddress = emailAddress,
                PersonPhone = phone,
                BusinessEntityAddress = entityAddress,
                EmployeeDepartmentHistory = employeeDepartment,
                EmployeePayHistory = employeePay
            });
        }
 /// <summary>
 /// There are no comments for StateProvince in the schema.
 /// </summary>
 public void AddToStateProvince(StateProvince stateProvince)
 {
     base.AddObject("StateProvince", stateProvince);
 }
 // POST api/awbuildversion
 public void Post(StateProvince value)
 {
     adventureWorks_BC.StateProvinceAdd(value);
 }
Exemplo n.º 22
0
 protected void UpdateLocales(StateProvince stateProvince, StateProvinceModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(stateProvince,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
 // POST api/awbuildversion
 public void Post(StateProvince value)
 {
     adventureWorks_BC.StateProvinceAdd(value);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Prepare state and province model
        /// </summary>
        /// <param name="model">State and province model</param>
        /// <param name="country">Country</param>
        /// <param name="state">State or province</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>State and province model</returns>
        public virtual async Task <StateProvinceModel> PrepareStateProvinceModelAsync(StateProvinceModel model,
                                                                                      Country country, StateProvince state, bool excludeProperties = false)
        {
            Action <StateProvinceLocalizedModel, int> localizedModelConfiguration = null;

            if (state != null)
            {
                //fill in model values from the entity
                model ??= state.ToModel <StateProvinceModel>();

                //define localized model configuration action
                localizedModelConfiguration = async(locale, languageId) =>
                {
                    locale.Name = await _localizationService.GetLocalizedAsync(state, entity => entity.Name, languageId, false, false);
                };
            }

            model.CountryId = country.Id;

            //set default values for the new model
            if (state == null)
            {
                model.Published = true;
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration);
            }

            return(model);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            RemotePost post = new RemotePost();

            post.FormName = "CyberSource";
            post.Url      = HostedPaymentSettings.GatewayUrl;
            post.Method   = "POST";

            post.Add("merchantID", HostedPaymentSettings.MerchantId);
            post.Add("orderPage_timestamp", HostedPaymentHelper.OrderPageTimestamp);
            post.Add("orderPage_transactionType", "authorization");
            post.Add("orderPage_version", "4");
            post.Add("orderPage_serialNumber", HostedPaymentSettings.SerialNumber);

            post.Add("amount", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", order.OrderTotal));
            post.Add("currency", order.CustomerCurrencyCode);
            post.Add("orderNumber", order.OrderId.ToString());

            post.Add("billTo_firstName", order.BillingFirstName);
            post.Add("billTo_lastName", order.BillingLastName);
            post.Add("billTo_street1", order.BillingAddress1);
            Country billCountry = CountryManager.GetCountryById(order.BillingCountryId);

            if (billCountry != null)
            {
                post.Add("billTo_country", billCountry.TwoLetterIsoCode);
            }
            StateProvince billState = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId);

            if (billState != null)
            {
                post.Add("billTo_state", billState.Abbreviation);
            }
            post.Add("billTo_city", order.BillingCity);
            post.Add("billTo_postalCode", order.BillingZipPostalCode);
            post.Add("billTo_phoneNumber", order.BillingPhoneNumber);
            post.Add("billTo_email", order.BillingEmail);

            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                post.Add("shipTo_firstName", order.ShippingFirstName);
                post.Add("shipTo_lastName", order.ShippingLastName);
                post.Add("shipTo_street1", order.ShippingAddress1);
                Country shipCountry = CountryManager.GetCountryById(order.ShippingCountryId);
                if (shipCountry != null)
                {
                    post.Add("shipTo_country", shipCountry.TwoLetterIsoCode);
                }
                StateProvince shipState = StateProvinceManager.GetStateProvinceById(order.ShippingStateProvinceId);
                if (shipState != null)
                {
                    post.Add("shipTo_state", shipState.Abbreviation);
                }
                post.Add("shipTo_city", order.ShippingCity);
                post.Add("shipTo_postalCode", order.ShippingZipPostalCode);
            }

            post.Add("orderPage_receiptResponseURL", String.Format("{0}CheckoutCompleted.aspx", CommonHelper.GetStoreLocation(false)));
            post.Add("orderPage_receiptLinkText", "Return");

            post.Add("orderPage_signaturePublic", HostedPaymentHelper.CalcRequestSign(post.Params));

            post.Post();

            return(String.Empty);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            string returnURL = CommonHelper.GetStoreLocation(false) + "WorldpayReturn.aspx";

            RemotePost remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "WorldpayForm";
            remotePostHelper.Url      = GetWorldpayUrl();

            remotePostHelper.Add("instId", instanceID);
            remotePostHelper.Add("cartId", order.OrderId.ToString());

            if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY)))
            {
                remotePostHelper.Add("paymentType", SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY));
            }

            if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName)))
            {
                remotePostHelper.Add("MC_WorldPayCSSName", SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName));
            }

            remotePostHelper.Add("currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode);
            remotePostHelper.Add("email", order.BillingEmail);
            remotePostHelper.Add("hideContact", "true");
            remotePostHelper.Add("noLanguageMenu", "true");
            remotePostHelper.Add("withDelivery", "true");
            remotePostHelper.Add("fixContact", "false");
            remotePostHelper.Add("amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("desc", SettingManager.StoreName);
            remotePostHelper.Add("M_UserID", order.CustomerId.ToString());
            remotePostHelper.Add("M_FirstName", order.BillingFirstName);
            remotePostHelper.Add("M_LastName", order.BillingLastName);
            remotePostHelper.Add("M_Addr1", order.BillingAddress1);
            remotePostHelper.Add("tel", order.BillingPhoneNumber);
            remotePostHelper.Add("M_Addr2", order.BillingAddress2);
            remotePostHelper.Add("M_Business", order.BillingCompany);

            CultureInfo cultureInfo = new CultureInfo(NopContext.Current.WorkingLanguage.LanguageCulture);

            remotePostHelper.Add("lang", cultureInfo.TwoLetterISOLanguageName);

            StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId);

            if (billingStateProvince != null)
            {
                remotePostHelper.Add("M_StateCounty", billingStateProvince.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("M_StateCounty", order.BillingStateProvince);
            }
            if (!useSandBox)
            {
                remotePostHelper.Add("testMode", "0");
            }
            else
            {
                remotePostHelper.Add("testMode", "100");
            }
            //TODO remotePostHelper.Add("testMode", "101");
            remotePostHelper.Add("postcode", order.BillingZipPostalCode);
            Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId);

            if (billingCountry != null)
            {
                remotePostHelper.Add("country", billingCountry.TwoLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("country", order.BillingCountry);
            }

            remotePostHelper.Add("address", order.BillingAddress1 + "," + order.BillingCountry);
            remotePostHelper.Add("MC_callback", returnURL);
            remotePostHelper.Add("name", order.BillingFirstName + " " + order.BillingLastName);

            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                remotePostHelper.Add("delvName", order.ShippingFullName);
                string delvAddress = order.ShippingAddress1;
                delvAddress += (!string.IsNullOrEmpty(order.ShippingAddress2)) ? " " + order.ShippingAddress2 : string.Empty;
                remotePostHelper.Add("delvAddress", delvAddress);
                remotePostHelper.Add("delvPostcode", order.ShippingZipPostalCode);
                Country shippingCountry = CountryManager.GetCountryById(order.ShippingCountryId);
                remotePostHelper.Add("delvCountry", shippingCountry.TwoLetterIsoCode);
            }

            remotePostHelper.Post();
            return(string.Empty);
        }
 /// <summary>
 /// Create a new StateProvince object.
 /// </summary>
 /// <param name="stateProvinceID">Initial value of StateProvinceID.</param>
 /// <param name="stateProvinceCode">Initial value of StateProvinceCode.</param>
 /// <param name="isOnlyStateProvinceFlag">Initial value of IsOnlyStateProvinceFlag.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="rowguid">Initial value of rowguid.</param>
 /// <param name="modifiedDate">Initial value of ModifiedDate.</param>
 public static StateProvince CreateStateProvince(int stateProvinceID, string stateProvinceCode, bool isOnlyStateProvinceFlag, string name, global::System.Guid rowguid, global::System.DateTime modifiedDate)
 {
     StateProvince stateProvince = new StateProvince();
     stateProvince.StateProvinceID = stateProvinceID;
     stateProvince.StateProvinceCode = stateProvinceCode;
     stateProvince.IsOnlyStateProvinceFlag = isOnlyStateProvinceFlag;
     stateProvince.Name = name;
     stateProvince.rowguid = rowguid;
     stateProvince.ModifiedDate = modifiedDate;
     return stateProvince;
 }
Exemplo n.º 28
0
 public static StateProvinceModel ToModel(this StateProvince entity)
 {
     return(entity.MapTo <StateProvince, StateProvinceModel>());
 }
Exemplo n.º 29
0
 public static StateProvince ToEntity(this StateProvinceModel model, StateProvince destination)
 {
     return Mapper.Map(model, destination);
 }
Exemplo n.º 30
0
        protected StateProvince Save()
        {
            StateProvince stateProvince = ctrlStateProvinceInfo.SaveInfo();

            return(stateProvince);
        }