private void ExecuteClearSearch()
 {
     if (searchSource != null && searchSource.Count != ResidenceList.Count)
     {
         if (ResidenceList != null)
         {
             ResidenceList.Clear();
         }
         searchSource = null;
         RefreshResidence();
     }
     SearchText = String.Empty;
 }
 private void ExecuteSearch()
 {
     RefreshResidence();
     searchSource = ResidenceList.ToList();;
     if (SearchByHouseNumber)
     {
         ResidenceList = new ObservableCollection <Residence>(searchSource.FindAll((x) => x.Number == SearchText.Trim()));
         if (ResidenceList != null && ResidenceList.Count == 0)
         {
             MessageBox.Show("No Residence Found with House Number " + SearchText);
         }
     }
     else if (SearchByHouseName)
     {
         ResidenceList = new ObservableCollection <Residence>(searchSource.FindAll((x) => x.Name.ToLower().Contains(SearchText.Trim().ToLower())));
         if (ResidenceList != null && ResidenceList.Count == 0)
         {
             MessageBox.Show("No Residence Found with House Name " + SearchText);
         }
     }
     else if (SearchByMemberName)
     {
         using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
             List <ResidenceMember> tempResidenceMembers = unitofWork.ResidenceMembers.Find((x) => x.MemberName.ToLower().Contains(SearchText.Trim().ToLower())).ToList();
             if (tempResidenceMembers != null && tempResidenceMembers.Count == 0)
             {
                 MessageBox.Show("No Residence Found with Member Name " + SearchText);
             }
             else
             {
                 ResidenceList.Clear();
                 foreach (var item in tempResidenceMembers)
                 {
                     Residence residence = searchSource.Find((x) => x.Id == item.Residence_Id);
                     if (residence != null && !ResidenceList.Contains(residence))
                     {
                         ResidenceList.Add(residence);
                     }
                 }
             }
         }
     }
 }