//Method of getting general information for a player via DAL access call public ActionResult Index() { //declaring list using model GamePO List <PlayerPO> mappedPlayers = new List <PlayerPO>(); //Beginning of processes try { //declaring list using Model PlayerDO in order to retrieve database information List <PlayerDO> allPlayers = _dataAccess.PlayerReadAll(); //loop to get all objects assigned appropriately foreach (PlayerDO dataObject in allPlayers) { //assign our PO list all of the values that were in the DO list via mapper mappedPlayers.Add(MapPlayerTF.PlayerDOtoPO(dataObject)); } } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(mappedPlayers)); }
//Method for taking in the necessary data to add a new game to the database public ActionResult AddGame() { //declaring object using model GamePO GamePO game = new GamePO(); //Beginning of processes try { //declare List using Model PlayerDO, and use it to store all information on all players recovered by using a DAL access call List <PlayerDO> players = _playerAccess.PlayerReadAll(); //Declare list to hold player names List <SelectListItem> options = new List <SelectListItem>(); //loop to get all objects assigned appropriately foreach (PlayerDO dataObject in players) { //Declare new object to temporarily hold data SelectListItem option = new SelectListItem(); //make list aspect equal dataObject variable option.Text = dataObject.Name; //make list aspect equal dataObject variable option.Value = dataObject.PlayerId.ToString(); //take object "option", and add it to list "options" options.Add(option); } //set object value of PlayersDropDown equal to values of "options" game.PlayersDropDown = options; } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(game)); }