Beispiel #1
0
        public string GetNameByUsername(string userName)
        {
            var loginAdapter = new staff_credentialsTableAdapter();

            try
            {
                using (loginAdapter)
                {
                    var staffCredentialsRow =
                        loginAdapter.GetData().FirstOrDefault(login => login.username.Equals(userName));
                    if (staffCredentialsRow != null)
                    {
                        var id           = staffCredentialsRow.staff_staffID;
                        var staffadapter = new staffTableAdapter();
                        using (staffadapter)
                        {
                            var staffRow = staffadapter.GetData().FirstOrDefault(staff => staff.staffID == id);
                            if (staffRow != null)
                            {
                                return(staffRow.firstName + " " + staffRow.lastName);
                            }
                        }
                    }
                }
                return(null);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #2
0
        public int GetStaffTypeByUsername(string userName)
        {
            var loginAdapter = new staff_credentialsTableAdapter();

            try
            {
                using (loginAdapter)
                {
                    var staffCredentialsRow =
                        loginAdapter.GetData().FirstOrDefault(login => login.username.Equals(userName));
                    if (staffCredentialsRow != null)
                    {
                        var id           = staffCredentialsRow.staff_staffID;
                        var staffadapter = new staffTableAdapter();
                        using (staffadapter)
                        {
                            var staffRow = staffadapter.GetData().FirstOrDefault(staff => staff.staffID == id);
                            if (staffRow != null)
                            {
                                return(staffRow.staffType);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(-1);
            }
            return(-1);
        }
Beispiel #3
0
        /// <summary>
        ///     Checks if the login is valid.
        /// </summary>
        /// <param name="userName">Username.</param>
        /// <param name="password">The password.</param>
        /// <returns>True if valid login, false otherwise</returns>
        public bool CheckLogin(string userName, string password)
        {
            var adapter = new staff_credentialsTableAdapter();

            try
            {
                using (adapter)
                {
                    var staffCredentialsRow = adapter.GetData().FirstOrDefault(login => login.username.Equals(userName));
                    if (staffCredentialsRow == null)
                    {
                        return(false);
                    }
                    var pword = staffCredentialsRow.password;
                    return(pword.Equals(password));
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }