Пример #1
0
        private void LoadShufflerCards(SSCasino_DBContext dbCasino, ShufflerControlPanel shufflerCP, int cardPackId)
        //================================================================================================================
        // Load the shuffler control panel with card packs
        //
        // Parameters
        //      dbCasino:    Database connection
        //      shufflerCP:  Shuffler control panel
        //      cardPackId:  Unique id of the desired card pack or zero
        //
        // Returns
        //      None
        //
        // Developer Notes
        //      The control panel object passed to this function is modified
        //================================================================================================================
        {
            // Load all card packs for then selection list
            shufflerCP.CardPacks = dbCasino.CardPacks.ToList();

            // If a card pack exists for the given id, use it
            // Otherwise the default card pack is used
            if (dbCasino.CardPacks.Any(e => e.CardPackId == cardPackId))
            {
                shufflerCP.SelectedCardPack = dbCasino.CardPacks.Where(e => e.CardPackId == cardPackId).FirstOrDefault();
            }
            else
            {
                shufflerCP.SelectedCardPack = dbCasino.CardPacks.Where(e => e.DefaultPack == 1).FirstOrDefault();
            }
        }
Пример #2
0
        //================================================================================================================
        //================================================================================================================
        #endregion  // Randomness

        #region Shuffler Control Panel
        //================================================================================================================
        //================================================================================================================

        public ActionResult ShufflerControlPanel_Reset()
        //================================================================================================================
        // This action is invoked when the shuffler control panel is being reset.
        //
        // Event Arguments
        //      arg_ShufflerMode: Operation mode for the shuffler
        //
        // Returns
        //      The shuffler control panel view
        //================================================================================================================
        {
            // Retrieve the operation mode for the shuffler
            SiteHelpers.ShuffleMode shuffleMode = (SiteHelpers.ShuffleMode)(!string.IsNullOrEmpty(Request.Params[ARG_SHUFFLE_MODE]) ? int.Parse(Request.Params[ARG_SHUFFLE_MODE]) : 1);

            // Create the model
            ShufflerControlPanel model = new ShufflerControlPanel(shuffleMode);

            // Load it with card packs
            SSCasino_DBContext dbCasino = null;

            try
            {
                // Connect the the database
                // Load it with all the card packs
                dbCasino = new SSCasino_DBContext();
                LoadShufflerCards(dbCasino, model, 0);
            }
            finally
            {
                if (dbCasino != null)
                {
                    dbCasino.Dispose();
                }
            }

            return(PartialView("_Shuffler_ControlPanelCBP", model));
        }