Exemple #1
0
 public Task Handle(ChangeCompanyShippingAddressCommand message)
 {
     return(Task.Factory.StartNew(() => {
         var company = _repository.GetById <Company>(message.CompanyId);
         if (company.ShippingAddress.IsDifferentAddress(message.Address, message.City, message.PostalCode, message.Province, message.Country))
         {
             company.SetShippingAddress(message.Address, message.City, message.PostalCode, message.Province, !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry());
             _repository.Save(company);
         }
     }));
 }
Exemple #2
0
        public async Task Handle(ChangeCompanyShippingAddressCommand message)
        {
            var effectiveDateTime = message.EffectiveDate;
            var effectiveDate     = new DateTime(effectiveDateTime.Year, effectiveDateTime.Month, effectiveDateTime.Day);

            var company = _repository.GetById <Company>(message.CompanyId);

            if (effectiveDate > DateTime.Now || company.ShippingAddress == null || company.ShippingAddress.IsDifferentAddress(message.Address, message.City, message.PostalCode, message.Province, message.Country))
            {
                company.ChangeShippingAddress(message.Address, message.City, message.PostalCode, message.Province, !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry(), effectiveDate, message.UserId);
                await _repository.SaveAsync(company);
            }
        }
        public void ChangeShippingAddress(ChangeShippingAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var cmd = new ChangeCompanyShippingAddressCommand(model.CompanyId,
                                                              model.ShippingAddress.Address,
                                                              model.ShippingAddress.PostalCode,
                                                              model.ShippingAddress.City,
                                                              model.ShippingAddress.Province,
                                                              model.ShippingAddress.Country);

            Bus.Send(cmd);
        }
        public void ChangeShippingAddress(ChangeShippingAddressViewModel 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 ChangeCompanyShippingAddressCommand(model.CompanyId,
                                                              model.ShippingAddress.Address,
                                                              model.ShippingAddress.PostalCode,
                                                              model.ShippingAddress.City,
                                                              model.ShippingAddress.Province,
                                                              model.ShippingAddress.Country,
                                                              effectiveDate);

            Bus.Send(cmd);
        }
Exemple #5
0
        public async Task ChangeShippingAddressAsync(Guid companyId, ChangeShippingAddressModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var userId = GetCurrentUserId();

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

            var cmd = new ChangeCompanyShippingAddressCommand(
                userId,
                companyId,
                model.ShippingAddress.Address,
                model.ShippingAddress.PostalCode,
                model.ShippingAddress.City,
                model.ShippingAddress.Province,
                model.ShippingAddress.Country,
                effectiveDate);

            await Bus.Send(cmd);
        }