Ejemplo n.º 1
0
        public Solver()
        {
            var lines = InputFileReader.GetInput($"Year2020/Inputs/Day{Day}.txt")
                        .ToList();

            foreach (var line in lines)
            {
                var split       = line.Split(" (");
                var ingredients = split[0].Split(" ");
                var recipe      = new Recipe();
                recipe.Ingredients.AddRange(ingredients);

                split[1]
                .Replace("contains ", string.Empty)
                .Replace(")", string.Empty)
                .Split(", ").ToList()
                .ForEach(x =>
                {
                    var a = _alergens.FirstOrDefault(a => a.Name == x);
                    if (a == null)
                    {
                        a = new Alergen(x);
                        _alergens.Add(a);
                    }

                    a.Recipes.Add(recipe);
                    recipe.Alergens.Add(a);
                });

                _recipes.Add(recipe);
            }
        }
Ejemplo n.º 2
0
        public Alergen AddAlergen(Alergen alergen)
        {
            var toReturn = _db.Alergen.Add(alergen);

            _db.SaveChanges();
            return(toReturn.Entity);
        }
Ejemplo n.º 3
0
 internal void ModificaAlergen(Alergen alergen, string alergenModificat, Cont user)
 {
     context.ModificaAlergen(alergen.denumire, alergenModificat);
     context.SaveChanges();
     MainViewModel.Instance.ActiveScreen = new AlergenViewModel(user);
     MessageBox.Show("Alergen Modificat!");
 }
Ejemplo n.º 4
0
 internal void DeleteAlergen(Alergen selectedAlergen, Cont user)
 {
     context.StergeAlergen(selectedAlergen.denumire);
     context.SaveChanges();
     MainViewModel.Instance.ActiveScreen = new AlergenViewModel(user);
     MessageBox.Show("Alergen Sters!");
 }
Ejemplo n.º 5
0
        internal ObservableCollection <Tuple <Produse, Categorie, Alergen> > GetAllProducts()
        {
            SqlConnection connection = HelpDAL.Connection;

            try
            {
                SqlCommand cmd = new SqlCommand("spGetAllProducts", connection);
                ObservableCollection <Tuple <Produse, Categorie, Alergen> > result =
                    new ObservableCollection <Tuple <Produse, Categorie, Alergen> >();
                cmd.CommandType = CommandType.StoredProcedure;
                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Produse   product  = new Produse();
                    Categorie category = new Categorie();
                    Alergen   allergen = new Alergen();

                    product.ProdusId = reader.GetInt32(0);
                    product.Nume     = reader.GetString(1);
                    product.Pret     = reader.GetDecimal(2);
                    product.Gramaj   = reader.GetInt32(3);
                    category.Nume    = reader.GetString(4);
                    allergen.Nume    = reader.GetString(5);

                    result.Add(new Tuple <Produse, Categorie, Alergen>(product, category, allergen));
                }
                reader.Close();
                return(result);
            }
            finally
            {
                connection.Close();
            }
        }
Ejemplo n.º 6
0
        //public void AddMethod(object obj)
        //{
        //    //parametrul obj este cel dat prin CommandParameter cu MultipleBinding la Button in xaml
        //    AlergenPreparatViewModel personVM = obj as AlergenPreparatViewModel;
        //    //DetaliiPreparatViewModel personVMa = obj as DetaliiPreparatViewModel;

        //    if (personVM != null)
        //    {
        //        Preparat preparat = context.Preparats.SqlQuery("[AfisarePreparatDupaID] @id_preparat", new SqlParameter("id_preparat", Properties.Settings.Default.id_preparat)).First();

        //            context.AdaugareAlergenPreparat(personVM.Denumire,preparat.denumire);
        //            //context.persoanes.Add(new persoane() { nume = personVM.Name , adresa = personVM.Address});
        //            context.SaveChanges();
        //            prepContext.Alergeni = AllAlergens();
        //            MainViewModel.Instance.ActiveScreen = new DetaliiPreparatViewModel();

        //    }
        //    }

        internal void AdaugaAlergenPreparat(Preparat preparatAles, Alergen alergenAles, Cont User)
        {
            context.AdaugareAlergenPreparat(alergenAles.denumire, preparatAles.denumire);
            //context.persoanes.Add(new persoane() { nume = personVM.Name , adresa = personVM.Address});
            context.SaveChanges();
            //prepContext.Alergeni = AllAlergens();
            MainViewModel.Instance.ActiveScreen = new DetaliiPreparatViewModel(preparatAles, User);
        }
Ejemplo n.º 7
0
 public IActionResult AddAlergen([FromBody] Alergen alergen)
 {
     try
     {
         return(new JsonResult(_repo.AddAlergen(alergen)));
     }
     catch (Exception e)
     { return(BadRequest(e)); }
 }
 public Boolean UpdateAlergen(String stariNaziv, Alergen noviAlergen)
 {
     throw new NotImplementedException();
 }
 public Boolean AddAlergen(Alergen noviAlergen)
 {
     throw new NotImplementedException();
 }