Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                //show Recipe details
                recipeID = int.Parse(Request.QueryString["id"]);
                RecipeDataBaseRepository repo = new RecipeDataBaseRepository();
                Recipe recipe = repo.GetRecipe(recipeID);
                divTitle.InnerText            = "Recipe Details: " + recipe.name;
                divCategory.InnerHtml         = String.Format("<h5>{0}</h5>", recipe.category);
                divCookingTime.InnerHtml      = String.Format("<h5>{0}</h5>", recipe.cookingTime.ToString());
                divNumberOfServings.InnerHtml = String.Format("<h5>{0}</h5>", recipe.numberOfServings.ToString());
                divSubmitBy.InnerHtml         = String.Format("<h5>{0}</h5>", recipe.submitBy);
                divDescription.InnerHtml      = String.Format("<h5>{0}</h5>", recipe.description);

                //show Ingredients details
                foreach (Ingredient ing in recipe.ingredients)
                {
                    HtmlTableRow  row  = new HtmlTableRow();
                    HtmlTableCell cell = new HtmlTableCell();
                    cell.InnerText = ing.name;
                    row.Cells.Add(cell);
                    cell           = new HtmlTableCell();
                    cell.InnerText = ing.quantity;
                    row.Cells.Add(cell);
                    cell           = new HtmlTableCell();
                    cell.InnerText = ing.unit;
                    row.Cells.Add(cell);
                    tbl.Rows.Add(row);
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadUpdate()
        {
            HideAlertMessage(divMessage);
            recipeID = int.Parse(Request.QueryString["id"]);
            RecipeDataBaseRepository repo = new RecipeDataBaseRepository();
            Recipe recipe = repo.GetRecipe(recipeID);

            //check Authenticate
            if (isAuthenticated(recipe.submitBy))
            {
                plDetails.Visible = false;
                plUpdate.Visible  = true;
                // ShowAlertMessage(divMessage);

                txtName.Text             = recipe.name;
                txtSubmitBy.Text         = recipe.submitBy;
                txtSubmitBy.ReadOnly     = true;
                txtSubmitBy.CssClass     = "form-control";
                txtCookingTime.Text      = recipe.cookingTime.ToString();
                txtNumberOfServings.Text = recipe.numberOfServings.ToString();
                txtDescription.Text      = recipe.description;
                ucCategories1.Value      = recipe.category;

                ucListEditIngedient1.Initialize(recipe.ingredients);
            }
        }
Ejemplo n.º 3
0
        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            RecipeDataBaseRepository repo = new RecipeDataBaseRepository();

            ListView1.DataSource = repo.GetRecipes(txtSubmitBy.Text, txtCategory.Text, txtIngredient.Text);
            ListView1.DataBind();
        }
Ejemplo n.º 4
0
 protected void ListView1_ItemCommand(object sender, System.Web.UI.WebControls.ListViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteItem")
     {
         RecipeDataBaseRepository repo = new RecipeDataBaseRepository();
         repo.DeleteRecipe(Convert.ToInt32(e.CommandArgument));
         ListView1.DataBind();
         ShowAlertMessage(divMessage);
     }
 }
Ejemplo n.º 5
0
        private void LoadDeitals()
        {
            //show Recipe details
            plDetails.Visible = true;
            plUpdate.Visible  = false;

            if (Request.QueryString["success"] == "true")
            {
                ShowAlertMessage(divMessage);
            }
            else
            {
                HideAlertMessage(divMessage);
            }

            recipeID = int.Parse(Request.QueryString["id"]);
            RecipeDataBaseRepository repo = new RecipeDataBaseRepository();
            Recipe recipe = repo.GetRecipe(recipeID);

            divTitle.InnerText            = recipe.name;
            divCategory.InnerHtml         = String.Format("<h5>{0}</h5>", recipe.category);
            divCookingTime.InnerHtml      = String.Format("<h5>{0}</h5>", recipe.cookingTime.ToString());
            divNumberOfServings.InnerHtml = String.Format("<h5>{0}</h5>", recipe.numberOfServings.ToString());
            divSubmitBy.InnerHtml         = String.Format("<h5>{0}</h5>", recipe.submitBy);
            divDescription.InnerHtml      = String.Format("<h5>{0}</h5>", recipe.description);

            //show Ingredients details
            foreach (Ingredient ing in recipe.ingredients)
            {
                HtmlTableRow  row  = new HtmlTableRow();
                HtmlTableCell cell = new HtmlTableCell();
                cell.InnerText = ing.name;
                row.Cells.Add(cell);
                cell           = new HtmlTableCell();
                cell.InnerText = ing.quantity;
                row.Cells.Add(cell);
                cell           = new HtmlTableCell();
                cell.InnerText = ing.unit;
                row.Cells.Add(cell);
                tbl.Rows.Add(row);
            }
            //if user does not login, can not modify the data
            btnModify.Visible = isAuthenticated(recipe.submitBy);
        }