Exemplo n.º 1
0
        internal void SetFilter(string street, string streetNumber, string zip, string city, object country)
        {
            List<Expression<Func<Address, object>>> exclude = new List<Expression<Func<Address, object>>>();
            Address address = new Address();

            if (!string.IsNullOrEmpty(city))
            {
                address.City = city;
            }
            else
            {
                exclude.Add(x => x.City);
            }

            if (country is Country)
            {
                address.Country = (Country)country;
            }
            else
            {
                exclude.Add(x => x.Country);
            }

            if (!string.IsNullOrEmpty(street))
            {
                address.Street = street;
            }
            else
            {
                exclude.Add(x => x.Street);
            }

            if (!string.IsNullOrEmpty(streetNumber))
            {
                address.StreetNumber = streetNumber;
            }
            else
            {
                exclude.Add(x => x.StreetNumber);
            }

            int zipAsInt;
            if (!string.IsNullOrEmpty(zip) && int.TryParse(zip, out zipAsInt))
            {
                address.Zip = zipAsInt;
            }
            else
            {
                exclude.Add(x => x.Zip);
            }

            m_filter = address;
            m_exclude = exclude.ToArray();

            NotifyPropertyChanged("Addressz");
        }
Exemplo n.º 2
0
 public AddressFilterViewModel()
 {
     m_addressz = (new AddressRepository()).GetAll();
     m_filter = new Address();
     m_exclude = new Expression<Func<Address, object>>[]
     {
         c => c.City,
         c => c.Country,
         c => c.Street,
         c => c.StreetNumber,
         c => c.Zip
     };
 }