Search in sources :

Example 11 with Address

use of com.salesmanager.shop.model.customer.address.Address in project shopizer by shopizer-ecommerce.

the class CustomerAccountController method editAddress.

@PreAuthorize("hasRole('AUTH_CUSTOMER')")
@RequestMapping(value = "/editAddress.html", method = { RequestMethod.GET, RequestMethod.POST })
public String editAddress(final Model model, final HttpServletRequest request, @RequestParam(value = "billingAddress", required = false) Boolean billingAddress) throws Exception {
    MerchantStore store = getSessionAttribute(Constants.MERCHANT_STORE, request);
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Customer customer = null;
    if (auth != null && request.isUserInRole("AUTH_CUSTOMER")) {
        customer = customerFacade.getCustomerByUserName(auth.getName(), store);
    }
    if (customer == null) {
        return "redirect:/" + Constants.SHOP_URI;
    }
    Address address = customerFacade.getAddress(customer.getId(), store, billingAddress);
    model.addAttribute("address", address);
    model.addAttribute("customerId", customer.getId());
    StringBuilder template = new StringBuilder().append(ControllerConstants.Tiles.Customer.EditAddress).append(".").append(store.getStoreTemplate());
    return template.toString();
}
Also used : Address(com.salesmanager.shop.model.customer.address.Address) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) Authentication(org.springframework.security.core.Authentication) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Address (com.salesmanager.shop.model.customer.address.Address)11 ConversionException (com.salesmanager.core.business.exception.ConversionException)7 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)4 ReadableCustomer (com.salesmanager.shop.model.customer.ReadableCustomer)4 Customer (com.salesmanager.core.model.customer.Customer)3 CustomerAttribute (com.salesmanager.core.model.customer.attribute.CustomerAttribute)3 ServiceException (com.salesmanager.core.business.exception.ServiceException)2 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 Language (com.salesmanager.core.model.reference.language.Language)2 Group (com.salesmanager.core.model.user.Group)2 CustomerOptionDescription (com.salesmanager.shop.model.customer.attribute.CustomerOptionDescription)2 CustomerOptionValueDescription (com.salesmanager.shop.model.customer.attribute.CustomerOptionValueDescription)2 ReadableCustomerAttribute (com.salesmanager.shop.model.customer.attribute.ReadableCustomerAttribute)2 ReadableCustomerOption (com.salesmanager.shop.model.customer.attribute.ReadableCustomerOption)2 ReadableCustomerOptionValue (com.salesmanager.shop.model.customer.attribute.ReadableCustomerOptionValue)2 ReadableGroup (com.salesmanager.shop.model.security.ReadableGroup)2 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)2 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)2 Product (com.salesmanager.core.model.catalog.product.Product)1 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)1