Exemple #1
0
        //Pro pridavani slozeni
        public AddContent(Frame f, Drug d)
        {
            InitializeComponent();
            drug             = d;
            frame            = f;
            list.ItemsSource = App.Database.GetIngredientsAsync().Result;

            /*selected = App.Database.GetSelected(drug.ID).Result;
             * foreach(Ingredient i in ingredients)
             * {
             *  foreach(DrugContent dc in selected)
             *  {
             *      if(dc.drugID == i.ID)
             *      {
             *          list.SelectedItems.Add(dc);
             *      }
             *  }
             * }*/
            Content = true;
        }
Exemple #2
0
 public Task <int> Delete(Drug item)
 {
     return(database.DeleteAsync(item));
 }
Exemple #3
0
        public DrugInfo(int x, Frame f, List <Drug> d)
        {
            InitializeComponent();
            ID    = x;
            drugs = d;
            frame = f;

            customer = App.Database.GetActive().Result;
            if (customer == null)
            {
                buy.IsEnabled = false;
                danger        = true;
                warning.Text  = "Žádný uživatel není aktivní, není možné kupovat bez kontroly alergií.";
            }

            getdrug = App.Database.GetItem(ID).Result;
            foreach (Drug t in getdrug)
            {
                drug          = t;
                id.Content    = t.ID;
                name.Content  = t.Name;
                dname         = t.Name;
                price.Content = t.Price;
            }
            dcontent = App.Database.GetIngredientID(drug.ID).Result;
            int pom = 0;

            if (customer != null)
            {
                allergy_ids = App.Database.GetAllergyID(customer.ID).Result;
                foreach (CustomerAllergy c in allergy_ids)
                {
                    Debug.WriteLine(c.AllergyID);
                    allergy = App.Database.GetAllergy(c.AllergyID).Result;
                    foreach (Ingredient aler in allergy)
                    {
                        //Debug.WriteLine(aler.Name);
                        foreach (DrugContent dr in dcontent)
                        {
                            Debug.WriteLine(dr.contentID);
                            ingredients = App.Database.GetAllergy(dr.contentID).Result;
                            foreach (Ingredient ing in ingredients)
                            {
                                //Debug.WriteLine(ing.Name);
                                if (aler.Name == ing.Name)
                                {
                                    danger = true;
                                }
                            }
                        }
                    }
                }
                foreach (DrugContent dr in dcontent)
                {
                    Debug.WriteLine(dr.contentID);
                    ingredients = App.Database.GetAllergy(dr.contentID).Result;
                    foreach (Ingredient ing in ingredients)
                    {
                        //Debug.WriteLine(ing.Name);
                        if (pom + 1 < dcontent.Count())
                        {
                            content.Content += ing.Name + ", ";
                        }
                        else
                        {
                            content.Content += ing.Name;
                        }
                        pom++;
                    }
                }
            }
            else
            {
                foreach (DrugContent dr in dcontent)
                {
                    Debug.WriteLine(dr.contentID);
                    ingredients = App.Database.GetAllergy(dr.contentID).Result;
                    foreach (Ingredient ing in ingredients)
                    {
                        //Debug.WriteLine(ing.Name);
                        if (pom + 1 < dcontent.Count())
                        {
                            content.Content += ing.Name + ", ";
                        }
                        else
                        {
                            content.Content += ing.Name;
                        }
                        pom++;
                    }
                }
            }
            if (danger)
            {
                warning.Visibility = Visibility.Visible;
            }
            else
            {
                warning.Visibility = Visibility.Collapsed;
            }
        }
Exemple #4
0
        private void Add(object sender, RoutedEventArgs e)
        {
            Drug item = new Drug();

            App.Database.SaveItemAsync(item);
        }