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; } }
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; }
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; }