Пример #1
0
        //Method that pulls back general information for the view
        public ActionResult Index()
        {
            //declaring list using model UserPO
            List <UserPO> mappedUsers = new List <UserPO>();

            //Beginning of processes
            try
            {
                //declaring list using Model UserDO in order to retrieve database information
                List <UserDO> allUsers = _dataAccess.UserReadAll();
                //loop to get all objects assigned appropriately
                foreach (UserDO dataObject in allUsers)
                {
                    //assign our PO list all of the values that were in the DO list via mapper
                    mappedUsers.Add(MapUserTF.UserDOtoPO(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(mappedUsers));
        }
Пример #2
0
        //Method that allows user to input the information they want to update
        public ActionResult UpdateUser(int UserId)
        {
            //declaring object using model PlayerPO
            UserPO userToUpdate = new UserPO();

            //Beginning of processes
            try
            {
                //declare List using Model UserDO, and use it to store all information on the game recovered by using a DAL access call
                UserDO item = _dataAccess.UserReadByID(UserId);
                //assign all data to object using a mapper
                userToUpdate = MapUserTF.UserDOtoPO(item);
            }
            //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(userToUpdate));
        }
Пример #3
0
        //Method that passes in the User input to the database to be saved
        public ActionResult AddUser(UserPO 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
                    UserDO dataObject = MapUserTF.UserPOtoDO(form);
                    //calling on a DAL access field to allow us to use a specific method within, while passing in the DO object
                    _dataAccess.UserCreate(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("UserLogin", "User");
            }
            //section of code that runs if the form is not valid
            else
            {
                //assigns a page redirection to our variable
                result = View(form);
            }
            //runs the portion of code that is necessary for the situation
            return(result);
        }