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);
            }
        }
        private void AddLek()
        {
            Lek noviLek = new Lek();

            Console.WriteLine(SifraTb.Text);
            noviLek.Sifra       = Int32.Parse(SifraTb.Text);
            noviLek.Naziv       = NazivTb.Text as string;
            noviLek.Kolicina    = Convert.ToInt32(KolicinaTb.Text);
            noviLek.Tip         = TipTb.SelectedItem as string;
            noviLek.RokTrajanja = (DateTime)RokTb.SelectedDate;
            noviLek.Sastav      = (List <string>)listBox2.ItemsSource;
            noviLek.Proizvodjac = ProizvodjacTb.Text as string;

            Lekovi.Add(noviLek);

            Drug newDrug = new Drug();

            newDrug.Name           = noviLek.Naziv;
            newDrug.Id             = noviLek.Sifra;
            newDrug.Quantity       = noviLek.Kolicina;
            newDrug.ExpirationDate = noviLek.RokTrajanja;
            newDrug.Producer       = noviLek.Proizvodjac;
            List <DrugType> types = dt.ViewDrugTypes();

            foreach (DrugType d in types)
            {
                if (noviLek.Tip.Equals(d.Type))
                {
                    newDrug.drugType = d;
                }
            }
            List <Ingredient> myIngredients = new List <Ingredient>();
            List <Ingredient> ingredients   = dt.ViewIngridients();

            foreach (Ingredient i in ingredients)
            {
                foreach (string s in newIngredients)
                {
                    if (s.Equals(i.Name))
                    {
                        myIngredients.Add(i);
                    }
                }
            }

            newDrug.ingredient = myIngredients;
            dc.AddDrug(newDrug);

            // Resetujemo polja
            ClearFields();

            UpdateTempLek();
        }