This code should go in your cs
var routeData = new RouteData();
routeData.Values["controller"] = "Customer";
routeData.Values["action"] = "updateGenericAttribute";
routeData.Values["firstname"] = txtFirstName.Text;
routeData.Values["lastname"] = txtLastName.Text;
routeData.Values["address"] = txtAddress1.Text;
routeData.Values["address1"] = txtAddress2.Text;
routeData.Values["city"] = txtCity.Text;
routeData.Values["countryId"] = cbCountry.Value;
routeData.Values["stateId"] = cbState.Value;
routeData.Values["phone"] = txtPhoneNumber.Text;
var requestContext = new RequestContext(new HttpContextWrapper(HttpContext.Current), routeData);
IController controller = DependencyResolver.Current.GetService<CustomerController>();
controller.Execute(requestContext);
And in MVC
[NopHttpsRequirement(SslRequirement.Yes)]
public ActionResult updateGenericAttribute(string firstname, string lastname, string address, string address1, string city, string countryId, string stateId,string phone)
{
var customer = _workContext.CurrentCustomer;
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.StreetAddress, address);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.StreetAddress2, address1);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.FirstName, firstname);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.LastName, lastname);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.City, city);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.CountryId, countryId);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.StateProvinceId, stateId);
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.Phone, phone);
return Content("");
}
No comments:
Post a Comment