Ejemplo n.º 1
0
 protected void DeleteFromRecipe_Click(object sender, EventArgs e)
 {
     if (IngredientList.SelectedDataKey != null)
     {
         var id = Convert.ToInt32(IngredientList.SelectedDataKey.Value);
         var listofdeletions = new List <FoodList>();
         foreach (FoodList x in Global.foods.FoodLists)
         {
             if (x.NDB_Number == id)
             {
                 listofdeletions.Add(x);
             }
         }
         foreach (var y in listofdeletions)
         {
             Global.foods.FoodLists.Remove(y);
         }
         IngredientList.DataSource = Global.foods.FoodLists.ToList();
         IngredientList.DataBind();
     }
     else
     {
         AnotherError.Text = "No ingredient selected for deletion.";
     }
 }
Ejemplo n.º 2
0
 protected void DumpSession(object sender, EventArgs e)
 {
     HttpContext.Current.Session.Clear();
     IngredientList.DataBind();
     SearchResults.DataBind();
     SelectedIngredient.Text     = "";
     AnotherError.Text           = "";
     SearchResults.SelectedIndex = -1;
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         IngredientList.DataSource = Global.foods.FoodLists.ToList();
         IngredientList.DataBind();
         RecipeTitle.Text = Global.foods.Name;
         Servings.Text    = Global.foods.Servings.ToString();
     }
 }
Ejemplo n.º 4
0
    protected void AddToList_Click(object sender, EventArgs e)
    {
        if (SearchResults.SelectedDataKey == null)
        {
            SelectedIngredient.Text = "No ingredient selected.";
        }
        else
        {
            FoodList fl = new FoodList();
            fl.NDB_Number = Convert.ToInt32(SearchResults.SelectedDataKey.Value);
            Global.foods.FoodLists.Add(fl);

            IngredientList.DataSource = Global.foods.FoodLists.ToList();

            IngredientList.DataBind();
            IngredientList.SelectedIndex = IngredientList.Rows.Count - 1;
        }
    }