Esempio n. 1
0
        public static Address GetAddress(this IAddressManager client, MailAddress address, EntityStatus?status)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            return(client.GetAddress(address.Address, status));
        }
Esempio n. 2
0
        internal Address GetAddress(DirectAddress address)
        {
            Debug.Assert(m_settings.HasAddressManager);

            IAddressManager client = CreateAddressManagerClient();

            using (client as IDisposable)
            {
                if (AddressDomainSearchEnabled(m_settings.AddressManager))
                {
                    return(client.GetAddressesOrDomain(address, EntityStatus.Enabled));
                }
                return(client.GetAddress(address, EntityStatus.Enabled));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteAddressInfo(int accountId, int addressId)
        {
            try
            {
                var acc = await accountManager.GetAccount(accountId);

                if (acc == null)
                {
                    return(NotFound("No account found with given id!"));
                }


                var adr = await addressManager.GetAddress(addressId);

                if (adr == null)
                {
                    return(NotFound("No address found with given id!"));
                }

                if (adr.IsMain == true)
                {
                    return(BadRequest("Could not delete primary address."));
                }

                var result = await addressManager.DeleteAddress(addressId);

                if (result == true)
                {
                    return(NoContent());
                }

                return(BadRequest(""));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        internal Address GetAddress(DirectAddress address)
        {
            Debug.Assert(_settings.HasAddressManager);

            Address managedAddress;

            if (_addressCache != null)
            {
                managedAddress = _addressCache.Get(address.Address);
                if (managedAddress != null)
                {
                    return(managedAddress);
                }
            }

            IAddressManager client = CreateAddressManagerClient();

            using (client as IDisposable)
            {
                if (_enabledDomainSearch)
                {
                    managedAddress = client.GetAddressesOrDomain(address, EntityStatus.Enabled);
                }
                else
                {
                    managedAddress = client.GetAddress(address, EntityStatus.Enabled);
                }
            }


            if (_addressCache != null)
            {
                _addressCache.Put(managedAddress);
            }

            return(managedAddress);
        }