public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var customerGuid = filterContext
                               .HttpContext
                               .Request
                               .GetOwinContext()
                               .Authentication
                               .User
                               .GetCustomerGuid();

            if (customerGuid == null)
            {
                return;
            }

            var ipAddress = CommonLogic.CustomerIpAddress();

            DB.ExecuteSQL(
                @"update Customer
				set LastIPAddress = @lastIpAddress
				where CustomerGUID = @customerGuid and LastIPAddress != @lastIpAddress"                ,
                new[] {
                new SqlParameter("lastIpAddress", ipAddress),
                new SqlParameter("customerGuid", customerGuid),
            });

            DataRetentionService.UpsertLastActivity(customerGuid);
        }
        /// <summary>
        /// Updates an existing customer with the information supplied in the form
        /// </summary>
        Tuple <bool, int?> UpdateCustomer()
        {
            var customer = new Customer(CustomerId.Value);

            if (!customer.AdminCanViewCC && chkCanViewCC.Checked)
            {
                Security.LogEvent(
                    securityAction: "Can View Credit Card Updated",
                    description: "A customer's setting 'can view credit card number' has been enabled.",
                    customerUpdated: customer.CustomerID,
                    updatedBy: ThisCustomer.CustomerID,
                    customerSessionId: ThisCustomer.CurrentSessionID);
            }

            customer.UpdateCustomer(
                storeId: ssOne.SelectedStoreID,
                customerLevelId: Convert.ToInt32(ddlCustomerLevel.SelectedValue),
                email: txtEmail.Text.Trim(),
                firstName: txtFirstName.Text.Trim(),
                lastName: txtLastName.Text.Trim(),
                notes: txtNotes.Text.Trim(),
                phone: txtPhone.Text.Trim(),
                okToEmail: chkOkToEmail.Checked,
                localeSetting: ddlCustomerLocaleSetting.SelectedValue != "-1"
                                        ? ddlCustomerLocaleSetting.SelectedItem.Value
                                        : string.Empty,
                microPayBalance: !string.IsNullOrEmpty(txtMicroPay.Text.Trim())
                                        ? Localization.ParseNativeDecimal(txtMicroPay.Text)
                                        : 0,
                over13Checked: chkOver13.Checked,
                vatRegistrationId: GetVatRegId(customer),
                lockedUntil: chkAccountLocked.Checked
                                        ? DateTime.MaxValue
                                        : DateTime.Now.AddMinutes(-1),
                adminCanViewCreditCard: chkCanViewCC.Checked,
                badLogin: -1);

            //Have to handle these separately as passing a null to the aspdnsf_updCustomer sproc results in no change.
            DB.ExecuteSQL(string.Format(
                              @"UPDATE Customer SET AffiliateID = {0} WHERE CustomerID = {1};",
                              Convert.ToInt32(ddlCustomerAffiliate.SelectedValue) == 0
                                        ? "null"
                                        : ddlCustomerAffiliate.SelectedValue,
                              CustomerId.Value));

            DataRetentionService.UpsertLastActivity(CustomerId ?? 0);

            AlertMessageDisplay.PushAlertMessage("admin.customer.CustomerUpdated".StringResource(), AlertMessage.AlertType.Success);

            return(new Tuple <bool, int?>(true, null));
        }