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)
            {
                UpdateDeliveryAddressFrom(request.Address, deliveryAddress);

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

            response.DeliveryAddress = deliveryAddress
                                       .ConvertToDeliveryAddressView();

            return(response);
        }
예제 #2
0
        public DeliveryAddressAddResponse AddDeliveryAddress(DeliveryAddressAddRequest request)
        {
            DeliveryAddressAddResponse response = new DeliveryAddressAddResponse();
            Customer customer = _customerRepository.FindBy(request.CustomerIdentityToken);

            DeliveryAddress deliveryAddress = new DeliveryAddress();

            deliveryAddress.Customer = customer;
            UpdateDeliveryAddressFrom(request.Address, deliveryAddress);

            customer.AddAddress(deliveryAddress);

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

            response.DeliveryAddress = deliveryAddress.ConvertToDeliveryAddressView();

            return(response);
        }