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; }
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; }
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; }
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; }
public int Puntuation(RecipeEN recipe) { int puntuacion = 0; return puntuacion; }
public List<IngredientEN> Ingredients(RecipeEN recipe) { List<IngredientEN> ingredientes = new List<IngredientEN>(); return ingredientes; }
public void INSERT(RecipeEN e) { }
public List<CommentEN> Comments(RecipeEN recipe) { List<CommentEN> comentarios = new List<CommentEN>(); return comentarios; }
public List<CookwareEN> Cookware(RecipeEN recipe) { List<CookwareEN> utensilios = new List<CookwareEN>(); return utensilios; }
public void voteRecipe(RecipeEN recipe, int vote) { }
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] "; } }
public List<CommentEN> CommentsPerRecipe(RecipeEN recipe) { RecipeCAD receta = new RecipeCAD(); return receta.getComments(recipe); }
public bool voteRecipe(RecipeEN recipe, int vote) { UserCAD u = new UserCAD(); return u.VoteRecipe(this, recipe, vote); }
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!"; } }
public int Quantity(RecipeEN recipe, IngredientEN ingredient) { int cantidad = 0; return cantidad; }
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; }
public void voteRecipe(UserEN user, RecipeEN recipe, int vote) { }
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; }
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; }
/*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; }
public void UPDATE(RecipeEN update) { }
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; }
public RecipeEN READ() { RecipeEN receta = new RecipeEN(); return receta; }
public bool Comment(RecipeEN recipe, CommentEN comment) { UserCAD u = new UserCAD(); return u.Comment(this, recipe, comment); }