protected void DataBindUserGridView()
        {
            DAL.User loggedInUser = Utilities.Membership.GetCurrentLoggedInUser();
            string[] roles = Utilities.Membership.GetCurrentLoggedInUserRole();

            List<User> UserList = null;

            var isAdmin = (from r in roles
                           where r.Contains("Administrators")
                           select r);
            var isDeptHead = (from r in roles
                              where r.Contains("DepartmentHeads") || r.Contains("TemporaryDepartmentHeads")
                              select r);
            using (UserManager um = new UserManager())
                if (isAdmin.Count() > 0)
                {
                    UserList = um.GetAllUsers();
                }
                else if (isDeptHead.Count() > 0)
                {
                    UserList = um.FindUsersByCriteria(
                        new UserSearchDTO() { DepartmentID = loggedInUser.DepartmentID });
                }
                else
                {
                    UserList = um.FindUsersByCriteria(
                        new UserSearchDTO() { UserID = loggedInUser.UserID });
                }
            this.UserGridView.DataSource = UserList;
            this.UserGridView.DataBind();
        }
 protected void LoadUserGridView()
 {
     using (UserManager um = new UserManager())
     {
         List<User> users = um.FindUsersByCriteria(new UserSearchDTO());
         this.UserGridView.DataSource = users;
         this.UserGridView.DataBind();
     }
 }
        protected void DataBindUserGridView()
        {
            List<User> UserList = null;

            using (UserManager um = new UserManager())
                if (Utilities.Membership.IsAdmin)
                {
                    UserList = um.GetAllUsers();
                }
                else if (Utilities.Membership.IsDeptHead || Utilities.Membership.IsTempDeptHead)
                {
                    UserList = um.FindUsersByCriteria(
                        new UserSearchDTO() { DepartmentID = Utilities.Membership.LoggedInuser.DepartmentID });
                }
                else
                {
                    UserList = um.FindUsersByCriteria(
                        new UserSearchDTO() { UserID = Utilities.Membership.LoggedInuser.UserID });
                }
            this.UserGridView.DataSource = UserList;
            this.UserGridView.DataBind();
        }
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            // Create filter
            UserSearchDTO criteria = new UserSearchDTO();

            // set filter from ui controls
            criteria.FirstName = this.FirstNameTextBox.Text;
            criteria.LastName = this.LastNameTextBox.Text;
            using (UserManager um = new UserManager())
            {
                // get users by fileter
                List<User> users = um.FindUsersByCriteria(criteria);
                this.UserGridView.DataSource = users;
                this.UserGridView.DataBind();

            }
        }
 public static User GetCurrentLoggedInUser()
 {
     WebSecurity.MembershipUser membershipUser = WebSecurity.Membership.GetUser();
     if (membershipUser != null)
     {
         using (UserManager userManager = new UserManager())
         {
             List<User> users =
                 userManager.FindUsersByCriteria(
                     new UserSearchDTO() { UserName = membershipUser.UserName });
             if (users.Count > 0)
                 return users[0];
             else
             {
                 throw new Exceptions.UserException("No current logged in user.");
             }
         }
     }
     else
     {
         throw new Exceptions.UserException("No current logged in user.");
     }
 }
 public static List<DAL.User> FindUsersByCriteria(DAL.DTO.UserSearchDTO criteria)
 {
     using (BLL.UserManager um = new UserManager())
     {
         return um.FindUsersByCriteria(criteria);
     }
 }