Ejemplo n.º 1
0
        /// <summary>
        /// Добавление пользователю группы по USER_ID пользователя
        /// и по ACCESSGROUP_ID группы
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="accessgroup_id"></param>
        /// <returns></returns>
        public void AddUserInAccessGroup(Int64 user_id, Int64 accessgroup_id)
        {
            using (SecurityDBEntities db = new SecurityDBEntities())
            {
                UsersInAccessGroups userinaccessgroup = new UsersInAccessGroups();
                userinaccessgroup.USER_ID = user_id;
                userinaccessgroup.ACCESSGROUP_ID = accessgroup_id;

                db.AddToUsersInAccessGroups(userinaccessgroup);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Добавление пользователю группы по логину пользователя
        /// и по ACCESSGROUP_ID группы
        /// </summary>
        /// <param name="user_login"></param>
        /// <param name="accessgroup_id"></param>
        /// <returns></returns>
        public void AddUserInAccessGroup(String user_login, Int64 accessgroup_id)
        {
            using (SecurityDBEntities db = new SecurityDBEntities())
            {
                long user_id = (from u in db.Users where (u.LOGIN == user_login) select u.USER_ID).First();

                UsersInAccessGroups userinaccessgroup = new UsersInAccessGroups();
                userinaccessgroup.USER_ID = user_id;
                userinaccessgroup.ACCESSGROUP_ID = accessgroup_id;

                db.AddToUsersInAccessGroups(userinaccessgroup);
                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public MembershipUser CreateUser(string first_name, string last_name, string username, string password, string email)
        {
            using (SecurityDBEntities db = new SecurityDBEntities())
            {
                Users user = new Users();
                user.LOGIN = username;
                user.FIRST_NAME = first_name;
                user.LAST_NAME = last_name;
                user.EMAIL = email;
                user.PASSWORD_SALT = CreateSalt();
                user.PASSWORD = CreatePasswordHash(password,user.PASSWORD_SALT);
                user.CREATE_DATE = DateTime.Now;
                user.IS_ACTIVATED = false;
                user.IS_LOCKED_OUT = false;
                user.LAST_LOCKED_OUT_DATE = DateTime.Now;
                user.LAST_LOGIN_DATE = DateTime.Now;

                db.AddToUsers(user);
                db.SaveChanges();

                return GetUser(username);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Удаление у пользователю группы.
        /// </summary>
        /// <param name="uiag_id"></param>
        /// <returns></returns>
        public bool RemoveUserInAccessGroup(Int64 uiag_id)
        {
            try
            {

                using (SecurityDBEntities db = new SecurityDBEntities())
                {
                    UsersInAccessGroups deluaig = (from a in db.UsersInAccessGroups where (a.UIAG_ID == uiag_id) select a).First();
                    db.UsersInAccessGroups.DeleteObject(deluaig);
                    db.SaveChanges();

                    return true;
                }
            }
            catch (Exception ex)
            {
                return false; // Ошибка пои удалении
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Удаление пользователя по USER_ID
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public bool DeleteUser(Int64 user_id)
        {
            try
            {

                using (SecurityDBEntities db = new SecurityDBEntities())
                {
                    Users del_user = (from a in db.Users where (a.USER_ID == user_id) select a).First();
                    db.Users.DeleteObject(del_user);
                    db.SaveChanges();

                    return true;
                }
            }
            catch (Exception ex)
            {
                return false; // Ошибка при удалении
            }
        }