public static List <DTOUser> SuperUsers(string DefaultConnection) { List <DTOUser> response = new List <DTOUser>(); var optionsBuilder = new DbContextOptionsBuilder <ADefHelpDeskContext>(); optionsBuilder.UseSqlServer(DefaultConnection); using (var context = new ADefHelpDeskContext(optionsBuilder.Options)) { // Get the SuperUsers var colUsers = (from user in context.AdefHelpDeskUsers where user.IsSuperUser == true select user); foreach (var item in colUsers) { DTOUser objDTOUser = new DTOUser(); objDTOUser.userId = item.UserId; objDTOUser.userName = item.Username; objDTOUser.firstName = item.FirstName; objDTOUser.lastName = item.LastName; objDTOUser.email = item.Email; objDTOUser.isSuperUser = item.IsSuperUser; response.Add(objDTOUser); } } return(response); }
public static DTOUser UserFromUserId(int paramUser, string DefaultConnection) { DTOUser response = new DTOUser(); var optionsBuilder = new DbContextOptionsBuilder <ADefHelpDeskContext>(); optionsBuilder.UseSqlServer(DefaultConnection); using (var context = new ADefHelpDeskContext(optionsBuilder.Options)) { // Get the user var objUser = (from user in context.AdefHelpDeskUsers where user.UserId == paramUser select user).FirstOrDefault(); if (objUser != null) { response.userId = objUser.UserId; response.userName = objUser.Username; response.email = objUser.Email; response.firstName = objUser.FirstName; response.lastName = objUser.LastName; response.isSuperUser = objUser.IsSuperUser; response.riapassword = objUser.Riapassword; } } return(response); }
public static List <DTOUser> UsersForRoleId(int paramRoleID, string DefaultConnection) { List <DTOUser> response = new List <DTOUser>(); var optionsBuilder = new DbContextOptionsBuilder <ADefHelpDeskContext>(); optionsBuilder.UseSqlServer(DefaultConnection); using (var context = new ADefHelpDeskContext(optionsBuilder.Options)) { // Get Users for Role var colUsers = (from user in context.AdefHelpDeskUsers from UserRoles in context.AdefHelpDeskUserRoles where UserRoles.User == user where UserRoles.RoleId == paramRoleID select user); foreach (var item in colUsers) { DTOUser objDTOUser = new DTOUser(); objDTOUser.userId = item.UserId; objDTOUser.userName = item.Username; objDTOUser.firstName = item.FirstName; objDTOUser.lastName = item.LastName; objDTOUser.email = item.Email; objDTOUser.isSuperUser = item.IsSuperUser; response.Add(objDTOUser); } } return(response); }