public List<iMentorUserInfo> GetUsersByListing(string data) { using (iMAST_dbEntities db = new iMAST_dbEntities()) { var users = new List<iMentorUserInfo>(); if (data != null) { var userIds = new List<int>(); int id = Convert.ToInt32(data); if (id > 0) { var listing = db.ListingModels.Where(x => x.Id == id).FirstOrDefault(); var assignments = db.AssignedListings.Where(x => x.ListingId == listing.Id).ToList(); foreach (AssignedListing assignment in assignments) { var user = db.iMentorUsers.Where(x => x.Id == assignment.UserId).FirstOrDefault(); var u = new iMentorUserInfo(); u.Id = user.Id; u.UrlId = user.UrlId; u.UserName = user.UserName; u.FirstName = user.FirstName; u.LastName = user.LastName; u.Email = user.Email; u.RoleId = u.GetRoleIdByUser(user); u.Role = u.GetRoleName(user); u.ShowOnlyAssignedListings = user.ShowOnlyAssignedListings; u.IconIndex = user.IconIndex; users.Add(u); } } } return users; } }
public List<iMentorUserInfo> GetAllUsers() { using (iMAST_dbEntities db = new iMAST_dbEntities()) { var iMentorUsers = db.iMentorUsers.ToList(); List<iMentorUserInfo> users = new List<iMentorUserInfo>(); foreach (iMentorUser user in iMentorUsers) { var u = new iMentorUserInfo(); u.Id = user.Id; u.UrlId = user.UrlId; u.UserName = user.UserName; u.FirstName = user.FirstName; u.LastName = user.LastName; u.Email = user.Email; u.RoleId = u.GetRoleIdByUser(user); u.Role = u.GetRoleName(user); u.ShowOnlyAssignedListings = user.ShowOnlyAssignedListings; u.IconIndex = user.IconIndex; users.Add(u); } return users; } }
public iMentorUserInfo GetCurrentUser(string userName) { var currentUserName = userName; var user = new iMentorUserInfo(); if (!currentUserName.Equals("")) { using (iMAST_dbEntities db = new iMAST_dbEntities()) { var iMentorUser = db.iMentorUsers.Where(x => x.UserName.Equals(currentUserName)).FirstOrDefault(); if (iMentorUser != null) { user.Id = iMentorUser.Id; user.UrlId = iMentorUser.UrlId; user.UserName = iMentorUser.UserName; user.FirstName = iMentorUser.FirstName; user.LastName = iMentorUser.LastName; user.Email = iMentorUser.Email; user.RoleId = user.GetRoleIdByUser(iMentorUser); user.Role = user.GetRoleName(iMentorUser); user.ShowOnlyAssignedListings = iMentorUser.ShowOnlyAssignedListings; user.IconIndex = iMentorUser.IconIndex; } } } return user; }