Example #1
0
        public static Selection[] ConvertSelectionTypeCollection(SelectionType[] remoteSelections)
        {
            Selection[] localSelections = new Selection[remoteSelections.Length];

            for (int i = 0 ; i < remoteSelections.Length ; i++)
            {
                localSelections[i] = new Selection();
                localSelections[i].Id = remoteSelections[i].Id;
                localSelections[i].Name  = remoteSelections[i].Name;
                localSelections[i].Status  = remoteSelections[i].Status;
                localSelections[i].ResetCount  = remoteSelections[i].ResetCount;
                localSelections[i].DeductionFactor  = remoteSelections[i].DeductionFactor;
            }

            return localSelections;
        }
Example #2
0
        public static Selection[] ConvertSelectionTypeWithPricesCollection(SelectionTypeWithPrices[] remoteSelections)
        {
            Selection[] localSelections = new Selection[remoteSelections.Length];

            for (int i = 0 ; i < remoteSelections.Length ; i++)
            {
                localSelections[i] = new Selection();
                localSelections[i].Id = remoteSelections[i].Id;
                localSelections[i].Name  = remoteSelections[i].Name;
                localSelections[i].Status  = remoteSelections[i].Status;
                localSelections[i].ResetCount  = remoteSelections[i].ResetCount;
                localSelections[i].DeductionFactor  = remoteSelections[i].DeductionFactor;

                if (remoteSelections[i].ForSidePrices != null)
                    localSelections[i].PricesFor = PriceConverter.ConvertPricesTypeCollection(remoteSelections[i].ForSidePrices);

                if (remoteSelections[i].AgainstSidePrices != null)
                    localSelections[i].PricesAgainst = PriceConverter.ConvertPricesTypeCollection(remoteSelections[i].AgainstSidePrices);
            }

            return localSelections;
        }
Example #3
0
        public static DataTable CreateAndPopulateSelectionsTable(Selection[] selections)
        {
            DataTable selectionsTable = new DataTable();

            selectionsTable.Columns.Add("Back 3");
            selectionsTable.Columns.Add("Back 2");
            selectionsTable.Columns.Add("Back 1");

            selectionsTable.Columns.Add("Name");
            selectionsTable.Columns.Add("Id");

            selectionsTable.Columns.Add("Lay 1");
            selectionsTable.Columns.Add("Lay 2");
            selectionsTable.Columns.Add("Lay 3");

            foreach (Selection subSelection in selections)
            {
                DataRow newRow = selectionsTable.NewRow();

                // Show the for prices.
                if (subSelection.PricesFor != null)
                    for (int i = 0 ; i < 3 ; i++)
                    {
                        // Have to use annoying little algo, so that can do stuff like place the
                        //  3rd price in the 1st column, 2nd price in 2nd col, 1st price in 3rd column.
                        // So, first time through this loop, check if there is a 3rd price and if so place in first column.
                        if (subSelection.PricesFor.Length >= (3-i))
                        {
                            // E.g. "$32 at 2.5".
                            // Obviously need to handle currency symbol properly.
                            string priceOddsText = string.Format("${0} at {1}", subSelection.PricesFor[2-i].Stake, subSelection.PricesFor[2-i].Odds);
                            newRow[i] = priceOddsText;
                        }
                        else
                            // If there is no price then just empty string.
                            newRow[i] = "";
                    }

                // In between the for prices and against prices want to place the selection details.
                newRow[3] = subSelection.Name;
                newRow[4] = subSelection.Id;

                // Show the against prices.
                if (subSelection.PricesAgainst != null)
                    for (int i = 0 ; i < 3 ; i++)
                    {
                        // Against prices go in regular order, but starting in column 5 makes more annoying.
                        // So, 1st price goes in 5th column, 2nd in 6th, 3rd in 6th.
                        if (subSelection.PricesAgainst.Length >= (i+1))
                        {
                            // As above.
                            string priceOddsText = string.Format("${0} at {1}", subSelection.PricesAgainst[i].Stake, subSelection.PricesAgainst[i].Odds);
                            newRow[5+i] = priceOddsText;
                        }
                        else
                            // If there is no price then just empty string.
                            newRow[5+i] = "";
                    }

                selectionsTable.Rows.Add(newRow);
            }

            return selectionsTable;
        }