Exemplo n.º 1
0
        //Method of getting the general information of a game from the database, and sending it up to the user
        public ActionResult Index()
        {
            //declaring list using model GamePO
            List <GamePO> mappedGame = new List <GamePO>();

            //Beginning of processes
            try
            {
                //declaring list using Model GameDO in order to retrieve database information
                List <GameDO> allGames = _dataAccess.GameReadAll();
                //loop to get all objects assigned appropriately
                foreach (GameDO dataObject in allGames)
                {
                    //assign our PO list all of the values that were in the DO list via mapper
                    mappedGame.Add(MapGameTF.GameDOtoPO(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(mappedGame));
        }
Exemplo n.º 2
0
        //Takes in the information that a user wants to update about a certain game
        public ActionResult UpdateGame(int gameId)
        {
            //declaring object using model GamePO
            GamePO gameToUpdate = new GamePO();

            //Beginning of processes
            try
            {
                //declare List using Model GameDO, and use it to store all information on the game recovered by using a DAL access call
                GameDO item = _dataAccess.GameReadByID(gameId);
                //assign all data to object using a mapper
                gameToUpdate = MapGameTF.GameDOtoPO(item);
                //establish list to hold all data on all players as recovered by the DAL access call
                List <PlayerDO> players = _playerAccess.PlayerReadAll();
                //declare list to hold relevant data from full DAL call
                List <SelectListItem> options = new List <SelectListItem>();
                foreach (PlayerDO dataObject in players)
                {
                    //Declare list to hold player names
                    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"
                gameToUpdate.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(gameToUpdate));
        }
Exemplo n.º 3
0
        //Method to pass information into the database and update the necessary game
        public ActionResult UpdateGame(GamePO form)
        {
            //Declaring an action result variable, but assigning it to null to reassign later
            ActionResult result = null;

            //Checks to see if the UI form is filled out correctly
            if (ModelState.IsValid)
            {
                //Beginning of processes
                try
                {
                    //passing the UI form information to run through our mapper, and assigning it to a DO object
                    GameDO dataObject = MapGameTF.GamePOtoDO(form);
                    //calling on a DAL access field to allow us to use a specific method within, while passing in the DO object
                    _dataAccess.GameUpdate(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
                { }
                //assigns a page redirection to our variable
                result = RedirectToAction("Index", "Game");
            }
            //section of code that runs if the form is not valid
            else
            {
                //assigning a value to our variable that will be used if the form isn't valid
                result = View(form);
            }
            //runs the portion of code that is necessary for the situation
            return(result);
        }