コード例 #1
0
        internal static Address Create(Address.CountryCode country)
        {
            Address result = null;

            switch (country)
            {
                case Address.CountryCode.US:
                    result = new USAddress();
                    break;
                case Address.CountryCode.UK:
                    result = new UKAddress();
                    break;
                case Address.CountryCode.CA:
                    result = new CAAddress();
                    break;
                case Address.CountryCode.AU:
                    result = new AUAddress();
                    break;
                default:
                    throw new ArgumentOutOfRangeException("country");
            }

            result.Country = country;
            return result;
        }
コード例 #2
0
        public static Address CreateAddress(Address.TypeEnum type, string line1, string line2, string city, string state, string zip, Address.CountryCode country)
        {
            if ((line1 == null) || (line1.Trim() == ""))
                throw new ArgumentNullException("line1");

            if ((state == null) || (state.Trim() == ""))
                throw new ArgumentNullException("state");

            if ((zip == null) || (zip.Trim() == ""))
                throw new ArgumentNullException("zip");

            Address result = null;

            result = AddressFactory.Create(country);
            result.Line1 = line1.Trim();
            result.Line2 = (line2 != null)? line2.Trim():null;
            result.City = (city != null)?city.Trim():null;
            result.State = state.Trim();
            result.ZipCode = zip.Trim();
            result.AddressType = type;

            return result;
        }
コード例 #3
0
 public static Address CreateAddress(Address.TypeEnum type, string line1, string line2, string city, string state, string zip, string country)
 {
     return CreateAddress(type, line1, line2, city, state, zip, (Address.CountryCode)Enum.Parse(typeof(Address.CountryCode), country));
 }
コード例 #4
0
ファイル: Address.cs プロジェクト: esegura/CustomerManagement
        private static void map(DAL.CustomersDataContext dc, Address a, DAL.Address dalAddress, int actionPerformerId)
        {
            bool isNew = a.Id == 0;
            bool isModified = false;

            if (dalAddress.Line1 != a.Line1)
            {
                dalAddress.Line1 = a.Line1;
                isModified = true;
            }

            if (dalAddress.Line2 != a.Line2)
            {
                dalAddress.Line2 = a.Line2;
                isModified = true;
            }

            if (dalAddress.City != a.City)
            {
                dalAddress.City = a.City;
                isModified = true;
            }

            //if (dalAddress.State != Enum.GetName(typeof(StateCode), a.State))
            //{
            //    dalAddress.State = Enum.GetName(typeof(StateCode), a.State);
            //    isModified = true;
            //}

            if (dalAddress.State != a.State)
            {
                dalAddress.State = a.State;
                isModified = true;
            }

            if (dalAddress.ZipCode != a.ZipCode)
            {
                dalAddress.ZipCode = a.ZipCode;
                isModified = true;
            }

            if (dalAddress.CountryCode != Enum.GetName(typeof(CountryCode), a.Country))
            {
                dalAddress.CountryCode = Enum.GetName(typeof(CountryCode), a.Country);
                isModified = true;
            }

            DAL.AddressType at = a.AddressType.findAddressType(dc);
            if ((dalAddress.AddressType == null) || (dalAddress.AddressType.Id != at.Id))
            {
                dalAddress.AddressType = at;
                isModified = true;
            }

            if (dalAddress.CustomerId != a.CustomerId)
            {
                dalAddress.CustomerId = a.CustomerId;
                isModified = true;
            }

            DateTime now = DateTime.Now;

            if (isNew)
            {
                dalAddress.CreatedBy = actionPerformerId;
                dalAddress.CreatedDate = now;
            }

            if (isModified)
            {
                dalAddress.LastChangedBy = actionPerformerId;
                dalAddress.LastChangedDate = now;
            }
        }
コード例 #5
0
ファイル: Address.cs プロジェクト: esegura/CustomerManagement
 internal static void map(DAL.Address dalAddress, Address address)
 {
     address.Line1 = dalAddress.Line1;
     address.Line2 = dalAddress.Line2;
     address.City = dalAddress.City;
     //            address.State = (StateCode)Enum.Parse(typeof(StateCode), dalAddress.State);
     address.State = dalAddress.State;
     address.ZipCode = dalAddress.ZipCode;
     address.Country = (CountryCode)Enum.Parse(typeof(CountryCode), dalAddress.CountryCode);
     address.AddressType = (TypeEnum)Enum.Parse(typeof(TypeEnum), dalAddress.AddressType.TypeName);
     address.Id = dalAddress.Id;
     address.CustomerId = dalAddress.CustomerId;
 }
コード例 #6
0
ファイル: Address.cs プロジェクト: esegura/CustomerManagement
 internal static void Delete(DAL.CustomersDataContext dc, Address item)
 {
     DAL.Address dalAddress = dc.Addresses.Where(a => a.Id == item.Id).Where(a => !a.Deleted).Single();
     dalAddress.Deleted = true;
     dc.SubmitChanges();
 }