Exemple #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         var oldAddress     = CustomerManager.GetAddressById(this.AddressId);
         var inputedAddress = AddressEditControl.Address;
         if (oldAddress != null)
         {
             CustomerManager.UpdateAddress(oldAddress.AddressId, oldAddress.CustomerId, oldAddress.IsBillingAddress,
                                           inputedAddress.FirstName, inputedAddress.LastName,
                                           inputedAddress.PhoneNumber, inputedAddress.Email, inputedAddress.FaxNumber,
                                           inputedAddress.Company, inputedAddress.Address1, inputedAddress.Address2,
                                           inputedAddress.City, inputedAddress.StateProvinceId, inputedAddress.ZipPostalCode,
                                           inputedAddress.CountryId, oldAddress.CreatedOn, DateTime.UtcNow);
         }
         else
         {
             CustomerManager.InsertAddress(NopContext.Current.User.CustomerId, this.IsBillingAddress,
                                           inputedAddress.FirstName, inputedAddress.LastName,
                                           inputedAddress.PhoneNumber, inputedAddress.Email, inputedAddress.FaxNumber,
                                           inputedAddress.Company, inputedAddress.Address1, inputedAddress.Address2,
                                           inputedAddress.City, inputedAddress.StateProvinceId, inputedAddress.ZipPostalCode,
                                           inputedAddress.CountryId, DateTime.UtcNow, DateTime.UtcNow);
         }
         Response.Redirect(SEOHelper.GetMyAccountUrl());
     }
 }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var oldAddress     = this.CustomerService.GetAddressById(this.AddressId);
                var inputedAddress = AddressEditControl.Address;
                if (oldAddress != null)
                {
                    oldAddress.FirstName       = inputedAddress.FirstName;
                    oldAddress.LastName        = inputedAddress.LastName;
                    oldAddress.PhoneNumber     = inputedAddress.PhoneNumber;
                    oldAddress.Email           = inputedAddress.Email;
                    oldAddress.FaxNumber       = inputedAddress.FaxNumber;
                    oldAddress.Company         = inputedAddress.Company;
                    oldAddress.Address1        = inputedAddress.Address1;
                    oldAddress.Address2        = inputedAddress.Address2;
                    oldAddress.City            = inputedAddress.City;
                    oldAddress.StateProvinceId = inputedAddress.StateProvinceId;
                    oldAddress.ZipPostalCode   = inputedAddress.ZipPostalCode;
                    oldAddress.CountryId       = inputedAddress.CountryId;
                    oldAddress.UpdatedOn       = DateTime.UtcNow;

                    this.CustomerService.UpdateAddress(oldAddress);
                }
                else
                {
                    inputedAddress.CustomerId       = NopContext.Current.User.CustomerId;
                    inputedAddress.IsBillingAddress = this.IsBillingAddress;
                    inputedAddress.CreatedOn        = DateTime.UtcNow;
                    inputedAddress.UpdatedOn        = DateTime.UtcNow;
                    this.CustomerService.InsertAddress(inputedAddress);
                }
                Response.Redirect(SEOHelper.GetMyAccountUrl());
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string title = GetLocaleResourceString("PageTitle.AddressEdit");

            SEOHelper.RenderTitle(this, title, true);

            CommonHelper.SetResponseNoCache(Response);

            if (NopContext.Current.User == null)
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }
            var address = CustomerManager.GetAddressById(this.AddressId);

            if (address != null)
            {
                var addressCustomer = address.Customer;
                if (addressCustomer == null || addressCustomer.CustomerId != NopContext.Current.User.CustomerId)
                {
                    string loginURL = SEOHelper.GetLoginPageUrl(true);
                    Response.Redirect(loginURL);
                }

                if (DeleteAddress)
                {
                    CustomerManager.DeleteAddress(address.AddressId);
                    Response.Redirect(SEOHelper.GetMyAccountUrl());
                }
            }

            if (!Page.IsPostBack)
            {
                this.BindData();
            }
        }
Exemple #4
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     CustomerManager.DeleteAddress(this.AddressId);
     Response.Redirect(SEOHelper.GetMyAccountUrl());
 }