Exemple #1
0
        public IEnumerable <Alchohol> GetAllAlchohols()
        {
            List <Alchohol> alchoholList = new List <Alchohol>();

            using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();

                using (SqlCommand cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM Alchohol";
                    var Reader = cmd.ExecuteReader();

                    while (Reader.Read())
                    {
                        Alchohol a = new Alchohol
                        {
                            ID      = (int)Reader["id"],
                            Name    = (string)Reader["alcName"],
                            Procent = (decimal)Reader["alcProcent"],
                            Price   = (decimal)Reader["alcPrice"],
                            Img     = (string)Reader["alcImg"]
                        };
                        alchoholList.Add(a);
                    }
                }
            }
            return(alchoholList);
        }
Exemple #2
0
        public Alchohol GetAlchohol(int id)
        {
            Alchohol alchohol = null;

            using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();
                using (SqlCommand cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "Select * From Alchohol Where id = @id";
                    cmd.Parameters.AddWithValue("id", id);
                    var Reader = cmd.ExecuteReader();
                    while (Reader.Read())
                    {
                        alchohol = new Alchohol
                        {
                            ID      = (int)Reader["id"],
                            Name    = (string)Reader["alcName"],
                            Procent = (decimal)Reader["alcProcent"],
                            Price   = (decimal)Reader["alcPrice"],
                            Img     = (string)Reader["alcImg"]
                        };
                    }
                }
            }
            return(alchohol);
        }
Exemple #3
0
 static ApplicationLogic()
 {
     meat       = new Meat();
     fruit      = new Fruits();
     nuts       = new Nuts();
     vegetables = new Vegetables();
     fish       = new Fish();
     cereals    = new Cereals();
     bread      = new Bread();
     alchohol   = new Alchohol();
     softDrinks = new SoftDrinks();
     user       = new User("Winnie the Pooh");
 }
Exemple #4
0
        public List <SuperAlchohol> GetAllDrinksByUser(int favoritesID)
        {
            List <SuperAlchohol> DrinksList = new List <SuperAlchohol>();

            using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();

                using (SqlCommand cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM FavoritesDrinks WHERE favoritesID = @favoritesID";
                    cmd.Parameters.AddWithValue("favoritesID", favoritesID);
                    var Reader = cmd.ExecuteReader();
                    while (Reader.Read())
                    {
                        Drink drink = ddb.GetDrink((int)Reader["drinkID"]);
                        DrinksList.Add(drink);
                    }
                }
                connection.Close();

                connection.Open();
                using (SqlCommand cmd2 = connection.CreateCommand())
                {
                    cmd2.CommandText = "SELECT * FROM FavoritesAlchohol WHERE favoritesID = @favoritesID";
                    cmd2.Parameters.AddWithValue("favoritesID", favoritesID);
                    var Reader2 = cmd2.ExecuteReader();
                    while (Reader2.Read())
                    {
                        Alchohol drink = aDB.GetAlchohol((int)Reader2["alchoholID"]);
                        DrinksList.Add(drink);
                    }
                }
                connection.Close();

                connection.Open();
                using (SqlCommand cmd3 = connection.CreateCommand())
                {
                    cmd3.CommandText = "SELECT * FROM FavoritesHelflask WHERE favoritesID = @favoritesID";
                    cmd3.Parameters.AddWithValue("favoritesID", favoritesID);
                    var Reader3 = cmd3.ExecuteReader();
                    while (Reader3.Read())
                    {
                        HelFlask drink = hfDB.GetHelFlask((int)Reader3["helflaskID"]);
                        DrinksList.Add(drink);
                    }
                }
            }
            return(DrinksList);
        }
Exemple #5
0
 public void CreateAlchohol(Alchohol alchohol)
 {
     using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
     {
         connection.Open();
         using (SqlCommand cmd = connection.CreateCommand())
         {
             cmd.CommandText = "Insert Into dbo.Alchohol(alcName, alcProcent, alcPrice, alcImg) values(@alcName, @alcProcent, @alcPrice, @alcImg)";
             //cmd.Parameters.AddWithValue("id", entity.Id);
             cmd.Parameters.AddWithValue("alcName", alchohol.Name);
             cmd.Parameters.AddWithValue("alcPrice", alchohol.Price);
             cmd.Parameters.AddWithValue("alcImg", alchohol.Img);
             cmd.Parameters.AddWithValue("alcProcent", alchohol.Procent);
             cmd.ExecuteNonQuery();
         }
     }
 }
Exemple #6
0
        public List <Alchohol> GetAllAlchoholsByMenu(int menuId)
        {
            List <Alchohol> AlchoholList = new List <Alchohol>();

            using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();

                using (SqlCommand cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM MenucardAlchohol WHERE menuID = @menuID";
                    cmd.Parameters.AddWithValue("menuID", menuId);
                    var Reader = cmd.ExecuteReader();
                    while (Reader.Read())
                    {
                        Alchohol drink = adb.GetAlchohol((int)Reader["alchoholID"]);
                        AlchoholList.Add(drink);
                    }
                }
            }
            return(AlchoholList);
        }
 public void CreateAlchohol(Alchohol alchohol)
 {
     aDB.CreateAlchohol(alchohol);
 }