Example #1
0
        public static SyosSeatCollection GetSeatsForSyos(int perfId)
        {
            // Getting result sets from the API

            DataRowCollection seatRows;
            DataRowCollection sectionRows;
            DataRowCollection zoneRows;
            DataRowCollection zonePriceTypeRows;
            DataRowCollection priceTypeRows;

            DataSet results = unsecuredClient.GetSeats(
                sSessionKey: HttpContext.Current.Session[TessSessionKeySessionKey].ToString(),
                iPackageNumber: 0,
                iPerformanceNumber: perfId,
                sZoneList: "",
                sSectionList: "",
                sScreenList: "",
                cSummaryOnly: 'N',
                cCalcPackageAlloc: 'N',
                sCheckPriceTypes: "",
                cReturnNonSeats: 'N');
            seatRows = results.Tables["Seat"].Rows;
            sectionRows = results.Tables["Section"].Rows;
            results = unsecuredClient.GetPerformanceDetailWithDiscountingSYOSDataSet(
                SessionKey: HttpContext.Current.Session[TessSessionKeySessionKey].ToString(),
                iPerf_no: perfId,
                iModeOfSale: (short)HttpContext.Current.Session[ModeOfSaleSessionKey],
                sContentType: "");
            zoneRows = results.Tables["Section"].Rows;
            zonePriceTypeRows = results.Tables["SectionPriceTypes"].Rows;
            priceTypeRows = results.Tables["PriceTypes"].Rows;

            // Parsing results sets

            List<SyosSeatSection> sectionsList = new List<SyosSeatSection>();
            foreach (DataRow sectionRow in sectionRows)
            {
                int newSectionId = Convert.ToInt32(sectionRow["section"]);
                string newSectionName = sectionRow["section_desc"].ToString();

                List<SyosSeatZone> zonesList = new List<SyosSeatZone>();
                foreach (DataRow zoneRow in zoneRows)
                {
                    int newZoneId = Convert.ToInt32(zoneRow["Zone"]);
                    string newZoneName = zoneRow["Description"].ToString();

                    Dictionary<int, List<SyosSeat>> seatGroupList
                        = new Dictionary<int, List<SyosSeat>>();
                    foreach (DataRow seatRow in seatRows)
                    {
                        if (Convert.ToInt32(seatRow["zone_no"]) == newZoneId
                            && Convert.ToInt32(seatRow["section"]) == newSectionId
                            && (seatRow["hc_no"] == DBNull.Value
                            || !invisibleHoldCodes.Contains(Convert.ToInt32(seatRow["hc_no"]))))
                        {
                            SyosSeatStatus newStatus;
                            if (seatRow["hc_no"] != DBNull.Value)
                                newStatus = SyosSeatStatus.Unavailable;
                            else
                            {
                                bool seatFound = false;
                                if (HttpContext.Current.Session[SyosReservedSeatsSessionKey]
                                    != null)
                                {
                                    Dictionary<int, List<int>> syosReservedSeats =
                                        (Dictionary<int, List<int>>)
                                        HttpContext.Current.Session[SyosReservedSeatsSessionKey];
                                    if (syosReservedSeats.ContainsKey(perfId))
                                    {
                                        List<int> seats = syosReservedSeats[perfId];
                                        seatFound = seats.Contains(
                                            Convert.ToInt32(seatRow["seat_no"]));
                                    }
                                }
                                if (seatFound)
                                {
                                    newStatus = SyosSeatStatus.InCart;
                                }
                                else if (Convert.ToInt32(seatRow["seat_status"]) == 0)
                                {
                                    newStatus = SyosSeatStatus.Available;
                                }
                                else
                                {
                                    newStatus = SyosSeatStatus.Unavailable;
                                }
                            }
                            SyosSeat newSeat = new SyosSeat(
                                id: Convert.ToInt32(seatRow["seat_no"]),
                                number: Convert.ToInt32(seatRow["seat_num"]),
                                xposition: Convert.ToInt32(seatRow["xpos"]),
                                yposition: Convert.ToInt32(seatRow["ypos"]),
                                status: newStatus);
                            int groupId = Convert.ToInt32(seatRow["seat_row"]);
                            if (seatGroupList.ContainsKey(groupId))
                            {
                                seatGroupList[groupId].Add(newSeat);
                            }
                            else
                            {
                                List<SyosSeat> seatsList = new List<SyosSeat>();
                                seatsList.Add(newSeat);
                                seatGroupList.Add(groupId, seatsList);
                            }
                        }
                    }

                    if (seatGroupList.Count == 0)
                        continue;

                    List<PriceType> priceTypesList = new List<PriceType>();
                    foreach (DataRow zonePriceTypeRow in zonePriceTypeRows)
                    {
                        if (Convert.ToInt32(zonePriceTypeRow["Zone"]) == newZoneId)
                        {
                            int newPriceTypeId = Convert.ToInt32(zonePriceTypeRow["Id"]);
                            string newPriceTypeName = null;
                            bool newIsPromo = false;
                            foreach (DataRow priceTypeRow in priceTypeRows)
                            {
                                if (Convert.ToInt32(priceTypeRow["Id"]) == newPriceTypeId)
                                {
                                    newPriceTypeName = priceTypeRow["Description"].ToString();
                                    newIsPromo = Convert.ToBoolean(priceTypeRow["Promotion"]);
                                    break;
                                }
                            }
                            PriceType newPriceType = new PriceType(
                                id: newPriceTypeId,
                                name: newPriceTypeName,
                                price: Convert.ToInt32(zonePriceTypeRow["Price"]),
                                isDefault: false,
                                isPromo: newIsPromo);
                            priceTypesList.Add(newPriceType);
                        }
                    }

                    SyosSeatGroup[] seatGroups = new SyosSeatGroup[seatGroupList.Count];
                    int insertIndex = 0;
                    foreach (int groupId in seatGroupList.Keys)
                    {
                        SyosSeatGroup newSeatGroup = new SyosSeatGroup(
                            id: groupId,
                            seats: seatGroupList[groupId].ToArray());
                        seatGroups[insertIndex] = newSeatGroup;
                        insertIndex++;
                    }

                    SyosSeatZone newZone = new SyosSeatZone(
                        id: newZoneId,
                        description: newZoneName,
                        priceTypes: priceTypesList.ToArray(),
                        seatGroups: seatGroups);

                    zonesList.Add(newZone);
                }

                if (zonesList.Count == 0)
                    continue;

                SyosSeatSection newSection = new SyosSeatSection(
                    id: newSectionId,
                    name: newSectionName,
                    zones: zonesList.ToArray());

                sectionsList.Add(newSection);
            }

            if (sectionsList.Count == 0)
                return null;

            SyosSeatCollection newCollection = new SyosSeatCollection(sectionsList.ToArray(),
                Convert.ToInt32(results.Tables["Performance"].Rows[0]["ZoneMap"]));

            return newCollection;
        }
Example #2
0
 public SyosSeatGroup(int id, SyosSeat[] seats)
 {
     Id = id;
     Seats = seats;
 }