Пример #1
0
        public static List <Address> GetCustomerAddresses(int customerID)
        {
            var addresses = new List <Address>();

            try
            {
                var context = Exigo.SqlDataContext();

                using (var ctx = Exigo.Sql())
                {
                    var model = ctx.Query(@"
                            select 
                                c.FirstName,
                                c.LastName,
                                c.Email,
                                c.Phone,

                                c.MainAddress1,
                                c.MainAddress2,
                                c.MainCity,
                                c.MainState,
                                c.MainZip,
                                c.MainCountry,

                                c.MailAddress1,
                                c.MailAddress2,
                                c.MailCity,
                                c.MailState,
                                c.MailZip,
                                c.MailCountry,

                                c.OtherAddress1,
                                c.OtherAddress2,
                                c.OtherCity,
                                c.OtherState,
                                c.OtherZip,
                                c.OtherCountry

                            from Customers c
                            where c.CustomerID = @customerID
                            ", new { customerID }).FirstOrDefault();

                    addresses.Add(new ShippingAddress()
                    {
                        AddressType = AddressType.Main,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        Email       = model.Email,
                        Phone       = model.Phone,
                        Address1    = model.MainAddress1,
                        Address2    = model.MainAddress2,
                        City        = model.MainCity,
                        State       = model.MainState,
                        Zip         = model.MainZip,
                        Country     = model.MainCountry
                    });

                    addresses.Add(new ShippingAddress()
                    {
                        AddressType = AddressType.Mailing,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        Email       = model.Email,
                        Phone       = model.Phone,
                        Address1    = model.MailAddress1,
                        Address2    = model.MailAddress2,
                        City        = model.MailCity,
                        State       = model.MailState,
                        Zip         = model.MailZip,
                        Country     = model.MailCountry
                    });

                    addresses.Add(new ShippingAddress()
                    {
                        AddressType = AddressType.Other,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        Email       = model.Email,
                        Phone       = model.Phone,
                        Address1    = model.OtherAddress1,
                        Address2    = model.OtherAddress2,
                        City        = model.OtherCity,
                        State       = model.OtherState,
                        Zip         = model.OtherZip,
                        Country     = model.OtherCountry
                    });
                }
            }
            catch
            {
            }

            return(addresses);
        }