/// <Summary Get Collection> /// Get collection of Games. If no records to return, GameCollection will be null. /// </summary> /// <returns></returns> public static GameBOCollection GetCollection() { GameBOCollection 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 GameBOCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }
public static GameBOCollection GetGameCollectionRestfulConsume() { GameBOCollection tempCollection = new GameBOCollection(); Base myBase = new Base(); using (WebClient webClient = new WebClient()) { //Call REST service and get JSON response string json = webClient.DownloadString("http://localhost:60706/LotteryService/Game/Collection/"); List<LotteryWindowsFormsApp.BO.GameDTO> gameCollectionList = myBase.GetGameList<LotteryWindowsFormsApp.BO.GameDTO>(json); foreach (LotteryWindowsFormsApp.BO.GameDTO item in gameCollectionList) { if (!string.IsNullOrEmpty(item.GameName)) { tempCollection.Add(new GameBO { GameId = item.GameId, GameName = item.GameName }); } else { tempCollection.Add(new GameBO { GameId = item.GameId }); } } } return tempCollection; }
private GameDTOCollection HydrateGameDTOCollection(GameBOCollection gameBOCollection) { GameDTOCollection tempCollection = new GameDTOCollection(); if (gameBOCollection != null && gameBOCollection.Count > 0) { foreach (GameBO item in gameBOCollection) { if (!string.IsNullOrEmpty(item.GameName)) { tempCollection.Add(new LotteryWindowsFormsApp.Service.Data_Contracts.GameDTO { GameId = item.GameId, GameName = item.GameName }); } else { tempCollection.Add(new LotteryWindowsFormsApp.Service.Data_Contracts.GameDTO { GameId = item.GameId }); } } } return tempCollection; }
public void GameGetInformation_Instantiation_NotNull() { GameBOCollection collection = new GameBOCollection(); GameBO myGame = new GameBO(); myGame.GameDescription = new GameDescriptionBO(); myGame.GameName = "Game1"; myGame.GameDescription.GameDescript = "Description Stuff"; myGame.GameDescription.HowToPlay = "Number of balls"; collection.Add(myGame); if (collection != null) { Assert.IsTrue(true); } }