コード例 #1
0
 public void insertUsers(User user)
 {
     using (var context = new ManageUsersEntities())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
コード例 #2
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public Role getRolesByName(String roleName)
        {
            Role role;

            using (var context = new ManageUsersEntities())
            {
                role = (from s in context.Roles where s.Name == roleName select s).FirstOrDefault();
            }
            return(role);
        }
コード例 #3
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
 public void deleteUsersToRole(List <ApplicationUserRolesObj> lstObj)
 {
     using (var context = new ManageUsersEntities())
     {
         foreach (ApplicationUserRolesObj item in lstObj)
         {
             context.ApplicationUserRoles_DeleteItem(item.UserId, item.RoleId);
         }
     }
 }
コード例 #4
0
        public List <User> getAllUsers()
        {
            List <User> userList;

            using (var context = new ManageUsersEntities())
            {
                userList = (from s in context.Users select s).ToList();
            }
            return(userList);
        }
コード例 #5
0
        public List <MenuItemFunction> getAllMenu()
        {
            List <MenuItemFunction> menuList;

            using (var context = new ManageUsersEntities())
            {
                menuList = (from s in context.MenuItemFunctions select s).ToList();
            }
            return(menuList);
        }
コード例 #6
0
        public List <Users_SelectUsersNoRole_Result> SelectUsersNoRole(Int32 idRoles)
        {
            List <Users_SelectUsersNoRole_Result> userList;

            using (var context = new ManageUsersEntities())
            {
                userList = context.Users_SelectUsersNoRole(idRoles).ToList <Users_SelectUsersNoRole_Result>();
            }
            return(userList);
        }
コード例 #7
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public void deleteRoles(Int32 IDrole)
        {
            using (var context = new ManageUsersEntities())
            {
                Role roleItem = (from s in context.Roles where s.Id == IDrole select s).Single();
                context.Roles.Remove(roleItem);

                context.SaveChanges();
            }
        }
コード例 #8
0
        public void deleteUsers(Int64 Iduser)
        {
            using (var context = new ManageUsersEntities())
            {
                User user = (from s in context.Users where s.Id == Iduser select s).Single();
                context.Users.Remove(user);

                context.SaveChanges();
            }
        }
コード例 #9
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public List <Role> getAllRoles()
        {
            List <Role> roleList;

            using (var context = new ManageUsersEntities())
            {
                roleList = (from s in context.Roles select s).ToList();
            }
            return(roleList);
        }
コード例 #10
0
        public List <User> getUsersByIdLogInLike(String idLogin)
        {
            List <User> userList;

            using (var context = new ManageUsersEntities())
            {
                userList = (from s in context.Users where s.Id_Login.Contains(idLogin) select s).ToList();
            }
            return(userList);
        }
コード例 #11
0
        public void updateUserPassword(String idLogIn, String password)
        {
            using (var context = new ManageUsersEntities())
            {
                User user = (from s in context.Users where s.Id_Login == idLogIn select s).Single();
                user.Password = password;

                context.SaveChanges();
            }
        }
コード例 #12
0
        public void updateUserLock(Int32 Iduser)
        {
            using (var context = new ManageUsersEntities())
            {
                User user = (from s in context.Users where s.Id == Iduser select s).Single();
                user.LockoutEnabled = !user.LockoutEnabled;

                context.SaveChanges();
            }
        }
コード例 #13
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
 public void insertMenuItemRoles(List <MenuItemFunction> lstMenu, Int32 IDrole)
 {
     using (var context = new ManageUsersEntities())
     {
         context.MenuItemRoles_DeleteByRoleID(IDrole);
         foreach (MenuItemFunction item in lstMenu)
         {
             context.MenuItemRoles_InsertItem(item.Item_ID, IDrole);
         }
     }
 }
コード例 #14
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public void updateRoles(Int32 IDrole, String Name, String moTa)
        {
            using (var context = new ManageUsersEntities())
            {
                Role roleItem = (from s in context.Roles where s.Id == IDrole select s).Single();
                roleItem.Name        = Name;
                roleItem.Description = moTa;

                context.SaveChanges();
            }
        }
コード例 #15
0
        public User getUsersByIDLogin(String IdLogIn)
        {
            User user;

            using (var context = new ManageUsersEntities())
            {
                IdLogIn = IdLogIn.Trim();
                user    = (from s in context.Users where s.Id_Login == IdLogIn select s).FirstOrDefault();
            }
            return(user);
        }
コード例 #16
0
        public User getUsersByID(Int64 Iduser)
        {
            User user;

            using (var context = new ManageUsersEntities())
            {
                user = (from s in context.Users where s.Id == Iduser select s).FirstOrDefault();
                var a = user.Roles;
            }
            return(user);
        }
コード例 #17
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public Role getListUserofRole(Int32 Idrole)
        {
            Role role;

            using (var context = new ManageUsersEntities())
            {
                role = (from s in context.Roles where s.Id == Idrole select s).FirstOrDefault();
                var a = role.Users;
            }
            return(role);
        }
コード例 #18
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
 public void insertRoles(String Name, String moTa)
 {
     using (var context = new ManageUsersEntities())
     {
         Role itemRole = new Role();
         itemRole.Name        = Name;
         itemRole.Description = moTa;
         itemRole.DateCreate  = DateTime.Now;
         context.Roles.Add(itemRole);
         context.SaveChanges();
     }
 }
コード例 #19
0
ファイル: RolesDH.cs プロジェクト: bodoi304/ReportFinance
        public Role getRolesByID(Int32 Idrole)
        {
            Role role;

            using (var context = new ManageUsersEntities())
            {
                role = (from s in context.Roles where s.Id == Idrole select s).FirstOrDefault();
                var a = role.MenuItemFunctions;
                var b = role.Users;
            }
            return(role);
        }
コード例 #20
0
        public List <MenuItemFunction> getMenuItem(User user)
        {
            List <MenuItemFunction> lstAll = new List <MenuItemFunction>();

            using (var context = new ManageUsersEntities())
            {
                foreach (Role item in user.Roles)
                {
                    lstAll.AddRange(item.MenuItemFunctions);
                }
            }
            return(lstAll.Distinct <MenuItemFunction>().ToList <MenuItemFunction>());
        }
コード例 #21
0
        public User validateLogin(String IdLogIn, String passWord)
        {
            User user;

            using (var context = new ManageUsersEntities())
            {
                user = (from s in context.Users where s.Id_Login == IdLogIn && s.Password == passWord select s).FirstOrDefault();
                if (user == null)
                {
                    return(null);
                }
                var a = user.Roles;
                foreach (Role item in user.Roles)
                {
                    var b = item.MenuItemFunctions;
                }
            }
            return(user);
        }
コード例 #22
0
        public void updateUsers(Int64 Iduser, User user)
        {
            using (var context = new ManageUsersEntities())
            {
                User userDb = (from s in context.Users where s.Id == Iduser select s).Single();
                userDb.Id_Login    = user.Id_Login;
                userDb.Email       = user.Email;
                userDb.PhoneNumber = user.PhoneNumber;
                userDb.UserName    = user.UserName;
                userDb.Department  = user.Department;
                userDb.Position    = user.Position;
                if (!String.IsNullOrEmpty(user.Password))
                {
                    userDb.Password = Utils.Encrypt(user.Password);
                }

                context.SaveChanges();
            }
        }