예제 #1
0
        public void CreateNieuweBestelling(Bestelling bestelling)
        {
            query = @"EXECUTE CreateNieuweBestelling " + bestelling.HuidigeKlant.Klantnummer + ", " + bestelling.Ophalen + ";";
            Database.Execute(query);
            query = @"SELECT dbo.GetNieuweBestellingId() AS Id;";
            DataTable result = Database.Execute(query);
            DataRow   row    = result.Rows[0];
            int       Id     = Convert.ToInt32(row["Id"].ToString());

            foreach (Product product in bestelling.Products)
            {
                query = @"EXECUTE AddProductToBestelling " + Id + ", " + product.Id + ";";
                Database.Execute(query);
            }
            foreach (Pizza pizza in bestelling.Pizzas)
            {
                if (pizza is StandaardPizza)
                {
                    StandaardPizza newPizza = (StandaardPizza)pizza;
                    query = @"EXECUTE AddStandaardPizzaToBestelling " + Id + ", " + newPizza.Id + "; ";
                    Database.Execute(query);
                }
                else if (pizza is CustomPizza)
                {
                    CustomPizza newPizza = (CustomPizza)pizza;
                    query = @"INSERT INTO CustomPizza VALUES(" + Id + ", '" + newPizza.Vorm + "', '" + newPizza.Formaat + "');";
                    Database.Execute(query);
                    foreach (Ingredient ingredient in newPizza.Ingredienten)
                    {
                        query = @"INSERT INTO CusPizIng VALUES(" + Id + ", " + ingredient.Id + ");";
                        Database.Execute(query);
                    }
                }
            }
        }
예제 #2
0
 public decimal[] getTotalPrice()
 {
     foreach (Pizza pizza in HuidigeBestelling.Pizzas)
     {
         if (pizza is StandaardPizza)
         {
             StandaardPizza    newPizza    = (StandaardPizza)pizza;
             List <Ingredient> ingredients = InventarisRepo.GetIngredientsFromPizza(newPizza.Id);
             pizza.Ingredienten = ingredients;
         }
     }
     return(HuidigeBestelling.GetTotalPrice());
 }
예제 #3
0
        public List <Pizza> GetAllStandardPizzas()
        {
            List <Pizza> Pizzas = new List <Pizza>();

            query = @"SELECT * FROM GetAllStandaardPizzas();";
            DataTable result = Database.Execute(query);

            foreach (DataRow row in result.Rows)
            {
                int            Id       = Convert.ToInt32(row["Id"].ToString());
                string         Vorm     = row["Vorm"].ToString();
                string         Formaat  = row["Formaat"].ToString();
                string         Naam     = row["Naam"].ToString();
                StandaardPizza newPizza = new StandaardPizza(Id, Vorm, Formaat, Naam);
                Pizzas.Add(newPizza);
            }

            return(Pizzas);
        }