Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check the Session variables to make sure we have started an order
            // and chose a pizza to add
            Order order = (Order)Session["order"];
            pizza_to_add = (Pizza)Session["pizza_to_add"];
            if ((order == null) || (pizza_to_add == null)) {
                Response.Redirect("OrderPizza.aspx");
            }

            // Display the base description of the pizza
            PizzaLabel.Text = pizza_to_add.name + "; includes " +
                pizza_to_add.base_toppings + ". Starts at " +
                pizza_to_add.base_cost.ToString("c");
        }
        protected void PizzasGridView_RowCommand(
            object sender, GridViewCommandEventArgs e)
        {
            // TODO(topher): Instead of polling the asp fields, is there a
            // better way we should be getting this data?
            DataKey pizza = PizzasGridView.DataKeys[
                Convert.ToInt32(e.CommandArgument)];
            string name = (string)pizza["name"];
            string base_toppings = (string)pizza["description"];
            decimal cost = (decimal)pizza["cost"];

            // TODO(topher): Is there a better way to pass a temporary object
            // to the next page? Should we be creating the Pizza on the next page?
            Session["pizza_to_add"] = new Pizza(name, base_toppings, cost);

            Response.Redirect("AddPizza.aspx");
        }
Example #3
0
 public void AddPizza(Pizza pizza)
 {
     pizzas.Add(pizza);
 }