Beispiel #1
0
        // Populate the suburbs data
        public void InitializeSuburb(List <String> siteSuburbs)
        {
            Suburbs = new List <ServiceVisitFilterSuburbViewModel>();

            siteSuburbs.ForEach((item) =>
            {
                var isInserted = false;
                Suburbs.ForEach((suburbItem) =>
                {
                    var suburbViewModel = (ServiceVisitFilterSuburbViewModel)suburbItem;
                    if (item.Equals(suburbViewModel.SuburbName))
                    {
                        isInserted = true;
                    }
                });

                // to avoid inserting the same suburb more than once
                if (!isInserted)
                {
                    var newSuburb        = new ServiceVisitFilterSuburbViewModel();
                    newSuburb.IsSelected = false;
                    newSuburb.SuburbName = (String)item;

                    Suburbs.Add(newSuburb);
                }
            });

            foreach (String selectedSuburb in this.SelectedSuburbs)
            {
                foreach (ServiceVisitFilterSuburbViewModel suburb in this.Suburbs)
                {
                    if (suburb.SuburbName.Equals(selectedSuburb))
                    {
                        suburb.IsSelected = true;
                    }
                }
            }

            this.AllSuburbs = new List <ServiceVisitFilterSuburbViewModel>();
            this.Suburbs.ForEach((item) =>
            {
                this.AllSuburbs.Add(item);
            });
        }
Beispiel #2
0
 // To be called when typing the suburb name on search bar
 public void UpdateSuburbResult()
 {
     this.Suburbs = new List <ServiceVisitFilterSuburbViewModel>();
     if (!String.IsNullOrWhiteSpace(_searchedTerm))
     {
         this.Suburbs = new List <ServiceVisitFilterSuburbViewModel>();
         this.AllSuburbs.ForEach((item) =>
         {
             ServiceVisitFilterSuburbViewModel suburb = item;
             if (suburb.SuburbName.Contains(_searchedTerm))
             {
                 this.Suburbs.Add(suburb);
             }
         });
     }
     else
     {
         this.AllSuburbs.ForEach((item) =>
         {
             ServiceVisitFilterSuburbViewModel suburb = item;
             this.Suburbs.Add(suburb);
         });
     }
 }