示例#1
0
        public static TabUserModel Parse(UserDataSet.TabUserRow row)
        {
            if (row == null)
            {
                return(null);
            }

            TabUserModel modelData = new TabUserModel();

            modelData.Uid      = row.UID;
            modelData.UserName = row.UserName;
            modelData.Password = row.Password;

            switch (row.UserLevel)
            {
            case 1:
                modelData.UserLevel = 1;
                break;

            case 2:
                modelData.UserLevel = 2;
                break;

            case 3:
                modelData.UserLevel = 3;
                break;

            default:
                modelData.UserLevel = 1;
                break;
            }

            return(modelData);
        }
示例#2
0
        public List <TabUserModel> GetAllUserDetails(int requestLevel)
        {
            if (requestLevel == 3)
            {
                _users = new List <TabUserModel>();

                try
                {
                    _tabUserTable = _userDAO.GetUser();

                    foreach (UserDataSet.TabUserRow row in _tabUserTable.Rows)
                    {
                        _users.Add(TabUserModel.Parse(row));
                    }

                    return(_users);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Table could not be filled");
                    throw ex;
                }
            }
            else
            {
                //throw access denied exception
                throw new MLMSExceptions("Access Denied");
            }
        }
示例#3
0
        public List <TabUserModel> GetAllUser()
        {
            _users = new List <TabUserModel>();

            _tabUserTable = _userDAO.GetAllUser();

            foreach (UserDS.TabUserRow row in _tabUserTable.Rows)
            {
                _users.Add(TabUserModel.Parse(row));
            }
            return(_users);
        }
示例#4
0
        /// <summary>
        /// Get user from tabUser by UDID
        /// </summary>
        /// <param name="UID"></param>
        /// <returns></returns>
        public List <TabUserModel> GetUserInfoByUID(int UID)
        {
            List <TabUserModel> _users = new List <TabUserModel>();

            _userTable = _userDao.GetInfoByUID(UID);

            foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
            {
                TabUserModel tempRow = TabUserModel.Parse(minionRow);
                _users.Add(tempRow);
            }

            return(_users);
        }
示例#5
0
        /// <summary>
        /// Get login from datatable with the value passed through
        /// </summary>
        /// <param name="userName">String Username</param>
        /// <returns>Return the value from the datatable</returns>
        public List <TabUserModel> GetLogin(string userName)
        {
            List <TabUserModel> _users = new List <TabUserModel>();

            _userTable = _userDao.GetUserName(userName);

            foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
            {
                TabUserModel tempRow = TabUserModel.Parse(minionRow);
                _users.Add(tempRow);
            }

            return(_users);
        }
示例#6
0
        public List <TabUserModel> PerformLogin(string username, string password)
        {
            _users = new List <TabUserModel>();

            if (password.Length > 0)
            {
                _tabUserTable = _userDAO.GetLogin(username, password);

                foreach (UserDS.TabUserRow row in _tabUserTable.Rows)
                {
                    _users.Add(TabUserModel.Parse(row));
                }
            }
            return(_users);
        }
        /// <summary>
        /// Get user Information
        /// </summary>
        /// <param name="UID">int</param>
        /// <returns></returns>
        public static String GetUserInfoByUID(int UID)
        {
            List <TabUserModel> _users = new List <TabUserModel>();

            UserDAO _userDao = new UserDAO();

            DataSet1.TabUserDataTable _userTable = _userDao.GetInfoByUID(UID);

            foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
            {
                TabUserModel tempRow = TabUserModel.Parse(minionRow);
                _users.Add(tempRow);
            }

            return(_users[0].UserName);
        }
示例#8
0
        //create a PARSE function that is static
        public static TabUserModel Parse(UserDataSet.TabUserRow rowFromDataSet)
        {
            if (rowFromDataSet == null)
            {
                return(null);
            }

            TabUserModel modelData = new TabUserModel();

            modelData.UserID    = rowFromDataSet.UID;
            modelData.UserName  = rowFromDataSet.UserName;
            modelData.UserLevel = rowFromDataSet.UserLevel;
            modelData.UserEmail = rowFromDataSet.UserEmail;

            return(modelData);
        }
示例#9
0
 // Get the value from the dataset and stock them in tempModel
 public static TabUserModel Parse(DataSet1.TabUserRow minionRow)
 {
     if (minionRow == null)
     {
         return(null);
     }
     else
     {
         TabUserModel tempModel = new TabUserModel();
         tempModel.UserID    = minionRow.UID;
         tempModel.UserName  = minionRow.UserName;
         tempModel.UserLevel = minionRow.UserLevel;
         tempModel.Password  = minionRow.Password;
         return(tempModel);
     }
 }
示例#10
0
        /// <summary>
        /// Returns all users data from table User.
        /// </summary>
        /// <returns>List<TabUserModel></returns>
        /// <exception cref="ex">Exception</exception>
        public List <TabUserModel> GetAllUser()
        {
            try
            {
                _users        = new List <TabUserModel>();
                _tabUserTable = _userDAO.GetAllUser();

                foreach (UserDS.TabUserRow row in _tabUserTable.Rows)
                {
                    _users.Add(TabUserModel.Parse(row));
                }
                return(_users);
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                throw;
            }
        }
示例#11
0
        public List <TabUserModel> GetLogin(String inputUsername, String inputPassword)
        {
            _users = new List <TabUserModel>();
            try
            {
                _tabUserTable = _userDAO.GetLogin(inputUsername, inputPassword);

                if (_tabUserTable.Count > 0)
                {
                    foreach (UserDataSet.TabUserRow row in _tabUserTable.Rows)
                    {
                        _users.Add(TabUserModel.Parse(row));
                    }
                }
                return(_users);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:" + ex.ToString() + ", captured. Could Not Fill Table");
                throw ex;
            }
        }//end GetLogin
示例#12
0
        /// <summary>
        /// Get user from datatable with 2 parameters UID OR UserName
        /// </summary>
        /// <param name="userName">String Username</param>
        /// <param name="UID">Int</param>
        /// <returns>Return the value from the datatable</returns>
        public List <TabUserModel> GetUserByUserNameUID(int UID, string userName)
        {
            int?UIDCheck = UID;

            if (UIDCheck == null && userName != "")
            {
                List <TabUserModel> _users = new List <TabUserModel>();

                _userTable = _userDao.GetUserName(userName);

                foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
                {
                    TabUserModel tempRow = TabUserModel.Parse(minionRow);
                    _users.Add(tempRow);
                }

                return(_users);
            }
            else if (UIDCheck != null && userName != "")
            {
                List <TabUserModel> _users = new List <TabUserModel>();

                _userTable = _userDao.GetUserByUserNameUID(UID, userName);

                foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
                {
                    TabUserModel tempRow = TabUserModel.Parse(minionRow);
                    _users.Add(tempRow);
                }

                return(_users);
            }
            else if (UIDCheck != null && userName == "")
            {
                List <TabUserModel> _users = new List <TabUserModel>();

                _userTable = _userDao.GetUserByUserNameUID(UID, "");

                foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
                {
                    TabUserModel tempRow = TabUserModel.Parse(minionRow);
                    _users.Add(tempRow);
                }

                return(_users);
            }
            else
            {
                List <TabUserModel> _users = new List <TabUserModel>();

                _userTable = _userDao.GetUser();

                foreach (DataSet1.TabUserRow minionRow in _userTable.Rows)
                {
                    TabUserModel tempRow = TabUserModel.Parse(minionRow);
                    _users.Add(tempRow);
                }

                return(_users);
            }
        }