public string getVarer(string kategori)
        {
            if (kategori == "")
            {
                return("");
            }
            List <string> liste = new List <string>();

            using (var db = new prj4databaseContext())
            {
                var vk = db.VareKategori.Where(v => v.Kategori == kategori).ToList();
                if (vk.Count != 0)
                {
                    foreach (var varekat in vk)
                    {
                        liste.Add(db.Vare.Where(v => v.VareId == varekat.VareId).First().Navn);
                    }
                }
            }

            string str = "";

            foreach (var vare in liste)
            {
                str += vare + "<br>";
            }
            return(str);
        }
Esempio n. 2
0
        public void OnGet()
        {
            using (var db = new prj4databaseContext())
            {
                tilbud = db.Vare.ToList <Vare>();
            }
            //var client = new WebClient();
            //client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");

            //var stream = client.OpenRead("http://skeldekrojmand.dk/tilbud.txt");
            //var reader = new StreamReader(stream);
            //json = reader.ReadToEnd();


            //var req = WebRequest.Create(@"http://skeldekrojmand.dk/tilbud.txt");
            //req.Headers.Add("Accept - Version", "2.0");
            //req.Method = "GET";
            //using (var response = req.GetResponse())
            //using (var content = response.GetResponseStream())
            //using (var reader = new StreamReader(content))
            //{
            //    json = reader.ReadToEnd();
            //}

            /*using(WebClient client = new WebClient())
             * {
             *  json = client.DownloadString("http://skeldekrojmand.dk/tilbud.txt");
             * }*/
        }
Esempio n. 3
0
 public string getAllVarer()
 {
     using (var db = new prj4databaseContext())
     {
         var varer = db.Product.ToArray();
         var json  = JsonConvert.SerializeObject(varer);
         return(json);
     }
 }
 public void OnGet()
 {
     kategories = new List <string>();
     using (var db = new prj4databaseContext())
     {
         foreach (var kategori in db.Kategori)
         {
             kategories.Add(kategori.Kategori1);
         }
     }
 }
        public async Task <IEnumerable <Recipes> > Execute(prj4databaseContext context)
        {
            switch (LoadIngredientList)
            {
            case true:
                switch (LoadSubscriptions)
                {
                case true:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .Include(r => r.IngredientList)
                           .Include(r => r.Subscriptions)
                           .ToListAsync());

                case false:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .Include(r => r.IngredientList)
                           .ToListAsync());

                default:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .ToListAsync());
                }
                break;

            case false:
                switch (LoadSubscriptions)
                {
                case true:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .Include(r => r.Subscriptions)
                           .ToListAsync());

                case false:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .ToListAsync());

                default:
                    return(await context.Set <Recipes>()
                           .Where(r => r.Name.Contains(SearchRecipe))
                           .ToListAsync());
                }

            default:
                return(await context.Set <Recipes>()
                       .Where(r => r.Name.Contains(SearchRecipe))
                       .ToListAsync());
            }
        }
Esempio n. 6
0
        public List <Product> getVarer(string kategori)
        {
            List <Product> liste = new List <Product>();

            using (var db = new prj4databaseContext())
            {
                var vk = db.ProductCategory.Where(v => v.CategoryName == kategori).ToList();
                if (vk.Count != 0)
                {
                    foreach (var varekat in vk)
                    {
                        liste.Add(db.Product.Where(v => v.ProductId == varekat.ProductId).First());
                    }
                }
            }

            return(liste);
        }
Esempio n. 7
0
        public List <NyVare> getVarer(string kategori)
        {
            List <NyVare> liste = new List <NyVare>();

            using (var db = new prj4databaseContext())
            {
                var vk = db.VareKategori.Where(v => v.Kategori == kategori).ToList();
                if (vk.Count != 0)
                {
                    foreach (var varekat in vk)
                    {
                        liste.Add(db.NyVare.Where(v => v.VareId == varekat.VareId).First());
                    }
                }
            }

            return(liste);
            //string str = "";
            //foreach (var vare in liste)
            //{
            //    str += vare + "<br>";
            //}
            //return str;
        }
Esempio n. 8
0
 public StudentRepository(RecipeContext context)
 {
     this.context = context;
 }
Esempio n. 9
0
 public RecipesRepository(prj4databaseContext context)
 {
     this.context = context;
 }
 public NyVareRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 11
0
 public OpskriftRepository(prj4databaseContext context)
 {
     this.context = context;
 }
 public SubscriptionsRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 13
0
 public RetailChainsRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 14
0
        public void OnGet()
        {
            //string connectionString;
            //SqlConnection con;
            var client = new WebClient();

            client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");

            var     stream = client.OpenRead("http://skeldekrojmand.dk/tilbud.txt");
            var     reader = new StreamReader(stream);
            String  json   = reader.ReadToEnd();
            JObject jo     = JObject.Parse(json);
            var     array  = (JArray)jo["adverts"];

            using (var db = new prj4databaseContext())
            {
                foreach (JObject data in array.Children <JObject>())
                {
                    Vare vare = new Vare();
                    vare.Volumen = 500;
                    foreach (JProperty prop in data.Properties())
                    {
                        string propname = prop.Name;
                        switch (propname)
                        {
                        case "title":
                            vare.Navn = (string)prop.Value;
                            break;

                        case "price":
                            vare.Pris = (double)prop.Value;
                            break;

                        case "customerName":
                            vare.Butik = (string)prop.Value;
                            break;

                        case "validFrom":
                            vare.ValidFra = (string)prop.Value;
                            break;

                        case "validTo":
                            vare.ValidTil = (string)prop.Value;
                            break;

                        case "volumePrice":
                            vare.Volumenpris = (double)prop.Value;
                            break;

                        case "imageUrl":
                            vare.Imgsrc = (string)prop.Value;
                            break;
                        }
                    }
                    db.Vare.Add(vare);
                }
                db.SaveChanges();
            }

            /*foreach(JObject data in array.Children<JObject>())
             * {
             *  foreach(JProperty prop in data.Properties())
             *  {
             *      string propname = prop.Name;
             *      if(propname.Equals("title"))
             *      {
             *          streng.Add((string) prop.Value+"\n");
             *      }
             *  }
             *
             * }*/


            /*using (var db = new projtestContext())
             * {
             *  var tekst = db.Tabel.ToList();
             *  foreach(var i in tekst)
             *  {
             *      streng = i.Tekst;
             *  }
             *  var tabel = new Tabel();
             *  db.Tabel.Add(tabel);
             *
             * }*/


            //connectionString = @"Data Source=prj4-server.database.windows.net;Initial Catalog=prj4-database;User ID=martin;Password=sY0$*68y!N0v";
            //con = new SqlConnection(connectionString);
            //SqlDataAdapter adapter = new SqlDataAdapter();
            //String sql;

            //con.Open();
            //sql = "INSERT INTO Vare VALUES ('Test',10,'Aldi','10-10-10,'12-10-10,25,500,'http://www.google.dk')";
            //SqlCommand com = new SqlCommand(sql, con);

            //adapter.InsertCommand = new SqlCommand(sql, con);
            //adapter.InsertCommand.ExecuteNonQuery();

            //com.Dispose();
            //con.Close();


            postVar = Request.Query["tekst"];
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            prj4databaseContext context = new prj4databaseContext();
            RecipeQuery         test    = new RecipeQuery
            {
                LoadIngredientList = true,
                LoadSubscriptions  = true,
                SearchRecipe       = "vegetar"
            };

            var udskrift = test.Execute(context);

            foreach (var VARIABLE in udskrift.Result)
            {
                Console.WriteLine($"{VARIABLE.Name}");
            }



            //foreach (var VARIABLE in udskrift)
            //{
            //    Console.WriteLine($"{VARIABLE}");
            //}
            //Console.WriteLine("Hello World!");

            //prj4databaseContext context = new prj4databaseContext();
            //VareRepository objekt = new VareRepository(context);

            //Vare var1 = new Vare();
            ////var1.VareId = 50000;
            //var1.Navn = "Testvare";
            //var1.Pris = 2000.0;
            //var1.Butik = "Netto";
            //var1.ValidFra = "";
            //var1.ValidTil = "";
            //var1.Volumenpris = 100;
            //var1.Volumen = 200;
            //var1.Imgsrc = "";

            //objekt.InsertVare(var1);
            //objekt.Save();

            /*
             * prj4databaseContext context = new prj4databaseContext();
             * RecipesRepository repo = new RecipesRepository(context);
             * IngredientList liste = new IngredientList();
             * Vare v1 = new Vare();
             * v1.Navn = "Kødboller";
             * v1.Pris = 45;
             * v1.Butik = "Rema2000";
             * v1.ValidFra = "";
             * v1.ValidTil = "";
             * v1.Volumenpris = 45;
             * v1.Volumen = 1000;
             * v1.Imgsrc = "";
             *
             * Vare v2 = new Vare();
             * v1.Navn = "Fiskefillet";
             * v1.Pris = 21;
             * v1.Butik = "Rema23000";
             * v1.ValidFra = "";
             * v1.ValidTil = "";
             * v1.Volumenpris = 30;
             * v1.Volumen = 450;
             * v1.Imgsrc = "";
             * liste.IngredientId = 2000;
             *
             * Recipes recipe = new Recipes();
             *
             * recipe.Category = "Vegetar";
             * recipe.Directions = "1. Put ting i en skål. 2. Rør dem sammen. 3. Put det i en spand. 4. Spis med glæde!";
             * recipe.IngredientList = new List<IngredientList>();
             * recipe.Name = "VegetarMedKød";
             * recipe.Price = 45;
             * recipe.SavingsAbsolute = 20;
             * recipe.SavingsPercent = 10;
             * recipe.Servings = 2;
             * recipe.Subscriptions = new List<Subscriptions>();
             * recipe.Timestamp = DateTime.Now;
             *
             * repo.InsertRecipe(recipe);
             * repo.Save();
             */
        }
Esempio n. 16
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            using (var db = new prj4databaseContext())
            {
                RecipeController ctrl = new RecipeController();
                var result            = await ctrl.viewForSmallRecipeSearch("lasagne", "bilka;aldi;netto");

                //var Stores = new string[] {"Netto", "rema", "bilka", "aldi"};
                //HTMLCalculator calculator = new HTMLCalculator();
                //for (int i = 0; i < 20; i++)
                //{

                //    var result = await calculator.NormalPrice("lasagne", Stores);
                //}


                //RecipeQuery recipeQuery = new RecipeQuery
                //{

                //            SearchRecipe = "lasagne",
                //            LoadIngredientList = true,
                //            Stores = new string[] {"Netto", "rema", "bilka", "aldi"}
                //        };
                //        var recipes = await recipeQuery.Execute(db);
                //        foreach (var recipe in recipes)
                //        {
                //            Console.WriteLine($"{recipe.Name}");
                //            foreach (var ingredient in recipe.IngredientList.Ingredient)
                //            {
                //                Console.WriteLine($"{ingredient.Name} - {ingredient.Product.Name} - {ingredient.Product.Price} - {ingredient.Product.RetailChain.Name}");
                //            }
                //        }


                //ProductQuery query = new ProductQuery
                //{
                //    LoadRetailChain = true
                //};
                //query.ValidToDate = "2050";
                //var result = await query.Execute(db);
                //foreach (var VARIABLE in result)
                //{
                //    //Console.WriteLine($"{VARIABLE.ValidTo.ToString()}");
                //    Console.WriteLine($"{VARIABLE.RetailChain.Name}");
                //    Console.WriteLine($"{VARIABLE.Name}");
                //    Console.WriteLine($"{VARIABLE.Price + "kr"}");
                //}


                //RecipeQuery query = new RecipeQuery
                //{
                //    LoadIngredientList = true,
                //    SearchIngredient = "feta"
                //};
                //RecipeRepository repo = new RecipeRepository(db);

                //var data = await repo.GetRecipes(query);

                //foreach (var VARIABLE in data)
                //{
                //    Console.WriteLine($"{VARIABLE.Name} - {VARIABLE.Price}");
                //}
                //Recipe recipe = new Recipe
                //{
                //    Name = "One Pot Pasta med chorizo",
                //    Price = 85,
                //    Servings = 4,
                //    SavingsAbsolute = 30,
                //    CookTime = 25,
                //    ImgSrc = "https://www.valdemarsro.dk/wp-content/2017/03/one-pot-pasta-1.jpg"

                //};
                //db.Recipe.Add(recipe);
                //db.SaveChanges();

                //var directions = new Directions[]
                //{
                //    new Directions{Description = "Skær ting", RecipeId = recipe.RecipeId},
                //    new Directions{Description = "Put det i en gryde", RecipeId = recipe.RecipeId}
                //};

                //foreach (var dir in directions)
                //{
                //    db.Directions.Add(dir);
                //}

                //db.SaveChanges();

                //Category category = new Category { CategoryName = "Dansk klassisk" };
                //if (!db.Category.Contains(category))
                //{
                //    db.Category.Add(category);
                //    db.SaveChanges();
                //}

                ////RecipeCategory recipeCategory = new RecipeCategory
                ////{
                ////    RecipeId = recipe.RecipeId,
                ////    CategoryName = "Pastaret"
                ////};
                ////db.RecipeCategory.Add(recipeCategory);
                ////db.SaveChanges();

                //IngredientList ingList = new IngredientList
                //{
                //    RecipeId = recipe.RecipeId
                //};
                //db.IngredientList.Add(ingList);
                //db.SaveChanges();
                //var produkt = await db.Set<Product>().Where(p => p.Name.Contains("a")).Take(1).ToListAsync();
                //var ingredients = new Ingredient[]
                //{
                //    new Ingredient{Amount = 400, AmountUnit = "g", Name = "Spaghetti", ProductId = db.Product.Where(p => p.Name.Contains("pasta")).Take(1).ToList()[0].ProductId, IngredientListId = ingList.IngredientListId},
                //    new Ingredient{Amount = 1, AmountUnit = "dåse", Name = "Hakkede tomater", ProductId = db.Product.Where(p => p.Name.Contains("tomat")).Take(1).ToList()[0].ProductId, IngredientListId = ingList.IngredientListId},
                //    new Ingredient{Amount = 1, AmountUnit = " ", Name = "Løg", ProductId = db.Product.Where(p => p.Name.Contains("løg")).Take(1).ToList()[0].ProductId, IngredientListId = ingList.IngredientListId}
                //};
                //foreach (Ingredient i in ingredients)
                //{
                //    db.Ingredient.Add(i);
                //}
                //db.SaveChanges();
            }

            //using (var context = new prj4databaseContext())
            //{
            //    insert insert = new insert(context);
            //    await insert.insertdataAsync();
            //    RecipeRepository repo = new RecipeRepository(context);
            //    RecipeQuery query = new RecipeQuery
            //    {
            //        LoadIngredientList = true,
            //        LoadRecipeCategory = true,
            //        SearchRecipe = ""
            //    };
            //    var opskrifter = await repo.GetRecipes(query);

            //    foreach (var opskrift in opskrifter.Where(o => o.Name.Contains("marcus")))
            //    {
            //        System.Console.WriteLine($"{opskrift.Name}");
            //        Console.WriteLine($"{opskrift.Price}");
            //    }
            //}
        }
Esempio n. 17
0
 public InsertRecipeDirectionsCategoryIngredients(prj4databaseContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public PrefsCategoriesRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 19
0
 public ProductsRepository(prj4databaseContext context)
 {
     this.context = context;
 }
 public VareKategoriRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 21
0
 public ButikRepository(prj4databaseContext context)
 {
     this.context = context;
 }
 public UsersRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 23
0
 public PrefsChainRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 24
0
 public IngredientListRepository(prj4databaseContext context)
 {
     this.context = context;
 }
Esempio n. 25
0
 public AbningstidRepository(prj4databaseContext context)
 {
     this.context = context;
 }