Ejemplo n.º 1
0
        public static GameCollection GetCollection()
        {
            GameCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetGame", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection);

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new GameCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return(tempList);
        }
 private void FillGameCollection()
 {
     foreach (GameInfo game in _gameList)
     {
         gameCollection.Add(game);
     }
 }
Ejemplo n.º 3
0
        private GameCollection ReadAvailableGames()
        {
            var result = new GameCollection();

            foreach (dynamic game in _navigationPlanJson.navigationPlan.games.properties.gamesPropertiesList)
            {
                var eventType = game.Value.eventType ?? "";
                if (eventType != JsonValues.ArenaLink && eventType != "")
                {
                    result.Add(new Game(int.Parse((string)game.Value.gameType), GetGameOrArenaFriendlyName(game)));
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load an ObservableCollection with Games
        /// </summary>
        /// <param name="error_message"></param>
        /// <returns></returns>
        public void GetAllGames(out string error_message)
        {
            _originalGameList = null;
            GameCollection.Clear();
            error_message = "";

            try
            {
                using (_gameRepository)
                {
                    _originalGameList = _gameRepository.GetAllGames(out error_message);
                }
            }
            catch (Exception ex)
            {
                error_message = ex.ToString();
            }

            foreach (Game game in _originalGameList)
            {
                GameCollection.Add(game);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Filters the game collection
        /// </summary>
        /// <param name="formatIdString"></param>
        /// <param name="publisherIdString"></param>
        /// <param name="ratingString"></param>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <param name="gameName"></param>
        public void FilterGameCollection(string formatIdString, string publisherIdString, string ratingString, string beginDate, string endDate, string gameName)
        {
            // process the inputs
            int.TryParse(formatIdString, out int formatId);
            int.TryParse(publisherIdString, out int publisherId);
            int.TryParse(ratingString, out int rating);

            if (DateTime.TryParse(beginDate, out DateTime beginDT))
            {
                beginDate = beginDT.Date.ToShortDateString();
            }

            if (DateTime.TryParse(endDate, out DateTime endDT))
            {
                endDate = endDT.Date.ToShortDateString();
            }

            //GameCollection = (ObservableCollection<Game>)
            IEnumerable <Game> outputGameList =
                (from g in _originalGameList
                 where g.FormatId == (formatId == 0 ? g.FormatId : formatId) &&
                 g.PublisherId == (publisherId == 0 ? g.PublisherId : publisherId) &&
                 g.Rating == (rating == 0 ? g.Rating : rating) &&
                 g.GameName.ToLower().Contains(gameName.ToLower()) &&
                 (beginDate == null || beginDate == "" ? 1 == 1 : DateTime.Parse(g.ReleaseDate) >= DateTime.Parse(beginDate == "" ? g.ReleaseDate : beginDate)) &&
                 DateTime.Parse(g.ReleaseDate) <= DateTime.Parse(endDate == "" ? g.ReleaseDate : endDate)
                 orderby g.GameName, g.PublisherName, g.FormatName
                 select g);

            GameCollection.Clear();

            foreach (Game game in outputGameList)
            {
                GameCollection.Add(game);
            }
        }