protected void BtnOrder_Click(object sender, EventArgs e) { OfferedPizza offerPizza = HelperSession.GetOfferPizza(Session); List <Ingredient> listIngredientsSelected = HelperSession.GetListIngredientsSelected(Session); OrderPizza orderPizza = new OrderPizza(offerPizza.Id_Offered_Pizza, offerPizza.Price, listIngredientsSelected); List <OrderPizza> listOrdersPizza = HelperSession.GetListOrdersPizza(Session); listOrdersPizza.Add(orderPizza); HelperSession.SetListOrdersPizza(Session, listOrdersPizza); double partialSum = HelperSession.GetSumOrderedPizzas(Session); partialSum += orderPizza.Price; HelperSession.SetSumOrderedPizzas(Session, partialSum); double totalSum = Properties.Settings.Default.PriceDeliveryAndService + partialSum; HelperSession.SetTotalPriceOrderedPizzas(Session, totalSum); Response.Redirect("Basket.aspx"); }
protected void CbStatus_CheckedChanged(object sender, EventArgs e) { OfferedPizza offerPizza = HelperSession.GetOfferPizza(Session); List <Ingredient> listIngredientsOffer = HelperSession.GetListIngredientsOffer(Session); List <Ingredient> listIngredientsSelected = HelperSession.GetListIngredientsSelected(Session); CheckBox cbStatus = (CheckBox)sender; GridViewRow row = (GridViewRow)cbStatus.NamingContainer; if (row != null) { int index = row.RowIndex; Ingredient ingredient = listIngredientsOffer[index]; ingredient.Status = !(ingredient.Status); if (ingredient.Status) { offerPizza.Price += ingredient.Price; listIngredientsSelected.Add(ingredient); } else { offerPizza.Price -= ingredient.Price; listIngredientsSelected.Remove(ingredient); } listIngredientsOffer[index] = ingredient; LbPrice.Text = offerPizza.Price.ToString("0.00") + ""; HelperSession.SetListIngredientsOffer(Session, listIngredientsOffer); HelperSession.SetListIngredientsSelected(Session, listIngredientsSelected); HelperSession.SetOfferPizza(Session, offerPizza); } }