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); } } }
public async void Get() { var jData = await DataService.Get($"Announcements"); if (jData == "ConnectionError") { StandardMessagesDisplay.NoConnectionToast(); } else if (jData == "null") { StandardMessagesDisplay.NoDataDisplayMessage(); } else if (jData == "Error") { StandardMessagesDisplay.Error(); } else if (jData == "ErrorTracked") { StandardMessagesDisplay.ErrorTracked(); } else { try { var data = JsonConvert.DeserializeObject <Dictionary <string, AnnouncementsModel> >(jData); if (data != null) { foreach (KeyValuePair <string, AnnouncementsModel> item in data) { Announcements?.Add( new AnnouncementsModel { Id = item.Value.Id, Content = item.Value.Content, IsActive = item.Value.IsActive, MessageDateTime = item.Value.MessageDateTime, Title = item.Value.Title, FId = item.Key } ); } } } catch (Exception ex) { Crashes.TrackError(ex); StandardMessagesDisplay.InputToast(ex.Message); } } }
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; } }
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; }
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}"; }
private void AddAnnouncement(Announcement announcement) { Announcements.Add(announcement); Announcements.Sort(AnnouncementComparison); }