private void ButtonTraziLekove_Click(object sender, RoutedEventArgs e) { TempLekovi.Clear(); foreach (var lek in Lekovi) { switch (SelectedKriterijum) { case "Naziv": if (lek.Naziv.IndexOf(Pretraga, StringComparison.CurrentCultureIgnoreCase) != -1) { TempLekovi.Add(lek); } break; case "Sifra": //if (lek.Sifra.IndexOf(Pretraga, StringComparison.CurrentCultureIgnoreCase) != -1) //{ TempLekovi.Add(lek); //} break; default: TempLekovi.Add(lek); break; } } }
private void UpdateTempLek() { Lekovi.Clear(); TempLekovi.Clear(); List <Drug> confirmedDrugs = dc.ViewConfirmedDrugs(); if (confirmedDrugs != null) { foreach (Drug d in confirmedDrugs) { Lek lek = new Lek(); lek.Naziv = d.Name; lek.Kolicina = d.Quantity; lek.Proizvodjac = d.Producer; lek.RokTrajanja = d.ExpirationDate; lek.Sifra = d.Id; lek.Sastav = new List <string>(); foreach (Ingredient a in d.ingredient) { lek.Sastav.Add(a.Name); } lek.Tip = d.drugType.Type; //lek.Sastav = d.ingredient.FirstOrDefault(); Lekovi.Add(lek); } } List <Drug> unconfirmedDrugs = dc.ViewUnconfirmedDrugs(); if (unconfirmedDrugs != null) { foreach (Drug d in unconfirmedDrugs) { Lek lek = new Lek(); lek.Naziv = d.Name; lek.Kolicina = d.Quantity; lek.Proizvodjac = d.Producer; lek.RokTrajanja = d.ExpirationDate; lek.Sifra = d.Id; lek.Sastav = new List <string>(); foreach (Ingredient a in d.ingredient) { lek.Sastav.Add(a.Name); } lek.Tip = d.drugType.Type; Lekovi.Add(lek); } } foreach (var lek in Lekovi) { TempLekovi.Add(lek); } }