Exemplo n.º 1
0
        public static List <UserGroups> GroupsGetAll(bool isTest = false)
        {
            List <UserGroups> groupList = new List <UserGroups>();

            try
            {
                ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest);

                DataTable  groupTable = sprocCalls.UserGroupsGetActive();
                UserGroups group;

                foreach (DataRow row in groupTable.Rows)
                {
                    group             = new UserGroups();
                    group.Active      = false;
                    group.GroupLevel  = Convert.ToInt32(row["GroupLevel"]);
                    group.GroupName   = row["GroupName"].ToString();
                    group.UserGroupID = Convert.ToInt32(row["UserGroupID"]);

                    groupList.Add(group);
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
            }

            return(groupList);
        }
Exemplo n.º 2
0
        public static List <UserInfo> GetAllUsers(bool isTest = false)
        {
            List <UserInfo> allUsers = new List <UserInfo>();

            try
            {
                ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest);
                DataTable   userTable  = sprocCalls.UserInfoGetAll();
                UserInfo    user;

                foreach (DataRow row in userTable.Rows)
                {
                    user              = new UserInfo();
                    user.UserInfoID   = Convert.ToInt32(row["UserInfoID"]);
                    user.UserName     = row["UserName"].ToString();
                    user.Email        = row["Email"].ToString();
                    user.ProfileImage = row["ProfileImage"].ToString();
                    user.GroupUsers   = GetGroupsByUserName(user.UserName, sprocCalls);

                    allUsers.Add(user);
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
            }

            return(allUsers);
        }
Exemplo n.º 3
0
        public static void UpdateUser(UserInfo user, out string errorMessage, bool isTest = false)
        {
            try
            {
                errorMessage = ValidateUser(user);

                if (string.IsNullOrEmpty(errorMessage))
                {
                    IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                    ISprocCalls      sprocCalls      = AppTools.InitSprocCalls(isTest);

                    if (membershipTools.UpdateUserEmail(user.UserName, user.Email) == false)
                    {
                        errorMessage = "Error updating email.";
                    }

                    if (sprocCalls.UserInfoUpdate(user) == false)
                    {
                        errorMessage = "Error saving user information";
                    }
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }
Exemplo n.º 4
0
        public static UserInfo GetUserByName(string userName, bool isTest = false)
        {
            ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest);

            UserInfo user = sprocCalls.UserInfoGetByUser(userName);

            if (user != null)
            {
                user.GroupUsers = GetGroupsByUserName(userName, sprocCalls);
            }

            return(user);
        }