public async void FindCommandClick(object sender) { try { FindHandler find = new FindHandler(); rs = new Model.RentalShopEntities(); List <int> tmp = new List <int>(); FreeCassetes.Clear(); foreach (var item in find.FindTitle(FindHandler.FieldType.Title, FindArg)) { foreach (var copyItem in rs.Cassete_Copies) { if (item != null && copyItem.Catalog_Id == item.Catalog_Id && copyItem.Status != "busy" && !tmp.Contains(copyItem.Catalog_Id)) { tmp.Add(copyItem.Catalog_Id); p.Dispatcher.Invoke(() => { FreeCassetes.Add(new CasseteShortInfo { Cover = API.Image.ByteArrayToImage(item.Cover), Id = item.Catalog_Id, Name = item.Title }); }); } } } tmp.Clear(); } catch (Exception e) { MessageBox.Show(e.Message); } }
private async void FindCommandClick(object sender) { Cassetes.Clear(); if (_inputtext != null && _inputtext != "") { FindHandler find = new FindHandler(); switch (SelectedArg) { case "Название": foreach (var item in find.FindTitle(FindHandler.FieldType.Title, _inputtext)) { Cassetes.Add(new CasseteShortInfo { Cover = API.Image.ByteArrayToImage(item.Cover), Id = item.Catalog_Id, Name = item.Title }); } break; case "Режиссер": foreach (var item in find.FindTitle(FindHandler.FieldType.Director, _inputtext)) { Cassetes.Add(new CasseteShortInfo { Cover = API.Image.ByteArrayToImage(item.Cover), Id = item.Catalog_Id, Name = item.Title }); } break; case "Цена": foreach (var item in find.FindTitle(FindHandler.FieldType.Price, _inputtext)) { Cassetes.Add(new CasseteShortInfo { Cover = API.Image.ByteArrayToImage(item.Cover), Id = item.Catalog_Id, Name = item.Title }); } break; case "Отдел": foreach (var item in find.FindTitle(FindHandler.FieldType.Departament, _inputtext)) { Cassetes.Add(new CasseteShortInfo { Cover = API.Image.ByteArrayToImage(item.Cover), Id = item.Catalog_Id, Name = item.Title }); } break; } } }