public async Task Recherche()
        {
            if (ResearchLabel != null)
            {
                Announcements.Clear();
                bool trouvé            = false;
                var  AnnouncementsTemp = await GetAnnouncementsUser();

                AnnouncementVisu anouncementTemp = null;
                foreach (AnnouncementVisu announc in AnnouncementsTemp)
                {
                    if (trouvé)
                    {
                        break;
                    }
                    if (announc.idAnnoun == Int32.Parse(ResearchLabel))
                    {
                        trouvé          = true;
                        anouncementTemp = announc;
                    }
                }
                if (anouncementTemp != null)
                {
                    Announcements.Add(anouncementTemp);
                }
            }
        }
Example #2
0
 public void sort()
 {
     if (flag)
     {
         Announcements.Clear();
         foreach (Announcement ann in getAnnouncements().OrderBy(x => x.cost))
         {
             Announcements.Add(ann);
         }
         flag = false;
     }
     else
     {
         Announcements.Clear();
         foreach (Announcement ann in getAnnouncements().OrderByDescending(x => x.cost))
         {
             Announcements.Add(ann);
         }
         flag = true;
     }
 }
Example #3
0
        public AllAnnouncementViewModel()
        {
            var announcements = getAnnouncements().ToList();

            Announcements.Clear();
            foreach (Announcement a in announcements)
            {
                a.BitmapImage = LoadPhoto(a.seller.Value);
                Announcements.Add(a);
            }


            tmpCategories = announcementRepository.getCategories().Distinct().ToList();
            tmpSellers    = userRepository.getAllNames().Distinct().ToList();
            tmpRegions    = regionRepository.getRegions();
            SelectedIndex = 0;
            Info          = $"Найдено {Announcements.Count}";
            MAX_COST      = announcementRepository.MaxCost();
            MaxCost       = MAX_COST.ToString();

            viewWindow            = new ViewWindow(this);
            viewWindow.Visibility = System.Windows.Visibility.Hidden;
        }
Example #4
0
        public void search()
        {
            selectedItem = null;
            Announcements.Clear();
            Regex regex    = new Regex(@"(\w*)(?i)" + SearchText + @"(\w*)");
            int   regionId = SelectedIndex;
            HashSet <Announcement> tmp1 = new HashSet <Announcement>();
            HashSet <Announcement> tmp2 = new HashSet <Announcement>();

            if (SelectedIndex != 0)
            {
                foreach (Announcement announcement in announcementRepository.getByRegionId(SelectedIndex))
                {
                    tmp1.Add(announcement);
                }
            }
            else
            {
                foreach (Announcement announcement in announcementRepository.getAll())
                {
                    tmp1.Add(announcement);
                }
            }
            if (!String.IsNullOrEmpty(Category))
            {
                foreach (Announcement announcement in tmp1.Where(x => x.category.Equals(Category)))
                {
                    tmp2.Add(announcement);
                }
                tmp1.Clear();
            }
            else
            {
                foreach (Announcement announcement in tmp1)
                {
                    tmp2.Add(announcement);
                }
                tmp1.Clear();
            }
            if (!String.IsNullOrEmpty(Seller))
            {
                int id = userRepository.getByName(Seller).id;
                foreach (Announcement announcement in tmp2.Where(x => x.seller == id))
                {
                    tmp1.Add(announcement);
                }
                tmp2.Clear();
            }
            else
            {
                foreach (Announcement announcement in tmp2)
                {
                    tmp1.Add(announcement);
                }
                tmp2.Clear();
            }
            if (!String.IsNullOrEmpty(SearchText))
            {
                foreach (Announcement announcement in tmp1)
                {
                    if (regex.IsMatch(announcement.about) || regex.IsMatch(announcement.name))
                    {
                        if (maxCost == 0)
                        {
                            if (announcement.cost <= maxCost && announcement.cost >= MAX_COST)
                            {
                                tmp2.Add(announcement);
                            }
                        }
                        else
                        {
                            if (announcement.cost <= maxCost && announcement.cost >= minCost)
                            {
                                tmp2.Add(announcement);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Announcement announcement in tmp1)
                {
                    if (maxCost == 0)
                    {
                        if (announcement.cost <= maxCost && announcement.cost >= MAX_COST)
                        {
                            tmp2.Add(announcement);
                        }
                    }
                    else
                    {
                        if (announcement.cost <= maxCost && announcement.cost >= minCost)
                        {
                            tmp2.Add(announcement);
                        }
                    }
                }
            }

            foreach (Announcement announcement in tmp2)
            {
                Announcements.Add(announcement);
            }

            tmp1.Clear();
            tmp2.Clear();

            Info = $"Найдено {Announcements.Count}";
        }
 public void Clear()
 {
     Announcements?.Clear();
 }