Create a page using addresses within an MVC site.
At your visual studio solution setup:
List<MVCSite.Models.Generated.Address> models = null; if (Sitecore.Context.User.IsAuthenticated) { var user = Sitecore.Context.User; var commerceProfile = user.GetCommerceProfileModel(); if (commerceProfile.AddressList != null) { models = Address.GetMultiple(commerceProfile.AddressList); } } return View(models);
if (model != null && Sitecore.Context.User.IsAuthenticated) { var user = Sitecore.Context.User; var profileModel = user.GetCommerceProfileModel(); if (string.IsNullOrEmpty(model.AddressID)) { var address = Address.Create(); model.Save(address); profileModel.AddressList.Add(model.AddressID); profileModel.AddressList = profileModel.AddressList; profileModel.Save(); } else { if (profileModel.AddressList.Contains(model.AddressID)) { var address = Address.GetCommerceProfile(model.AddressID); if (address != null) { model.Save(address); } } } }