예제 #1
0
        public static Reservation ReserveBestSeating(Reservation reservation)
        {
            Reservation unreserved = new Reservation(reservation.PerfId);
            foreach (ReservationSeatingZone request in reservation.Sections)
            {
                StringBuilder priceTypeParam = new StringBuilder();
                if (request.PriceTypesSeats.Count == 1)
                    priceTypeParam.Append(request.PriceTypesSeats[0].PriceTypeId);
                else
                {
                    List<int> priceTypes = new List<int>();
                    foreach (PriceTypeSeatsPair seatsPrice in request.PriceTypesSeats)
                    {
                        for (int c = 0; c < seatsPrice.SeatCount; c++)
                        {
                            priceTypes.Add(seatsPrice.PriceTypeId);
                        }
                    }
                    priceTypeParam.Append(priceTypes[0].ToString());
                    for (int c = 1; c < priceTypes.Count; c++)
                    {
                        priceTypeParam.Append("," + priceTypes[c].ToString());
                    }
                }
                int seatsReserved = 0;
                try
                {
                    seatsReserved =
                        unsecuredClient.ReserveTicketsEx(
                            sWebSessionID:
                                HttpContext.Current.Session[TessSessionKeySessionKey].ToString(),
                            sPriceType: priceTypeParam.ToString(),
                            iPerformanceNumber: reservation.PerfId,
                            iNumberOfSeats: request.NumOfSeats,
                            iZone: request.SectionId,
                            sSpecialRequests: "");
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("TESSITURA_SEAT_LIMIT_EXCEPTION"))
                        throw e;
                }

                if (seatsReserved < request.NumOfSeats)
                {
                    foreach (PriceTypeSeatsPair priceSeats in request.PriceTypesSeats)
                    {
                        unreserved.AddPriceTypeSeats(request.SectionId, priceSeats.PriceTypeId,
                            priceSeats.SeatCount);
                    }
                }
            }
            if (unreserved.Sections.Count < reservation.Sections.Count)
            {
                checkExpireTime();
            }
            return unreserved;
        }
예제 #2
0
 protected void AddSeatsToCart(object sender, EventArgs e)
 {
     if (SelectionModeViews.GetActiveView() == BestSeatingModeView)
     {
         Reservation res = new Reservation(Int32.Parse(PerfField.SelectedValue));
         foreach (string key in Request.Form.AllKeys)
         {
             if (key.StartsWith("seats_"))
             {
                 string[] queryKeyParts = key.Split('_');
                 int sectionId = Int32.Parse(queryKeyParts[1]);
                 int priceTypeId = Int32.Parse(queryKeyParts[2]);
                 int numOfSeats = Int32.Parse(Request.Form[key]);
                 if (numOfSeats > 0)
                 {
                     res.AddPriceTypeSeats(sectionId, priceTypeId, numOfSeats);
                 }
             }
         }
         Reservation unreserved = WebClient.ReserveBestSeating(res);
         if (unreserved.Sections.Count == res.Sections.Count)
         {
             ReservationErrorFlag.Value = "1";
         }
         else
         {
             ViewState.Remove("perfs");
             if (unreserved.Sections.Count == 0)
             {
                 FailedResPanel.Visible = false;
             }
             else
             {
                 ViewState.Add("unreserved", unreserved);
                 res.RemoveSections(unreserved.Sections);
             }
             ViewState.Add("reserved", res);
             OrderWizardViews.SetActiveView(ConfirmationView);
         }
     }
     else if (SelectionModeViews.GetActiveView() == SyosModeView)
     {
         if (syosRequestProcessed)
             return;
         SyosReservation res = new SyosReservation(Int32.Parse(PerfField.SelectedValue));
         foreach (string key in Request.Form.AllKeys)
         {
             if (key.StartsWith("SyosSeat_"))
             {
                 string[] queryKeyParts = key.Split('_');
                 int sectionId = Int32.Parse(queryKeyParts[2]);
                 int zoneId = Int32.Parse(queryKeyParts[4]);
                 int priceTypeId = Int32.Parse(queryKeyParts[6]);
                 int seatId = Int32.Parse(queryKeyParts[8]);
                 res.AddSeat(sectionId, zoneId, priceTypeId, seatId);
             }
         }
         SyosReservation unreserved = WebClient.ReserveSyos(res);
         if (res.SeatCount == 0)
         {
             ReservationErrorFlag.Value = "1";
         }
         else if (res.SeatCount == 1)
         {
             if (unreserved.SeatCount == 1)
                 FailedSeatAddFlag.Value = "1";
             else
                 SeatAddSuccessFlag.Value = "1";
         }
         else
         {
             if (unreserved.SeatCount == res.SeatCount)
                 ReservationErrorFlag.Value = "1";
             else
             {
                 SeatsAddSuccessFlag.Value = "1";
                 // TODO: add successful reservations to list
                 if (unreserved.SeatCount > 0)
                 {
                     FailedSeatsAddFlag.Value = "1";
                     // TODO: add failed reservations to list
                 }
             }
         }
         syosRequestProcessed = true;
     }
 }