// map the users from the db to the view public UserDAO Map(UserPO userToMap) { // instaniate a new instance of userPO UserDAO userToView = new UserDAO(); // map the values userToView.accountInfoID = userToMap.accountInfoID; userToView.accountFirstName = userToMap.accountFirstName; userToView.accountLastName = userToMap.accountLastName; userToView.accountEmail = userToMap.accountEmail; userToView.accountPhoneNumber = userToMap.accountPhoneNumber; userToView.accountAddress = userToMap.accountAddress; userToView.accountCity = userToMap.accountCity; userToView.accountState = userToMap.accountState; userToView.accountZip = userToMap.accountZip; userToView.userTableID = userToMap.userTableID; userToView.userName = userToMap.userName; userToView.userPassword = userToMap.userPassword; userToView.userRole = userToMap.userRole; userToView.roleName = userToMap.roleName; // return the userToView return(userToView); }
// create a mapper method to map all of the users in a list public List <UserPO> Map(List <UserDAO> userListToMap) { // instaniate a new list of type userPO List <UserPO> userListToReturn = new List <UserPO>(); // create a foreach loop to loop throught the list foreach (UserDAO userToMap in userListToMap) { // instaniate a new userPO UserPO userToView = new UserPO(); // map the values userToView.accountInfoID = userToMap.accountInfoID; userToView.accountFirstName = userToMap.accountFirstName; userToView.accountLastName = userToMap.accountLastName; userToView.accountEmail = userToMap.accountEmail; userToView.accountPhoneNumber = userToMap.accountPhoneNumber; userToView.accountAddress = userToMap.accountAddress; userToView.accountCity = userToMap.accountCity; userToView.accountState = userToMap.accountState; userToView.accountZip = userToMap.accountZip; userToView.userTableID = userToMap.userTableID; userToView.userName = userToMap.userName; userToView.userPassword = userToMap.userPassword; userToView.roleName = userToMap.roleName; userToView.userRole = userToMap.userRole; userListToReturn.Add(userToView); } // return the whole list of users return(userListToReturn); }
// create the method for the UserViewModel public UserViewModel() { // instaniate a new instance of the single user and list of users singleUserPO = new UserPO(); listUserPO = new List <UserPO>(); }