protected void SetHotelData(ref Hotels hotels, int hotelId) { var amentyItem = AmentiesList.First(x => x.HotelId == hotelId); hotels.AmentiesItem = amentyItem; hotels.PoolAmentyListses = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Pool).OrderBy(x => x.AmentyOrder); hotels.PoolAmentyUpgrages = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && !x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Pool).OrderBy(x => x.AmentyOrder); hotels.GymAmentyListses = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Gym).OrderBy(x => x.AmentyOrder); hotels.GymAmentyUpgrages = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && !x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Gym).OrderBy(x => x.AmentyOrder); hotels.SpaAmentyListses = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Spa).OrderBy(x => x.AmentyOrder); hotels.SpaAmentyUpgrages = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && !x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Spa).OrderBy(x => x.AmentyOrder); hotels.BusinessCenterAmentyListses = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.BusinessCenter).OrderBy(x => x.AmentyOrder); hotels.BusinessCenterAmentyUpgrages = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && !x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.BusinessCenter).OrderBy(x => x.AmentyOrder); hotels.DinningAmentyListes = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Dining).OrderBy(x => x.AmentyOrder); hotels.EventAmentyListes = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Event).OrderBy(x => x.AmentyOrder); hotels.OtherAmentyListses = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Other).OrderBy(x => x.AmentyOrder); hotels.OtherAmentyUpgrages = AmentyListsList.Where(x => x.AmentyId == amentyItem.Id && x.IsActive.HasValue && x.IsActive.Value && x.IsAmenty.HasValue && !x.IsAmenty.Value && x.AmentyTypeId.HasValue && x.AmentyTypeId.Value == (int)Enums.AmentyType.Other).OrderBy(x => x.AmentyOrder); hotels.PhotoList = PhotoList.Where(x => x.HotelId == hotelId && x.IsActive.HasValue && x.IsActive.Value).OrderBy(x => x.Order); }
private async void SearchPhotoButton_ClickAsync(object sender, RoutedEventArgs e) { GoBackButton.IsEnabled = false; SearchPhotoButton.IsEnabled = false; SelectPhotoButton.IsEnabled = false; if (FullFileName == "") { MessageBox.Show("Пожалуйста, выберите картинку"); return; } try { int counter = 0; PhotoList = Helper.Connection.Photo.ToList(); System.Drawing.Image searchImage = System.Drawing.Image.FromFile(FullFileName); PhotoList = PhotoList.Where(p => p.Category.Title == CategoryComboBox.SelectedItem.ToString()).ToList(); ProgressBarWindow ProgressBarWindow = new ProgressBarWindow(PhotoList.Count); ProgressBarWindow.Show(); await Task.Run(() => { foreach (Photo p in PhotoList) { counter++; Dispatcher.Invoke(() => ProgressBarWindow.ProgressBar.Value = counter); int counterOfCompare = 0; System.Drawing.Image imageFromDB = System.Drawing.Image.FromFile(p.Path); byte[,] array = ExtensionMethods.GetDifferences(searchImage, imageFromDB); for (int i = 0; i < array.GetLength(0); i++) { for (int j = 0; j < array.GetLength(1); j++) { if (array[i, j] == 0) { counterOfCompare++; } } } if (counterOfCompare > 5) { SimilarPhotoList.Add(p); } continue; } Dispatcher.Invoke(() => ProgressBarWindow.Close()); if (SimilarPhotoList.Count > 0) { List <string> similarImagePathList = SimilarPhotoList.Select(p => p.Path).ToList(); MessageBox.Show("Совпадение найдено!"); Dispatcher.Invoke(() => Helper.GoNextWindow(new ShowSimilarPhotoWindow(similarImagePathList, true), this)); return; } else { Dispatcher.Invoke(() => { string categoryTitle = CategoryComboBox.SelectedItem as string; MessageBox.Show($"К сожалению в категории {categoryTitle} нет схожих изображений"); }); } }); } catch (Exception ex) { MessageBox.Show(ex.Message); } GoBackButton.IsEnabled = true; SearchPhotoButton.IsEnabled = true; SelectPhotoButton.IsEnabled = true; }