示例#1
0
        protected void ddlTaxDisplayType_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            TaxDisplayTypeEnum taxDisplayType = (TaxDisplayTypeEnum)Enum.ToObject(typeof(TaxDisplayTypeEnum), int.Parse(this.ddlTaxDisplayType.SelectedItem.Value));

            NopContext.Current.TaxDisplayType = taxDisplayType;
            CommonHelper.ReloadCurrentPage();
        }
示例#2
0
		/// <summary>
		/// Updates the order
		/// </summary>
		/// <param name="OrderID">he order identifier</param>
		/// <param name="OrderGUID">The order identifier</param>
		/// <param name="CustomerID">The customer identifier</param>
		/// <param name="CustomerLanguageID">The customer language identifier</param>
		/// <param name="CustomerTaxDisplayType">The customer tax display type</param>
		/// <param name="OrderSubtotalInclTax">The order subtotal (incl tax)</param>
		/// <param name="OrderSubtotalExclTax">The order subtotal (excl tax)</param>
		/// <param name="OrderShippingInclTax">The order shipping (incl tax)</param>
		/// <param name="OrderShippingExclTax">The order shipping (excl tax)</param>
		/// <param name="PaymentMethodAdditionalFeeInclTax">The payment method additional fee (incl tax)</param>
		/// <param name="PaymentMethodAdditionalFeeExclTax">The payment method additional fee (excl tax)</param>
		/// <param name="OrderTax">The order tax</param>
		/// <param name="OrderTotal">The order total</param>
		/// <param name="OrderDiscount">The order discount</param>
		/// <param name="OrderSubtotalInclTaxInCustomerCurrency">The order subtotal incl tax (customer currency)</param>
		/// <param name="OrderSubtotalExclTaxInCustomerCurrency">The order subtotal excl tax (customer currency)</param>
		/// <param name="OrderShippingInclTaxInCustomerCurrency">The order shipping incl tax (customer currency)</param>
		/// <param name="OrderShippingExclTaxInCustomerCurrency">The order shipping excl tax (customer currency)</param>
		/// <param name="PaymentMethodAdditionalFeeInclTaxInCustomerCurrency">The payment method additional fee incl tax (customer currency)</param>
		/// <param name="PaymentMethodAdditionalFeeExclTaxInCustomerCurrency">The payment method additional fee excl tax (customer currency)</param>
		/// <param name="OrderTaxInCustomerCurrency">The order tax (customer currency)</param>
		/// <param name="OrderTotalInCustomerCurrency">The order total (customer currency)</param>
		/// <param name="CustomerCurrencyCode">The customer currency code</param>
		/// <param name="OrderWeight">The order weight</param>
		/// <param name="AffiliateID">The affiliate identifier</param>
		/// <param name="OrderStatus">The order status</param>
		/// <param name="AllowStoringCreditCardNumber">The value indicating whether storing of credit card number is allowed</param>
		/// <param name="CardType">The card type</param>
		/// <param name="CardName">The card name</param>
		/// <param name="CardNumber">The card number</param>
		/// <param name="MaskedCreditCardNumber">The masked credit card number</param>
		/// <param name="CardCVV2">The card CVV2</param>
		/// <param name="CardExpirationMonth">The card expiration month</param>
		/// <param name="CardExpirationYear">The card expiration year</param>
		/// <param name="PaymentMethodID">The payment method identifier</param>
		/// <param name="PaymentMethodName">The payment method name</param>
		/// <param name="AuthorizationTransactionID">The authorization transaction ID</param>
		/// <param name="AuthorizationTransactionCode">The authorization transaction code</param>
		/// <param name="AuthorizationTransactionResult">The authorization transaction result</param>
		/// <param name="CaptureTransactionID">The capture transaction ID</param>
		/// <param name="CaptureTransactionResult">The capture transaction result</param>
		/// <param name="PurchaseOrderNumber">The purchase order number</param>
		/// <param name="PaymentStatus">The payment status</param>
		/// <param name="BillingFirstName">The billing first name</param>
		/// <param name="BillingLastName">The billing last name</param>
		/// <param name="BillingPhoneNumber">he billing phone number</param>
		/// <param name="BillingEmail">The billing email</param>
		/// <param name="BillingFaxNumber">The billing fax number</param>
		/// <param name="BillingCompany">The billing company</param>
		/// <param name="BillingAddress1">The billing address 1</param>
		/// <param name="BillingAddress2">The billing address 2</param>
		/// <param name="BillingCity">The billing city</param>
		/// <param name="BillingStateProvince">The billing state/province</param>
		/// <param name="BillingStateProvinceID">The billing state/province identifier</param>
		/// <param name="BillingZipPostalCode">The billing zip/postal code</param>
		/// <param name="BillingCountry">The billing country</param>
		/// <param name="BillingCountryID">The billing country identifier</param>
		/// <param name="ShippingStatus">The shipping status</param>
		/// <param name="ShippingFirstName">The shipping first name</param>
		/// <param name="ShippingLastName">The shipping last name</param>
		/// <param name="ShippingPhoneNumber">The shipping phone number</param>
		/// <param name="ShippingEmail">The shipping email</param>
		/// <param name="ShippingFaxNumber">The shipping fax number</param>
		/// <param name="ShippingCompany">The shipping  company</param>
		/// <param name="ShippingAddress1">The shipping address 1</param>
		/// <param name="ShippingAddress2">The shipping address 2</param>
		/// <param name="ShippingCity">The shipping city</param>
		/// <param name="ShippingStateProvince">The shipping state/province</param>
		/// <param name="ShippingStateProvinceID">The shipping state/province identifier</param>
		/// <param name="ShippingZipPostalCode">The shipping zip/postal code</param>
		/// <param name="ShippingCountry">The shipping country</param>
		/// <param name="ShippingCountryID">The shipping country identifier</param>
		/// <param name="ShippingMethod">The shipping method</param>
		/// <param name="ShippingRateComputationMethodID">The shipping rate computation method identifier</param>
		/// <param name="ShippedDate">The shipped date and time</param>
		/// <param name="Deleted">A value indicating whether the entity has been deleted</param>
		/// <param name="CreatedOn">The date and time of order creation</param>
		/// <returns>Order</returns>
		public static Order UpdateOrder(int OrderID, Guid OrderGUID, int CustomerID, int CustomerLanguageID,
			TaxDisplayTypeEnum CustomerTaxDisplayType, decimal OrderSubtotalInclTax, decimal OrderSubtotalExclTax,
			decimal OrderShippingInclTax, decimal OrderShippingExclTax,
			decimal PaymentMethodAdditionalFeeInclTax, decimal PaymentMethodAdditionalFeeExclTax,
			decimal OrderTax, decimal OrderTotal, decimal OrderDiscount,
			decimal OrderSubtotalInclTaxInCustomerCurrency, decimal OrderSubtotalExclTaxInCustomerCurrency,
			decimal OrderShippingInclTaxInCustomerCurrency, decimal OrderShippingExclTaxInCustomerCurrency,
			decimal PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, decimal PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
			decimal OrderTaxInCustomerCurrency, decimal OrderTotalInCustomerCurrency,
			string CustomerCurrencyCode, decimal OrderWeight,
			int AffiliateID, OrderStatusEnum OrderStatus, bool AllowStoringCreditCardNumber,
			string CardType, string CardName, string CardNumber, string MaskedCreditCardNumber, string CardCVV2,
			string CardExpirationMonth, string CardExpirationYear, int PaymentMethodID,
			string PaymentMethodName, string AuthorizationTransactionID, string AuthorizationTransactionCode,
			string AuthorizationTransactionResult, string CaptureTransactionID, string CaptureTransactionResult,
			string PurchaseOrderNumber, PaymentStatusEnum PaymentStatus, string BillingFirstName, string BillingLastName,
			string BillingPhoneNumber, string BillingEmail, string BillingFaxNumber, string BillingCompany,
			string BillingAddress1, string BillingAddress2, string BillingCity, string BillingStateProvince,
			int BillingStateProvinceID, string BillingZipPostalCode, string BillingCountry,
			int BillingCountryID, ShippingStatusEnum ShippingStatus, string ShippingFirstName,
			string ShippingLastName, string ShippingPhoneNumber, string ShippingEmail,
			string ShippingFaxNumber, string ShippingCompany, string ShippingAddress1,
			string ShippingAddress2, string ShippingCity, string ShippingStateProvince,
			int ShippingStateProvinceID, string ShippingZipPostalCode,
			string ShippingCountry, int ShippingCountryID, string ShippingMethod, int ShippingRateComputationMethodID, DateTime? ShippedDate,
			bool Deleted, DateTime CreatedOn)
		{
			if (ShippedDate.HasValue)
				ShippedDate = DateTimeHelper.ConvertToUtcTime(ShippedDate.Value);
			CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn);

			DBOrder dbItem = DBProviderManager<DBOrderProvider>.Provider.UpdateOrder(OrderID, OrderGUID, CustomerID, CustomerLanguageID,
				(int)CustomerTaxDisplayType, OrderSubtotalInclTax, OrderSubtotalExclTax,
				OrderShippingInclTax, OrderShippingExclTax,
				PaymentMethodAdditionalFeeInclTax, PaymentMethodAdditionalFeeExclTax,
				OrderTax, OrderTotal, OrderDiscount,
				OrderSubtotalInclTaxInCustomerCurrency, OrderSubtotalExclTaxInCustomerCurrency,
				OrderShippingInclTaxInCustomerCurrency, OrderShippingExclTaxInCustomerCurrency,
				PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,
				OrderTaxInCustomerCurrency, OrderTotalInCustomerCurrency, CustomerCurrencyCode, OrderWeight,
				AffiliateID, (int)OrderStatus, AllowStoringCreditCardNumber,
				CardType, CardName, CardNumber, MaskedCreditCardNumber, CardCVV2,
				CardExpirationMonth, CardExpirationYear, PaymentMethodID,
				PaymentMethodName, AuthorizationTransactionID, AuthorizationTransactionCode,
				AuthorizationTransactionResult, CaptureTransactionID, CaptureTransactionResult, PurchaseOrderNumber,
				(int)PaymentStatus, BillingFirstName, BillingLastName,
				BillingPhoneNumber, BillingEmail, BillingFaxNumber, BillingCompany,
				BillingAddress1, BillingAddress2, BillingCity, BillingStateProvince, BillingStateProvinceID,
				BillingZipPostalCode, BillingCountry, BillingCountryID, (int)ShippingStatus, ShippingFirstName, ShippingLastName,
				ShippingPhoneNumber, ShippingEmail,
				ShippingFaxNumber, ShippingCompany, ShippingAddress1,
				ShippingAddress2, ShippingCity, ShippingStateProvince, ShippingStateProvinceID, ShippingZipPostalCode,
				ShippingCountry, ShippingCountryID, ShippingMethod, ShippingRateComputationMethodID, ShippedDate,
				Deleted, CreatedOn);

			Order order = DBMapping(dbItem);
			return order;
		}
        /// <summary>
        /// Adds a customer without any validations, welcome messages
        /// </summary>
        /// <param name="customerGuid">The customer identifier</param>
        /// <param name="email">The email</param>
        /// <param name="username">The username</param>
        /// <param name="passwordHash">The password hash</param>
        /// <param name="saltKey">The salt key</param>
        /// <param name="affiliateId">The affiliate identifier</param>
        /// <param name="billingAddressId">The billing address identifier</param>
        /// <param name="shippingAddressId">The shipping address identifier</param>
        /// <param name="lastPaymentMethodId">The last payment method identifier</param>
        /// <param name="lastAppliedCouponCode">The last applied coupon code</param>
        /// <param name="giftCardCouponCodes">The applied gift card coupon code</param>
        /// <param name="checkoutAttributes">The selected checkout attributes</param>
        /// <param name="languageId">The language identifier</param>
        /// <param name="currencyId">The currency identifier</param>
        /// <param name="taxDisplayType">The tax display type</param>
        /// <param name="isTaxExempt">A value indicating whether the customer is tax exempt</param>
        /// <param name="isAdmin">A value indicating whether the customer is administrator</param>
        /// <param name="isGuest">A value indicating whether the customer is guest</param>
        /// <param name="isForumModerator">A value indicating whether the customer is forum moderator</param>
        /// <param name="totalForumPosts">A forum post count</param>
        /// <param name="signature">Signature</param>
        /// <param name="adminComment">Admin comment</param>
        /// <param name="active">A value indicating whether the customer is active</param>
        /// <param name="deleted">A value indicating whether the customer has been deleted</param>
        /// <param name="registrationDate">The date and time of customer registration</param>
        /// <param name="timeZoneId">The time zone identifier</param>
        /// <param name="avatarId">The avatar identifier</param>
        /// <param name="dateOfBirth">Date of birth</param>
        /// <returns>A customer</returns>
        public Customer AddCustomerForced(Guid customerGuid, string email,
            string username, string passwordHash, string saltKey,
            int affiliateId, int billingAddressId,
            int shippingAddressId, int lastPaymentMethodId,
            string lastAppliedCouponCode, string giftCardCouponCodes,
            string checkoutAttributes, int languageId,
            int currencyId, TaxDisplayTypeEnum taxDisplayType, bool isTaxExempt,
            bool isAdmin, bool isGuest, bool isForumModerator,
            int totalForumPosts, string signature, string adminComment, 
            bool active, bool deleted, DateTime registrationDate, string timeZoneId,
            int avatarId, DateTime? dateOfBirth)
        {
            email = CommonHelper.EnsureNotNull(email);
            email = email.Trim();
            email = CommonHelper.EnsureMaximumLength(email, 255);
            username = CommonHelper.EnsureNotNull(username);
            username = username.Trim();
            username = CommonHelper.EnsureMaximumLength(username, 100);
            passwordHash = CommonHelper.EnsureNotNull(passwordHash);
            passwordHash = CommonHelper.EnsureMaximumLength(passwordHash, 255);
            saltKey = CommonHelper.EnsureNotNull(saltKey);
            saltKey = CommonHelper.EnsureMaximumLength(saltKey, 255);
            lastAppliedCouponCode = CommonHelper.EnsureNotNull(lastAppliedCouponCode);
            lastAppliedCouponCode = CommonHelper.EnsureMaximumLength(lastAppliedCouponCode, 100);
            signature = CommonHelper.EnsureNotNull(signature);
            signature = CommonHelper.EnsureMaximumLength(signature, 300);
            adminComment = CommonHelper.EnsureNotNull(adminComment);
            adminComment = CommonHelper.EnsureMaximumLength(adminComment, 4000);
            timeZoneId = CommonHelper.EnsureNotNull(timeZoneId);
            timeZoneId = CommonHelper.EnsureMaximumLength(timeZoneId, 200);

            var customer = _context.Customers.CreateObject();
            customer.CustomerGuid = customerGuid;
            customer.Email = email;
            customer.Username = username;
            customer.PasswordHash = passwordHash;
            customer.SaltKey = saltKey;
            customer.AffiliateId = affiliateId;
            customer.BillingAddressId = billingAddressId;
            customer.ShippingAddressId = shippingAddressId;
            customer.LastPaymentMethodId = lastPaymentMethodId;
            customer.LastAppliedCouponCode = lastAppliedCouponCode;
            customer.GiftCardCouponCodes = giftCardCouponCodes;
            customer.CheckoutAttributes = checkoutAttributes;
            customer.LanguageId = languageId;
            customer.CurrencyId = currencyId;
            customer.TaxDisplayTypeId = (int)taxDisplayType;
            customer.IsTaxExempt = isTaxExempt;
            customer.IsAdmin = isAdmin;
            customer.IsGuest = isGuest;
            customer.IsForumModerator = isForumModerator;
            customer.TotalForumPosts = totalForumPosts;
            customer.Signature = signature;
            customer.AdminComment = adminComment;
            customer.Active = active;
            customer.Deleted = deleted;
            customer.RegistrationDate = registrationDate;
            customer.TimeZoneId = timeZoneId;
            customer.AvatarId = avatarId;
            customer.DateOfBirth = dateOfBirth;

            _context.Customers.AddObject(customer);
            _context.SaveChanges();

            //reward points
            if (!isGuest &&
                IoC.Resolve<IOrderService>().RewardPointsEnabled &&
                IoC.Resolve<IOrderService>().RewardPointsForRegistration > 0)
            {
                IoC.Resolve<IOrderService>().InsertRewardPointsHistory(customer.CustomerId, 0,
                    IoC.Resolve<IOrderService>().RewardPointsForRegistration, decimal.Zero, decimal.Zero,
                    string.Empty, IoC.Resolve<ILocalizationManager>().GetLocaleResourceString("RewardPoints.Message.EarnedForRegistration"),
                    DateTime.UtcNow);
            }

            //raise event
            EventContext.Current.OnCustomerCreated(null,
                new CustomerEventArgs() { Customer = customer});

            return customer;
        }
        /// <summary>
        /// Adds a customer
        /// </summary>
        /// <param name="customerGuid">The customer identifier</param>
        /// <param name="email">The email</param>
        /// <param name="username">The username</param>
        /// <param name="password">The password</param>
        /// <param name="affiliateId">The affiliate identifier</param>
        /// <param name="billingAddressId">The billing address identifier</param>
        /// <param name="shippingAddressId">The shipping address identifier</param>
        /// <param name="lastPaymentMethodId">The last payment method identifier</param>
        /// <param name="lastAppliedCouponCode">The last applied coupon code</param>
        /// <param name="giftCardCouponCodes">The applied gift card coupon code</param>
        /// <param name="checkoutAttributes">The selected checkout attributes</param>
        /// <param name="languageId">The language identifier</param>
        /// <param name="currencyId">The currency identifier</param>
        /// <param name="taxDisplayType">The tax display type</param>
        /// <param name="isTaxExempt">A value indicating whether the customer is tax exempt</param>
        /// <param name="isAdmin">A value indicating whether the customer is administrator</param>
        /// <param name="isGuest">A value indicating whether the customer is guest</param>
        /// <param name="isForumModerator">A value indicating whether the customer is forum moderator</param>
        /// <param name="totalForumPosts">A forum post count</param>
        /// <param name="signature">Signature</param>
        /// <param name="adminComment">Admin comment</param>
        /// <param name="active">A value indicating whether the customer is active</param>
        /// <param name="deleted">A value indicating whether the customer has been deleted</param>
        /// <param name="registrationDate">The date and time of customer registration</param>
        /// <param name="timeZoneId">The time zone identifier</param>
        /// <param name="avatarId">The avatar identifier</param>
        /// <param name="dateOfBirth">Date of birth</param>
        /// <param name="status">Status</param>
        /// <returns>A customer</returns>
        public Customer AddCustomer(Guid customerGuid, string email, string username,
            string password, int affiliateId, int billingAddressId,
            int shippingAddressId, int lastPaymentMethodId,
            string lastAppliedCouponCode, string giftCardCouponCodes,
            string checkoutAttributes, int languageId, int currencyId,
            TaxDisplayTypeEnum taxDisplayType, bool isTaxExempt, bool isAdmin, bool isGuest,
            bool isForumModerator, int totalForumPosts, string signature, string adminComment,
            bool active, bool deleted, DateTime registrationDate,
            string timeZoneId, int avatarId, DateTime? dateOfBirth, out MembershipCreateStatus status)
        {
            Customer customer = null;

            if (username == null)
                username = string.Empty;
            username = username.Trim();

            if (email == null)
                email = string.Empty;
            email = email.Trim();

            if (signature == null)
                signature = string.Empty;
            signature = signature.Trim();

            string saltKey = string.Empty;
            string passwordHash = string.Empty;

            status = MembershipCreateStatus.UserRejected;
            if (!isGuest)
            {
                if (!NopContext.Current.IsAdmin)
                {
                    if (this.CustomerRegistrationType == CustomerRegistrationTypeEnum.Disabled)
                    {
                        status = MembershipCreateStatus.ProviderError;
                        return customer;
                    }
                }

                if (this.UsernamesEnabled)
                {
                    if (GetCustomerByUsername(username) != null)
                    {
                        status = MembershipCreateStatus.DuplicateUserName;
                        return customer;
                    }

                    if (username.Length > 100)
                    {
                        status = MembershipCreateStatus.InvalidUserName;
                        return customer;
                    }
                }

                if (GetCustomerByEmail(email) != null)
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                    return customer;
                }

                if (!CommonHelper.IsValidEmail(email))
                {
                    status = MembershipCreateStatus.InvalidEmail;
                    return customer;
                }

                if (email.Length > 100)
                {
                    status = MembershipCreateStatus.InvalidEmail;
                    return customer;
                }

                if (!NopContext.Current.IsAdmin)
                {
                    if (this.CustomerRegistrationType == CustomerRegistrationTypeEnum.EmailValidation ||
                        this.CustomerRegistrationType == CustomerRegistrationTypeEnum.AdminApproval)
                    {
                        active = false;
                    }
                }
                saltKey = CreateSalt(5);
                passwordHash = CreatePasswordHash(password, saltKey);
            }

            customer = AddCustomerForced(customerGuid, email, username,
                passwordHash, saltKey, affiliateId, billingAddressId,
                shippingAddressId, lastPaymentMethodId,
                lastAppliedCouponCode, giftCardCouponCodes,
                checkoutAttributes, languageId, currencyId, taxDisplayType,
                isTaxExempt, isAdmin, isGuest, isForumModerator,
                totalForumPosts, signature, adminComment, active,
                deleted, registrationDate, timeZoneId, avatarId, dateOfBirth);

            if (!isGuest)
            {
                DateTime lastAccessed = DateTime.UtcNow;
                SaveCustomerSession(Guid.NewGuid(), customer.CustomerId, lastAccessed, false);
            }

            status = MembershipCreateStatus.Success;

            if (!isGuest)
            {
                if (active)
                {
                    IoC.Resolve<IMessageService>().SendCustomerWelcomeMessage(customer, NopContext.Current.WorkingLanguage.LanguageId);
                }
                else
                {
                    if (this.CustomerRegistrationType == CustomerRegistrationTypeEnum.EmailValidation)
                    {
                        Guid accountActivationToken = Guid.NewGuid();
                        customer.AccountActivationToken = accountActivationToken.ToString();

                        IoC.Resolve<IMessageService>().SendCustomerEmailValidationMessage(customer, NopContext.Current.WorkingLanguage.LanguageId);
                    }
                }
            }
            return customer;
        }
示例#5
0
        /// <summary>
        /// Updates the order
        /// </summary>
        /// <param name="orderId">The order identifier</param>
        /// <param name="orderGuid">The order identifier</param>
        /// <param name="customerId">The customer identifier</param>
        /// <param name="customerLanguageId">The customer language identifier</param>
        /// <param name="customerTaxDisplayType">The customer tax display type</param>
        /// <param name="customerIP">The customer IP address</param>
        /// <param name="orderSubtotalInclTax">The order subtotal (incl tax)</param>
        /// <param name="orderSubtotalExclTax">The order subtotal (excl tax)</param>
        /// <param name="orderShippingInclTax">The order shipping (incl tax)</param>
        /// <param name="orderShippingExclTax">The order shipping (excl tax)</param>
        /// <param name="paymentMethodAdditionalFeeInclTax">The payment method additional fee (incl tax)</param>
        /// <param name="paymentMethodAdditionalFeeExclTax">The payment method additional fee (excl tax)</param>
        /// <param name="taxRates">The tax rates</param>
        /// <param name="orderTax">The order tax</param>
        /// <param name="orderTotal">The order total</param>
        /// <param name="refundedAmount">The refunded amount</param>
        /// <param name="orderDiscount">The order discount</param>
        /// <param name="orderSubtotalInclTaxInCustomerCurrency">The order subtotal incl tax (customer currency)</param>
        /// <param name="orderSubtotalExclTaxInCustomerCurrency">The order subtotal excl tax (customer currency)</param>
        /// <param name="orderShippingInclTaxInCustomerCurrency">The order shipping incl tax (customer currency)</param>
        /// <param name="orderShippingExclTaxInCustomerCurrency">The order shipping excl tax (customer currency)</param>
        /// <param name="paymentMethodAdditionalFeeInclTaxInCustomerCurrency">The payment method additional fee incl tax (customer currency)</param>
        /// <param name="paymentMethodAdditionalFeeExclTaxInCustomerCurrency">The payment method additional fee excl tax (customer currency)</param>
        /// <param name="taxRatesInCustomerCurrency">The tax rates (customer currency)</param>
        /// <param name="orderTaxInCustomerCurrency">The order tax (customer currency)</param>
        /// <param name="orderTotalInCustomerCurrency">The order total (customer currency)</param>
        /// <param name="orderDiscountInCustomerCurrency">The order discount (customer currency)</param>
        /// <param name="checkoutAttributeDescription">The checkout attribute description</param>
        /// <param name="checkoutAttributesXml">The checkout attributes in XML format</param>
        /// <param name="customerCurrencyCode">The customer currency code</param>
        /// <param name="orderWeight">The order weight</param>
        /// <param name="affiliateId">The affiliate identifier</param>
        /// <param name="orderStatus">The order status</param>
        /// <param name="allowStoringCreditCardNumber">The value indicating whether storing of credit card number is allowed</param>
        /// <param name="cardType">The card type</param>
        /// <param name="cardName">The card name</param>
        /// <param name="cardNumber">The card number</param>
        /// <param name="maskedCreditCardNumber">The masked credit card number</param>
        /// <param name="cardCvv2">The card CVV2</param>
        /// <param name="cardExpirationMonth">The card expiration month</param>
        /// <param name="cardExpirationYear">The card expiration year</param>
        /// <param name="paymentMethodId">The payment method identifier</param>
        /// <param name="paymentMethodName">The payment method name</param>
        /// <param name="authorizationTransactionId">The authorization transaction identifier</param>
        /// <param name="authorizationTransactionCode">The authorization transaction code</param>
        /// <param name="authorizationTransactionResult">The authorization transaction result</param>
        /// <param name="captureTransactionId">The capture transaction identifier</param>
        /// <param name="captureTransactionResult">The capture transaction result</param>
        /// <param name="subscriptionTransactionId">The subscription transaction identifier</param>
        /// <param name="purchaseOrderNumber">The purchase order number</param>
        /// <param name="paymentStatus">The payment status</param>
        /// <param name="paidDate">The paid date and time</param>
        /// <param name="billingFirstName">The billing first name</param>
        /// <param name="billingLastName">The billing last name</param>
        /// <param name="billingPhoneNumber">he billing phone number</param>
        /// <param name="billingEmail">The billing email</param>
        /// <param name="billingFaxNumber">The billing fax number</param>
        /// <param name="billingCompany">The billing company</param>
        /// <param name="billingAddress1">The billing address 1</param>
        /// <param name="billingAddress2">The billing address 2</param>
        /// <param name="billingCity">The billing city</param>
        /// <param name="billingStateProvince">The billing state/province</param>
        /// <param name="billingStateProvinceId">The billing state/province identifier</param>
        /// <param name="billingZipPostalCode">The billing zip/postal code</param>
        /// <param name="billingCountry">The billing country</param>
        /// <param name="billingCountryId">The billing country identifier</param>
        /// <param name="shippingStatus">The shipping status</param>
        /// <param name="shippingFirstName">The shipping first name</param>
        /// <param name="shippingLastName">The shipping last name</param>
        /// <param name="shippingPhoneNumber">The shipping phone number</param>
        /// <param name="shippingEmail">The shipping email</param>
        /// <param name="shippingFaxNumber">The shipping fax number</param>
        /// <param name="shippingCompany">The shipping  company</param>
        /// <param name="shippingAddress1">The shipping address 1</param>
        /// <param name="shippingAddress2">The shipping address 2</param>
        /// <param name="shippingCity">The shipping city</param>
        /// <param name="shippingStateProvince">The shipping state/province</param>
        /// <param name="shippingStateProvinceId">The shipping state/province identifier</param>
        /// <param name="shippingZipPostalCode">The shipping zip/postal code</param>
        /// <param name="shippingCountry">The shipping country</param>
        /// <param name="shippingCountryId">The shipping country identifier</param>
        /// <param name="shippingMethod">The shipping method</param>
        /// <param name="shippingRateComputationMethodId">The shipping rate computation method identifier</param>
        /// <param name="shippedDate">The shipped date and time</param>
        /// <param name="deliveryDate">The delivery date and time</param>
        /// <param name="trackingNumber">The tracking number of order</param>
        /// <param name="vatNumber">The VAT number (the European Union Value Added Tax)</param>
        /// <param name="deleted">A value indicating whether the entity has been deleted</param>
        /// <param name="createdOn">The date and time of order creation</param>
        /// <returns>Order</returns>
        public static Order UpdateOrder(int orderId,
            Guid orderGuid,
            int customerId,
            int customerLanguageId,
            TaxDisplayTypeEnum customerTaxDisplayType,
            string customerIP,
            decimal orderSubtotalInclTax,
            decimal orderSubtotalExclTax,
            decimal orderShippingInclTax,
            decimal orderShippingExclTax,
            decimal paymentMethodAdditionalFeeInclTax,
            decimal paymentMethodAdditionalFeeExclTax,
            string taxRates,
            decimal orderTax,
            decimal orderTotal,
            decimal refundedAmount,
            decimal orderDiscount,
            decimal orderSubtotalInclTaxInCustomerCurrency,
            decimal orderSubtotalExclTaxInCustomerCurrency,
            decimal orderShippingInclTaxInCustomerCurrency,
            decimal orderShippingExclTaxInCustomerCurrency,
            decimal paymentMethodAdditionalFeeInclTaxInCustomerCurrency,
            decimal paymentMethodAdditionalFeeExclTaxInCustomerCurrency,
            string taxRatesInCustomerCurrency,
            decimal orderTaxInCustomerCurrency,
            decimal orderTotalInCustomerCurrency,
            decimal orderDiscountInCustomerCurrency,
            string checkoutAttributeDescription,
            string checkoutAttributesXml,
            string customerCurrencyCode,
            decimal orderWeight,
            int affiliateId,
            OrderStatusEnum orderStatus,
            bool allowStoringCreditCardNumber,
            string cardType,
            string cardName,
            string cardNumber,
            string maskedCreditCardNumber,
            string cardCvv2,
            string cardExpirationMonth,
            string cardExpirationYear,
            int paymentMethodId,
            string paymentMethodName,
            string authorizationTransactionId,
            string authorizationTransactionCode,
            string authorizationTransactionResult,
            string captureTransactionId,
            string captureTransactionResult,
            string subscriptionTransactionId,
            string purchaseOrderNumber,
            PaymentStatusEnum paymentStatus,
            DateTime? paidDate,
            string billingFirstName,
            string billingLastName,
            string billingPhoneNumber,
            string billingEmail,
            string billingFaxNumber,
            string billingCompany,
            string billingAddress1,
            string billingAddress2,
            string billingCity,
            string billingStateProvince,
            int billingStateProvinceId,
            string billingZipPostalCode,
            string billingCountry,
            int billingCountryId,
            ShippingStatusEnum shippingStatus,
            string shippingFirstName,
            string shippingLastName,
            string shippingPhoneNumber,
            string shippingEmail,
            string shippingFaxNumber,
            string shippingCompany,
            string shippingAddress1,
            string shippingAddress2,
            string shippingCity,
            string shippingStateProvince,
            int shippingStateProvinceId,
            string shippingZipPostalCode,
            string shippingCountry,
            int shippingCountryId,
            string shippingMethod,
            int shippingRateComputationMethodId,
            DateTime? shippedDate,
            DateTime? deliveryDate,
            string trackingNumber,
            string vatNumber,
            bool deleted,
            DateTime createdOn)
        {
            if (trackingNumber == null)
                trackingNumber = string.Empty;

            taxRates = CommonHelper.EnsureMaximumLength(taxRates, 4000);
            taxRatesInCustomerCurrency = CommonHelper.EnsureMaximumLength(taxRatesInCustomerCurrency, 4000);
            customerIP = CommonHelper.EnsureMaximumLength(customerIP, 50);
            cardType = CommonHelper.EnsureMaximumLength(cardType, 100);
            cardName = CommonHelper.EnsureMaximumLength(cardName, 1000);
            cardNumber = CommonHelper.EnsureMaximumLength(cardNumber, 100);
            maskedCreditCardNumber = CommonHelper.EnsureMaximumLength(maskedCreditCardNumber, 100);
            cardCvv2 = CommonHelper.EnsureMaximumLength(cardCvv2, 100);
            cardExpirationMonth = CommonHelper.EnsureMaximumLength(cardExpirationMonth, 100);
            cardExpirationYear = CommonHelper.EnsureMaximumLength(cardExpirationYear, 100);
            paymentMethodName = CommonHelper.EnsureMaximumLength(paymentMethodName, 100);
            authorizationTransactionId = CommonHelper.EnsureMaximumLength(authorizationTransactionId, 4000);
            authorizationTransactionCode = CommonHelper.EnsureMaximumLength(authorizationTransactionCode, 4000);
            authorizationTransactionResult = CommonHelper.EnsureMaximumLength(authorizationTransactionResult, 4000);
            captureTransactionId = CommonHelper.EnsureMaximumLength(captureTransactionId, 4000);
            captureTransactionResult = CommonHelper.EnsureMaximumLength(captureTransactionResult, 4000);
            subscriptionTransactionId = CommonHelper.EnsureMaximumLength(subscriptionTransactionId, 4000);
            purchaseOrderNumber = CommonHelper.EnsureMaximumLength(purchaseOrderNumber, 100);
            billingFirstName = CommonHelper.EnsureMaximumLength(billingFirstName, 100);
            billingLastName = CommonHelper.EnsureMaximumLength(billingLastName, 100);
            billingPhoneNumber = CommonHelper.EnsureMaximumLength(billingPhoneNumber, 50);
            billingEmail = CommonHelper.EnsureMaximumLength(billingEmail, 255);
            billingFaxNumber = CommonHelper.EnsureMaximumLength(billingFaxNumber, 50);
            billingCompany = CommonHelper.EnsureMaximumLength(billingCompany, 100);
            billingAddress1 = CommonHelper.EnsureMaximumLength(billingAddress1, 100);
            billingAddress2 = CommonHelper.EnsureMaximumLength(billingAddress2, 100);
            billingCity = CommonHelper.EnsureMaximumLength(billingCity, 100);
            billingStateProvince = CommonHelper.EnsureMaximumLength(billingStateProvince, 100);
            billingZipPostalCode = CommonHelper.EnsureMaximumLength(billingZipPostalCode, 30);
            billingCountry = CommonHelper.EnsureMaximumLength(billingCountry, 100);
            shippingFirstName = CommonHelper.EnsureMaximumLength(shippingFirstName, 100);
            shippingLastName = CommonHelper.EnsureMaximumLength(shippingLastName, 100);
            shippingPhoneNumber = CommonHelper.EnsureMaximumLength(shippingPhoneNumber, 50);
            shippingEmail = CommonHelper.EnsureMaximumLength(shippingEmail, 255);
            shippingFaxNumber = CommonHelper.EnsureMaximumLength(shippingFaxNumber, 50);
            shippingCompany = CommonHelper.EnsureMaximumLength(shippingCompany, 100);
            shippingAddress1 = CommonHelper.EnsureMaximumLength(shippingAddress1, 100);
            shippingAddress2 = CommonHelper.EnsureMaximumLength(shippingAddress2, 100);
            shippingCity = CommonHelper.EnsureMaximumLength(shippingCity, 100);
            shippingStateProvince = CommonHelper.EnsureMaximumLength(shippingStateProvince, 100);
            shippingZipPostalCode = CommonHelper.EnsureMaximumLength(shippingZipPostalCode, 30);
            shippingCountry = CommonHelper.EnsureMaximumLength(shippingCountry, 100);
            shippingMethod = CommonHelper.EnsureMaximumLength(shippingMethod, 100);
            trackingNumber = CommonHelper.EnsureMaximumLength(trackingNumber, 100);
            vatNumber = CommonHelper.EnsureMaximumLength(vatNumber, 100);

            var order = GetOrderById(orderId);
            if (order == null)
                return null;

            var context = ObjectContextHelper.CurrentObjectContext;
            if (!context.IsAttached(order))
                context.Orders.Attach(order);

            order.OrderGuid = orderGuid;
            order.CustomerId = customerId;
            order.CustomerLanguageId = customerLanguageId;
            order.CustomerTaxDisplayTypeId = (int)customerTaxDisplayType;
            order.CustomerIP = customerIP;
            order.OrderSubtotalInclTax = orderSubtotalInclTax;
            order.OrderSubtotalExclTax = orderSubtotalExclTax;
            order.OrderShippingInclTax = orderShippingInclTax;
            order.OrderShippingExclTax = orderShippingExclTax;
            order.PaymentMethodAdditionalFeeInclTax = paymentMethodAdditionalFeeInclTax;
            order.PaymentMethodAdditionalFeeExclTax = paymentMethodAdditionalFeeExclTax;
            order.TaxRates = taxRates;
            order.OrderTax = orderTax;
            order.OrderTotal = orderTotal;
            order.RefundedAmount = refundedAmount;
            order.OrderDiscount = orderDiscount;
            order.OrderSubtotalInclTaxInCustomerCurrency = orderSubtotalInclTaxInCustomerCurrency;
            order.OrderSubtotalExclTaxInCustomerCurrency = orderSubtotalExclTaxInCustomerCurrency;
            order.OrderShippingInclTaxInCustomerCurrency = orderShippingInclTaxInCustomerCurrency;
            order.OrderShippingExclTaxInCustomerCurrency = orderShippingExclTaxInCustomerCurrency;
            order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency = paymentMethodAdditionalFeeInclTaxInCustomerCurrency;
            order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency = paymentMethodAdditionalFeeExclTaxInCustomerCurrency;
            order.TaxRatesInCustomerCurrency = taxRatesInCustomerCurrency;
            order.OrderTaxInCustomerCurrency = orderTaxInCustomerCurrency;
            order.OrderTotalInCustomerCurrency = orderTotalInCustomerCurrency;
            order.OrderDiscountInCustomerCurrency = orderDiscountInCustomerCurrency;
            order.CheckoutAttributeDescription = checkoutAttributeDescription;
            order.CheckoutAttributesXml = checkoutAttributesXml;
            order.CustomerCurrencyCode = customerCurrencyCode;
            order.OrderWeight = orderWeight;
            order.AffiliateId = affiliateId;
            order.OrderStatusId = (int)orderStatus;
            order.AllowStoringCreditCardNumber = allowStoringCreditCardNumber;
            order.CardType = cardType;
            order.CardName = cardName;
            order.CardNumber = cardNumber;
            order.MaskedCreditCardNumber = maskedCreditCardNumber;
            order.CardCvv2 = cardCvv2;
            order.CardExpirationMonth = cardExpirationMonth;
            order.CardExpirationYear = cardExpirationYear;
            order.PaymentMethodId = paymentMethodId;
            order.PaymentMethodName = paymentMethodName;
            order.AuthorizationTransactionId = authorizationTransactionId;
            order.AuthorizationTransactionCode = authorizationTransactionCode;
            order.AuthorizationTransactionResult = authorizationTransactionResult;
            order.CaptureTransactionId = captureTransactionId;
            order.CaptureTransactionResult = captureTransactionResult;
            order.SubscriptionTransactionId = subscriptionTransactionId;
            order.PurchaseOrderNumber = purchaseOrderNumber;
            order.PaymentStatusId = (int)paymentStatus;
            order.PaidDate = paidDate;
            order.BillingFirstName = billingFirstName;
            order.BillingLastName = billingLastName;
            order.BillingPhoneNumber = billingPhoneNumber;
            order.BillingEmail = billingEmail;
            order.BillingFaxNumber = billingFaxNumber;
            order.BillingCompany = billingCompany;
            order.BillingAddress1 = billingAddress1;
            order.BillingAddress2 = billingAddress2;
            order.BillingCity = billingCity;
            order.BillingStateProvince = billingStateProvince;
            order.BillingStateProvinceId = billingStateProvinceId;
            order.BillingZipPostalCode = billingZipPostalCode;
            order.BillingCountry = billingCountry;
            order.BillingCountryId = billingCountryId;
            order.ShippingStatusId = (int)shippingStatus;
            order.ShippingFirstName = shippingFirstName;
            order.ShippingLastName = shippingLastName;
            order.ShippingPhoneNumber = shippingPhoneNumber;
            order.ShippingEmail = shippingEmail;
            order.ShippingFaxNumber = shippingFaxNumber;
            order.ShippingCompany = shippingCompany;
            order.ShippingAddress1 = shippingAddress1;
            order.ShippingAddress2 = shippingAddress2;
            order.ShippingCity = shippingCity;
            order.ShippingStateProvince = shippingStateProvince;
            order.ShippingStateProvinceId = shippingStateProvinceId;
            order.ShippingZipPostalCode = shippingZipPostalCode;
            order.ShippingCountry = shippingCountry;
            order.ShippingCountryId = shippingCountryId;
            order.ShippingMethod = shippingMethod;
            order.ShippingRateComputationMethodId = shippingRateComputationMethodId;
            order.ShippedDate = shippedDate;
            order.DeliveryDate = deliveryDate;
            order.TrackingNumber = trackingNumber;
            order.VatNumber = vatNumber;
            order.Deleted = deleted;
            order.CreatedOn = createdOn;
            context.SaveChanges();

            //quickbooks
            if (QBManager.QBIsEnabled)
            {
                QBManager.RequestSynchronization(order);
            }

            //raise event
            EventContext.Current.OnOrderUpdated(null,
                new OrderEventArgs() { Order = order });

            return order;
        }
示例#6
0
        /// <summary>
        /// Updates the customer
        /// </summary>
        /// <param name="customerId">The customer identifier</param>
        /// <param name="customerGuid">The customer identifier</param>
        /// <param name="email">The email</param>
        /// <param name="username">The username</param>
        /// <param name="passwordHash">The password hash</param>
        /// <param name="saltKey">The salt key</param>
        /// <param name="affiliateId">The affiliate identifier</param>
        /// <param name="billingAddressId">The billing address identifier</param>
        /// <param name="shippingAddressId">The shipping address identifier</param>
        /// <param name="lastPaymentMethodId">The last payment method identifier</param>
        /// <param name="lastAppliedCouponCode">The last applied coupon code</param>
        /// <param name="giftCardCouponCodes">The applied gift card coupon code</param>
        /// <param name="checkoutAttributes">The selected checkout attributes</param>
        /// <param name="languageId">The language identifier</param>
        /// <param name="currencyId">The currency identifier</param>
        /// <param name="taxDisplayType">The tax display type</param>
        /// <param name="isTaxExempt">A value indicating whether the customer is tax exempt</param>
        /// <param name="isAdmin">A value indicating whether the customer is administrator</param>
        /// <param name="isGuest">A value indicating whether the customer is guest</param>
        /// <param name="isForumModerator">A value indicating whether the customer is forum moderator</param>
        /// <param name="totalForumPosts">A forum post count</param>
        /// <param name="signature">Signature</param>
        /// <param name="adminComment">Admin comment</param>
        /// <param name="active">A value indicating whether the customer is active</param>
        /// <param name="deleted">A value indicating whether the customer has been deleted</param>
        /// <param name="registrationDate">The date and time of customer registration</param>
        /// <param name="timeZoneId">The time zone identifier</param>
        /// <param name="avatarId">The avatar identifier</param>
        /// <param name="dateOfBirth">Date of birth</param>
        /// <returns>A customer</returns>
        public static Customer UpdateCustomer(int customerId,
                                              Guid customerGuid, string email,
                                              string username, string passwordHash, string saltKey,
                                              int affiliateId, int billingAddressId,
                                              int shippingAddressId, int lastPaymentMethodId,
                                              string lastAppliedCouponCode, string giftCardCouponCodes,
                                              string checkoutAttributes, int languageId,
                                              int currencyId, TaxDisplayTypeEnum taxDisplayType,
                                              bool isTaxExempt, bool isAdmin, bool isGuest, bool isForumModerator,
                                              int totalForumPosts, string signature, string adminComment,
                                              bool active, bool deleted, DateTime registrationDate,
                                              string timeZoneId, int avatarId, DateTime? dateOfBirth)
        {
            if (username == null)
                username = string.Empty;
            username = username.Trim();

            if (email == null)
                email = string.Empty;
            email = email.Trim();

            if (signature == null)
                signature = string.Empty;
            signature = signature.Trim();

            email = CommonHelper.EnsureMaximumLength(email, 255);
            username = CommonHelper.EnsureMaximumLength(username, 100);
            passwordHash = CommonHelper.EnsureMaximumLength(passwordHash, 255);
            saltKey = CommonHelper.EnsureMaximumLength(saltKey, 255);
            signature = CommonHelper.EnsureMaximumLength(signature, 300);
            adminComment = CommonHelper.EnsureMaximumLength(adminComment, 4000);
            timeZoneId = CommonHelper.EnsureMaximumLength(timeZoneId, 200);

            Customer customer = GetCustomerById(customerId);
            if (customer == null)
                return null;

            NewsLetterSubscription subscriptionOld = customer.NewsLetterSubscription;

            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;
            if (!context.IsAttached(customer))
                context.Customers.Attach(customer);
            customer.CustomerGuid = customerGuid;
            customer.Email = email;
            customer.Username = username;
            customer.PasswordHash = passwordHash;
            customer.SaltKey = saltKey;
            customer.AffiliateId = affiliateId;
            customer.BillingAddressId = billingAddressId;
            customer.ShippingAddressId = shippingAddressId;
            customer.LastPaymentMethodId = lastPaymentMethodId;
            customer.LastAppliedCouponCode = lastAppliedCouponCode;
            customer.GiftCardCouponCodes = giftCardCouponCodes;
            customer.CheckoutAttributes = checkoutAttributes;
            customer.LanguageId = languageId;
            customer.CurrencyId = currencyId;
            customer.TaxDisplayTypeId = (int) taxDisplayType;
            customer.IsTaxExempt = isTaxExempt;
            customer.IsAdmin = isAdmin;
            customer.IsGuest = isGuest;
            customer.IsForumModerator = isForumModerator;
            customer.TotalForumPosts = totalForumPosts;
            customer.Signature = signature;
            customer.AdminComment = adminComment;
            customer.Active = active;
            customer.Deleted = deleted;
            customer.RegistrationDate = registrationDate;
            customer.TimeZoneId = timeZoneId;
            customer.AvatarId = avatarId;
            customer.DateOfBirth = dateOfBirth;
            context.SaveChanges();

            if (subscriptionOld != null && !email.ToLower().Equals(subscriptionOld.Email.ToLower()))
            {
                MessageManager.UpdateNewsLetterSubscription(subscriptionOld.NewsLetterSubscriptionId,
                                                            email, subscriptionOld.Active);
            }

            //raise event
            EventContext.Current.OnCustomerUpdated(null,
                                                   new CustomerEventArgs {Customer = customer});

            return customer;
        }