Exemple #1
0
        public async Task <ValidationResult> Handle(AddAddressCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                return(message.ValidationResult);
            }

            var address = new Address(message.Street, message.Number, message.Complement, message.ZipCode, message.Neighborhood, message.City, message.State, message.CustomerId);

            _customerRepository.AddAddress(address);

            return(await PersistToBase(_customerRepository.UnitOfWork));
        }
        public Task <SetAddressResponce> Handle(SetAddressRequest request, CancellationToken cancellationToken)
        {
            //get user
            var user = _customerRepository.GetCustomer(request.Email);

            if (user == null)
            {
                return(Task.FromResult(SetAddressResponce.Empty));
            }

            _customerRepository.AddAddress(request.Email, request);
            return(Task.FromResult(SetAddressResponce.Empty));

            //add address
        }