public void insertUsers(User user) { using (var context = new ManageUsersEntities()) { context.Users.Add(user); context.SaveChanges(); } }
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); }
public void deleteUsersToRole(List <ApplicationUserRolesObj> lstObj) { using (var context = new ManageUsersEntities()) { foreach (ApplicationUserRolesObj item in lstObj) { context.ApplicationUserRoles_DeleteItem(item.UserId, item.RoleId); } } }
public List <User> getAllUsers() { List <User> userList; using (var context = new ManageUsersEntities()) { userList = (from s in context.Users select s).ToList(); } return(userList); }
public List <MenuItemFunction> getAllMenu() { List <MenuItemFunction> menuList; using (var context = new ManageUsersEntities()) { menuList = (from s in context.MenuItemFunctions select s).ToList(); } return(menuList); }
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); }
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(); } }
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(); } }
public List <Role> getAllRoles() { List <Role> roleList; using (var context = new ManageUsersEntities()) { roleList = (from s in context.Roles select s).ToList(); } return(roleList); }
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); }
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(); } }
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(); } }
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); } } }
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(); } }
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); }
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); }
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); }
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(); } }
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); }
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>()); }
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); }
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(); } }