Exemplo n.º 1
0
        public static Cart BuildSummaryCart(Reservation reservation, SeatingZone[] seatingInfo)
        {
            Cart cart = new Cart();
            List<CartSeatGroupItem> seatGroups = cart.SeatGroups = new List<CartSeatGroupItem>();

            foreach (ReservationSeatingZone seatingZone in reservation.Sections)
            {
                CartSeatGroupItem newItem = new CartSeatGroupItem();
                newItem.Performance = WebClient.GetPerformance(reservation.PerfId);
                string description = null;
                foreach (SeatingZone zone in seatingInfo)
                {
                    if (zone.Id == seatingZone.SectionId)
                    {
                        description = zone.Name;
                        break;
                    }
                }
                newItem.SeatingZoneName = description;
                newItem.SeatingZoneId = seatingZone.SectionId;
                newItem.SeatsPerPriceTypes = new List<CartPriceTypeSeats>();
                foreach (PriceTypeSeatsPair seatsPerPriceType in seatingZone.PriceTypesSeats)
                {
                    double pricePerSeat = 0;
                    string priceTypeName = null;
                    bool found = false;
                    foreach (SeatingZone zone in seatingInfo)
                    {
                        if (zone.Id == seatingZone.SectionId)
                        {
                            foreach (PriceType priceType in zone.PriceTypes)
                            {
                                if (priceType.Id == seatsPerPriceType.PriceTypeId)
                                {
                                    pricePerSeat = priceType.Price;
                                    priceTypeName = priceType.Name;
                                    found = true;
                                    break;
                                }
                            }
                            if (found)
                                break;
                        }
                    }
                    newItem.SeatsPerPriceTypes.Add(
                        new CartPriceTypeSeats
                        {
                            SeatCount = seatsPerPriceType.SeatCount,
                            PricePerSeat = pricePerSeat,
                            PriceTypeName = priceTypeName
                        });
                }
                seatGroups.Add(newItem);
            }
            return cart;
        }
Exemplo n.º 2
0
 // TODO: consider: is there ever a time to set exceptionOnSessionError to false?
 /// <summary>
 ///     Gets the cart for the current session, or returns null for an expired cart.
 /// </summary>
 /// <param name="exceptionOnSessionError">
 ///     Whether the method should throw an exception when lacking an authenticated session.
 /// </param>
 public static Cart GetCart(bool exceptionOnSessionError)
 {
     DataSet cartResults = null;
     if (!MaintainedSessionExists())
     {
         if (exceptionOnSessionError)
             // TODO: Check if it's safe to call MaintainTessSession() automatically
             throw new ApplicationException("GetCart() was called out of sequence. A "
                 + "maintained Tessitura session is required. Try calling "
                 + "MaintainTessSession() first.");
     }
     else
     {
         try
         {
             cartResults = unsecuredClient.GetCart(
                 HttpContext.Current.Session[TessSessionKeySessionKey].ToString());
         }
         catch (Exception exception)
         {
             if (exception.Message.Contains("TESSITURA_ACCESS_DENIED_EXCEPTION"))
             {
                 Logout();
                 //HttpContext.Current.Response.Redirect("/");
             }
             else if (!exception.Message.Contains("TESSITURA_SEAT_LOCKING_EXCEPTION"))
                 throw exception;
         }
     }
     //            if (cartResults != null && cartResults.Tables["Order"] != null
     //                && cartResults.Tables["LineItem"] != null)
     if (cartResults != null && cartResults.Tables["Order"].Rows.Count > 0)
     {
         Cart cart = new Cart();
         cart.Id = Convert.ToInt32(cartResults.Tables["Order"].Rows[0]["order_no"]);
         cart.SeatGroups = new List<CartSeatGroupItem>();
         DataRowCollection lineItemResults = cartResults.Tables["LineItem"].Rows;
         foreach (DataRow lineItemResult in lineItemResults)
         {
             CartSeatGroupItem seatGroup = new CartSeatGroupItem();
             seatGroup.Id = Convert.ToInt32(lineItemResult["li_seq_no"]);
             seatGroup.Performance = GetPerformance(Convert.ToInt32(lineItemResult["perf_no"]));
             seatGroup.SeatingZoneId = Convert.ToInt32(lineItemResult["zone_no"]);
             seatGroup.SeatingZoneName = null;
             seatGroup.SeatsPerPriceTypes = new List<CartPriceTypeSeats>();
             DataRowCollection subLineItemResults = cartResults.Tables["SubLineItem"].Rows;
             foreach (DataRow subLineItemResult in subLineItemResults)
             {
                 if (subLineItemResult["li_seq_no"].ToString()== lineItemResult["li_seq_no"].ToString())
                 {
                     if (seatGroup.SeatingZoneName == null)
                     {
                         seatGroup.SeatingZoneName =
                             subLineItemResult["zone_desc"].ToString();
                     }
                     int foundIndex = -1;
                     for (int c = 0; c < seatGroup.SeatsPerPriceTypes.Count; c++)
                     {
                         if (seatGroup.SeatsPerPriceTypes[c].PriceTypeId
                             == Convert.ToInt32(subLineItemResult["price_type"]))
                         {
                             foundIndex = c;
                             break;
                         }
                     }
                     CartPriceTypeSeats priceTypeSeats = new CartPriceTypeSeats();
                     priceTypeSeats.PriceTypeId =Convert.ToInt32(subLineItemResult["price_type"]);
                     foreach (DataRow priceTypeResult in cartResults.Tables["PriceType"].Rows)
                     {
                         if (Convert.ToInt32(priceTypeResult["price_type"])== priceTypeSeats.PriceTypeId)
                         {
                             priceTypeSeats.PriceTypeName =priceTypeResult["description"].ToString();
                             priceTypeSeats.PriceTypeIsDefault =Convert.ToChar(priceTypeResult["def_price_type"])== 'Y';
                             break;
                         }
                     }
                     priceTypeSeats.PricePerSeat = Convert.ToDouble(subLineItemResult["due_amt"]);
                     priceTypeSeats.SeatCount = 1;
                     priceTypeSeats.Seats = new List<CartSeat>();
                     CartSeat newSeat = new CartSeat();
                     newSeat.RowIdentifier = subLineItemResult["seat_row"].ToString();
                     newSeat.SeatNumInRow = Convert.ToInt32(subLineItemResult["seat_num"]);
                     newSeat.Id = Convert.ToInt32(subLineItemResult["seat_no"]);
                     newSeat.Fees = new List<CartFee>();
                     foreach (DataRow feeResult in cartResults.Tables["SubLineItemFee"].Rows)
                     {
                         if (Convert.ToInt32(subLineItemResult["sli_no"])
                             == Convert.ToInt32(feeResult["sli_no"]))
                         {
                             newSeat.Fees.Add(new CartFee
                             {
                                 Amount = Convert.ToDouble(feeResult["fee_amt"]),
                                 Description = feeResult["category_desc"].ToString()
                             });
                         }
                     }
                     priceTypeSeats.Seats.Add(newSeat);
                     if (foundIndex == -1)
                     {
                         seatGroup.SeatsPerPriceTypes.Add(priceTypeSeats);
                     }
                     else
                     {
                         seatGroup.SeatsPerPriceTypes[foundIndex].Absorb(priceTypeSeats);
                     }
                 }
             }
             cart.SeatGroups.Add(seatGroup);
         }
         return cart;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 3
0
 private string getSeatString(CartSeatGroupItem seatGroup)
 {
     StringBuilder seatText = new StringBuilder("");
     foreach (CartPriceTypeSeats priceTypeSeats in seatGroup.SeatsPerPriceTypes)
     {
         foreach (CartSeat seat in priceTypeSeats.Seats)
         {
             seatText.Append(" " + seat.RowIdentifier + "-"
                 + seat.SeatNumInRow.ToString() + ",");
         }
     }
     return seatText.ToString().Substring(0, seatText.Length - 1);//to eliminate trailing comma
 }