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
        /// <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); // Ошибка пои удалении
            }
        }