Exemple #1
0
        public void Execute(DeliveryAddressModifyCommand command)
        {
            Customer customer = _customerRepository.FindBy(command.CustomerIdentityToken);

            DeliveryAddress deliveryAddress =
                customer.DeliveryAddressBook.Where(d => d.Id == command.Address.Id).FirstOrDefault();

            if (deliveryAddress != null)
            {
                deliveryAddress.ChangeNameTo(command.Address.Name);

                var address = ConvertToAddressFrom(command.Address);

                deliveryAddress.ChangeAddressTo(address);

                _customerRepository.Save(customer);
                _uow.Commit();
            }
        }
Exemple #2
0
        public DeliveryAddressModifyResponse ModifyDeliveryAddress(DeliveryAddressModifyRequest request)
        {
            DeliveryAddressModifyResponse response = new DeliveryAddressModifyResponse();

            Customer customer = _customerRepository.FindBy(request.CustomerIdentityToken);

            DeliveryAddress deliveryAddress =
                customer.DeliveryAddressBook.Where(d => d.Id == request.Address.Id).FirstOrDefault();

            if (deliveryAddress != null)
            {
                var address = ConvertToAddress(request.Address);

                deliveryAddress.ChangeAddressTo(address);

                _customerRepository.Save(customer);
                _uow.Commit();
            }

            response.DeliveryAddress = deliveryAddress.ConvertToDeliveryAddressView();

            return(response);
        }