예제 #1
0
 public bool deleteRecipe(RecipeEN recipe)
 {
     bool delete = false;
     SqlConnection c = new SqlConnection(db);
     try
     {
         c.Open();
         SqlCommand com = new SqlCommand("DELETE FROM Recipe WHERE NICK = '" + recipe.Id + "'", c);
         com.ExecuteNonQuery();
         delete = true;
     }
     catch (Exception ex) { delete = false; }
     finally { c.Close(); }
     return delete;
 }
예제 #2
0
 public bool Comment(UserEN u, RecipeEN r, CommentEN c)
 {
     bool added = false;
     SqlConnection sql = new SqlConnection(db);
     try
     {
         sql.Open();
         SqlCommand com = new SqlCommand("INSERT INTO Ternary (Email, Id, Code)" +
                                         " VALUES ('" + u.Email + "', " + r.Id + ", " + c.Code + ")", sql);
         com.ExecuteNonQuery();
         added = true;
     }
     catch (Exception ex) { }
     finally
     {
         sql.Close();
     }
     return added;
 }
예제 #3
0
        public bool addRecipe(RecipeEN recipe)
        {
            bool added = false;
            SqlConnection c = new SqlConnection(db);
            try
            {
                try
                {
                    c.Open();
                    SqlCommand sentencia = new SqlCommand("SELECT MAX(Id) FROM Recipe", c);
                    SqlDataReader dr = sentencia.ExecuteReader();

                    //while (dr.Read())
                    //{
                    if (dr.Read())
                    {
                        recipe.Id = long.Parse(dr[0].ToString());
                        recipe.Id += 1;
                    }

                    dr.Close();
                }
                catch (Exception ex) { }
                finally
                {
                    c.Close();
                }

                c.Open();
                SqlCommand com = new SqlCommand("INSERT INTO Recipe (Id, Name, Time, Subtitle, Description, Video, Origin, Difficulty, Type, Image, Usuario) VALUES (" +
                    recipe.Id + ", '" + recipe.Name + "', " + recipe.Time + ", '" + recipe.Subtitle + "', '" + recipe.Description + "', '" + recipe.Video +
                    "', '" + recipe.Origin + "', '" + recipe.Difficulty + "', '" + recipe.Type + "', '" + recipe.Imagen + "', '" + recipe.User.Email + "')", c);
                com.ExecuteNonQuery();
                added = true;
            }
            catch (Exception ex) { added = false; }
            finally
            {
                c.Close();
            }
            return added;
        }
예제 #4
0
        public BookEN getBook(RecipeEN recipe)
        {
            BookEN book = new BookEN();
            SqlConnection c = new SqlConnection(db);
            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("SELECT FROM Book WHERE Title = '" + recipe.Book + "'", c);
                SqlDataReader dr = com.ExecuteReader();

                if (dr.Read())
                {
                    book.Author = dr["Author"].ToString();
                    book.Date = dr["Date"].ToString();
                    book.Isbn = dr["Isbn"].ToString();
                    book.Title = dr["Title"].ToString();
                }
            }
            catch (Exception ex) { }
            finally { c.Close(); }
            return book;
        }
예제 #5
0
        public int Puntuation(RecipeEN recipe)
        {
            int puntuacion = 0;

            return puntuacion;
        }
예제 #6
0
        public List<IngredientEN> Ingredients(RecipeEN recipe)
        {
            List<IngredientEN> ingredientes = new List<IngredientEN>();

            return ingredientes;
        }
예제 #7
0
 public void INSERT(RecipeEN e)
 {
 }
예제 #8
0
        public List<CommentEN> Comments(RecipeEN recipe)
        {
            List<CommentEN> comentarios = new List<CommentEN>();

            return comentarios;
        }
예제 #9
0
        public List<CookwareEN> Cookware(RecipeEN recipe)
        {
            List<CookwareEN> utensilios = new List<CookwareEN>();

            return utensilios;
        }
예제 #10
0
 public void voteRecipe(RecipeEN recipe, int vote)
 {
 }
예제 #11
0
        protected void do_search(object sender, EventArgs e)
        {
            RecipeEN receta = new RecipeEN();

            string text = "";

            string num = DropDownList1.SelectedIndex.ToString();

            List<RecipeEN> recetas = new List<RecipeEN>();

            if (num == "0")
            {
                if (TextBox1.Text != "")
                {
                    text = "WHERE (Name LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] "+ text +" ORDER BY [Name] ";
            }

            else if (num == "1")
            {
                if (TextBox1.Text != "")
                {
                    text = "WHERE (Author LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] "+text+" ORDER BY [Author] ";
            }

            else if (num == "2")
            {
                if (TextBox1.Text != "")
                {
                    text = "AND (Name LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] WHERE ([Difficulty] = 'Easy') "+ text +" ORDER BY [Name] ";

            }

            else if (num == "3")
            {
                if (TextBox1.Text != "")
                {
                    text = "AND (Name LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] WHERE ([Difficulty] = 'Medium') " + text + " ORDER BY [Name] ";

            }

            else if (num == "4")
            {
                if (TextBox1.Text != "")
                {
                    text = "AND (Name LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] WHERE ([Difficulty] = 'Hard') " + text + " ORDER BY [Name] ";

            }

            else if (num == "5")
            {
                if (TextBox1.Text != "")
                {
                    text = "AND (Name LIKE '%" + TextBox1.Text + "%') ";
                }
                SqlDataSource1.SelectCommand = "SELECT [Image], [Name], [Time], [Difficulty] FROM [Recipe] WHERE ([Difficulty] = 'Impossible') "+ text +" ORDER BY [Name] ";

            }
        }
예제 #12
0
        public List<CommentEN> CommentsPerRecipe(RecipeEN recipe)
        {
            RecipeCAD receta = new RecipeCAD();

            return receta.getComments(recipe);
        }
예제 #13
0
 public bool voteRecipe(RecipeEN recipe, int vote)
 {
     UserCAD u = new UserCAD();
     return u.VoteRecipe(this, recipe, vote);
 }
예제 #14
0
        protected void Upload_recipe(object sender, EventArgs e)
        {
            if (Session["login"] != null)
            {
                RecipeEN receta = new RecipeEN();
                UserEN usuario = new UserEN();

                //usuario.Password = (string)Session["login"];
                //usuario = usuario.Read();

                usuario.Email = Session["Login"].ToString();
                usuario = usuario.Read();

                receta.Name = Nombre.Text;
                receta.Subtitle = Subtitulo.Text;
                receta.Time = Int32.Parse(Tiempo.Text);
                receta.Description = Descripcion.Text;
                receta.Origin = Origen.Text;
                receta.Imagen = Foto.Text;
                receta.Video = Video.Text;
                receta.Imagen = Foto.Text;
                receta.User = usuario;

                string num = DropDownList1.SelectedIndex.ToString();

                if (num == "0")
                {
                    receta.Difficulty = "Easy";
                }

                else if (num == "1")
                {
                    receta.Difficulty = "Medium";
                }

                else if (num == "2")
                {
                    receta.Difficulty = "Hard";
                }

                else
                {
                    receta.Difficulty = "Impossible";
                }

                string tipo = DropDownList2.SelectedIndex.ToString();

                if (tipo == "0")
                {
                    receta.Type = "Starter";
                }

                else if (tipo == "1")
                {
                    receta.Type = "First Plate";
                }

                else if (tipo == "2")
                {
                    receta.Type = "Second Plate";
                }

                else
                {
                    receta.Type = "Dessert";
                }

                //receta.User = usuario;

                if (receta.INSERT())
                {
                    //MensajeOK.Text = "The recipe was uploaded correctly";
                    Nombre.Text = "";
                    Subtitulo.Text = "";
                    Tiempo.Text = "";
                    Descripcion.Text = "";
                    Origen.Text = "";
                    Descripcion.Text = "";
                    Video.Text = "";

                    MensajeOK.Text = "The recipe is uploaded! Thank You!";
                }

                else
                {
                    MensajeOK.Text = "The recipe can not be uploaded";
                }

            }

            else
            {
                MensajeOK.Text = "You have to be a registered user to upload a recipe!";
            }
        }
예제 #15
0
        public int Quantity(RecipeEN recipe, IngredientEN ingredient)
        {
            int cantidad = 0;

            return cantidad;
        }
예제 #16
0
        private List<RecipeEN> getRecipesName(RecipeEN reci)
        {
            List<RecipeEN> recipes = new List<RecipeEN>();
            RecipeEN recipe = new RecipeEN();
            SqlConnection c = new SqlConnection(db);

            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("SELECT * FROM Recipe WHERE Name = '" + reci.Name + "'", c);
                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    recipe.Id = int.Parse(dr["Id"].ToString());
                    recipe.Name = dr["Name"].ToString();
                    recipe.Time = int.Parse(dr["Time"].ToString());
                    recipe.Subtitle = dr["Subtitle"].ToString();
                    recipe.Description = dr["Description"].ToString();
                    recipe.Video = dr["Video"].ToString();
                    recipe.Origin = dr["Origin"].ToString();
                    recipe.Difficulty = dr["Difficulty"].ToString();
                    recipe.Type = dr["Type"].ToString();
                    recipe.Imagen = dr["Imagen"].ToString();
                    recipes.Add(recipe);
                }
                dr.Close();
            }
            catch (Exception ex) { }
            finally { c.Close(); }

            return recipes;
        }
예제 #17
0
 public void voteRecipe(UserEN user, RecipeEN recipe, int vote)
 {
 }
예제 #18
0
        public List<RecipeEN> getRecipes(string tipoBusqueda, RecipeEN reci)
        {
            List<RecipeEN> fr = new List<RecipeEN>();
            SqlConnection c = new SqlConnection(db);

            try
            {
                c.Open();
                switch (tipoBusqueda)
                {
                    case "Name":
                        return getRecipesName(reci);
                        break;
                    case "Hard":
                        return getRecipesHard(reci);
                        break;
                    case "Impossible":
                        return getRecipesImpossible(reci);
                        break;
                    case "Middle":
                        return getRecipesMedium(reci);
                        break;
                    case "Author":
                        return getRecipesAuth(reci);
                        break;
                }
            }
            catch (Exception ex) { }
            finally { c.Close(); }
            return fr;
        }
예제 #19
0
 public RecipeEN getRecipe(long id)
 {
     RecipeEN recipe = new RecipeEN();
     SqlConnection c = new SqlConnection(db);
     try
     {
         c.Open();
         SqlCommand com = new SqlCommand("SELECT * FROM Recipe WHERE Id = '" + id + "'", c);
         SqlDataReader dr = com.ExecuteReader();
         if (dr.Read())
         {
             recipe.Id = int.Parse(dr["Id"].ToString());
             recipe.Name = dr["Name"].ToString();
             recipe.Time = int.Parse(dr["Time"].ToString());
             recipe.Subtitle = dr["Subtitle"].ToString();
             recipe.Description = dr["Description"].ToString();
             recipe.Video = dr["Video"].ToString();
             recipe.Origin = dr["Origin"].ToString();
             recipe.Difficulty = dr["Difficulty"].ToString();
             recipe.Type = dr["Type"].ToString();
             recipe.Imagen = dr["Imagen"].ToString();
             dr.Close();
         }
     }
     catch (Exception ex) { }
     finally
     {
         c.Close();
     }
     return recipe;
 }
예제 #20
0
        /*public bool updateRecipe(RecipeEN recipe, long id)
        {
            bool updated = false;
            SqlConnection c = new SqlConnection(db);
            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("", c);
                com.ExecuteNonQuery();
                updated = true;
            }
            catch (Exception ex) { updated=false;}
            finally
            {
                c.Close();
            }
            return updated;
        }*/
        public List<CommentEN> getComments(RecipeEN reci)
        {
            List<CommentEN> lista = new List<CommentEN>();
            CommentsCAD recipeCad = new CommentsCAD();
            CommentEN recipe;
            SqlConnection c = new SqlConnection(db);
            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("SELECT Code FROM Ternary WHERE Id = " + reci.Id, c);
                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    recipe = recipeCad.READ(long.Parse(dr["Id"].ToString()));

                    lista.Add(recipe);
                }
                dr.Close();
            }
            catch (Exception ex) { }
            finally
            {
                c.Close();
            }
            return lista;
        }
예제 #21
0
 public void UPDATE(RecipeEN update)
 {
 }
예제 #22
0
 public bool VoteRecipe(UserEN u, RecipeEN r, int vote)
 {
     bool added = false;
     SqlConnection c = new SqlConnection(db);
     try
     {
         c.Open();
         SqlCommand com = new SqlCommand("INSERT INTO Puntuation (Email, Id, Puntuation)" +
                                         " VALUES ('" + u.Email + "', " + r.Id + ", " + vote + ")", c);
         com.ExecuteNonQuery();
         added = true;
     }
     catch (Exception ex) { }
     finally
     {
         c.Close();
     }
     return added;
 }
예제 #23
0
        public RecipeEN READ()
        {
            RecipeEN receta = new RecipeEN();

            return receta;
        }
예제 #24
0
 public bool Comment(RecipeEN recipe, CommentEN comment)
 {
     UserCAD u = new UserCAD();
     return u.Comment(this, recipe, comment);
 }