Exemplo n.º 1
0
 public Task Handle(ChangePersonAddressCommand message)
 {
     return(Task.Factory.StartNew(() => {
         var person = _repository.GetById <Person>(message.PersonId);
         if (person.ShippingAddress == null || person.ShippingAddress.IsDifferentAddress(message.Address, message.City, message.PostalCode, message.Province, message.Country))
         {
             person.SetAddress(message.Address, message.City, message.PostalCode, message.Province, !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry());
             _repository.Save(person);
         }
     }));
 }
Exemplo n.º 2
0
        public async Task Handle(ChangePersonAddressCommand message)
        {
            var person = _repository.GetById <Person>(message.PersonId);

            if (person.ShippingAddress == null || person.ShippingAddress.IsDifferentAddress(message.Address, message.City, message.PostalCode, message.Province, message.Country))
            {
                var effectiveDateTime = message.EffectiveDate;
                var effectiveDate     = new DateTime(effectiveDateTime.Year, effectiveDateTime.Month, effectiveDateTime.Day);
                person.ChangeAddress(message.Address, message.City, message.PostalCode, message.Province, !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry(), effectiveDate);
                await _repository.SaveAsync(person);
            }
        }
Exemplo n.º 3
0
        public void ChangeAddress(ChangeAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var cmd = new ChangePersonAddressCommand(model.PersonId,
                                                     model.Address.Address,
                                                     model.Address.PostalCode,
                                                     model.Address.City,
                                                     model.Address.Province,
                                                     model.Address.Country);

            Bus.Send(cmd);
        }
        public void ChangeAddress(ChangeAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var effectiveDateTime = model.EffectiveDate;
            var effectiveDate     = new DateTime(effectiveDateTime.Year, effectiveDateTime.Month, effectiveDateTime.Day);

            var cmd = new ChangePersonAddressCommand(model.PersonId,
                                                     model.Address.Address,
                                                     model.Address.PostalCode,
                                                     model.Address.City,
                                                     model.Address.Province,
                                                     model.Address.Country,
                                                     effectiveDate);

            Bus.Send(cmd);
        }