public IEnumerable <RegisteredUsers> GetRegisteredUsers() { using (OrganizationHierarchyContext context = new OrganizationHierarchyContext()) { return(context.RegisteredUsers.ToList()); } }
public List <RegisteredUsers> SetDefaultdata() { List <RegisteredUsers> result = new List <RegisteredUsers>(); List <RegisteredUsers> current = new List <RegisteredUsers>(); List <RegisteredUsers> next = new List <RegisteredUsers>(); OrganizationHierarchyContext db = new OrganizationHierarchyContext(); var username = GetUserName(); var root = db.RegisteredUsers.Where(x => x.EmployeeUsername.Contains("sudhag")).FirstOrDefault(); var root2 = db.RegisteredUsers.Where(x => x.EmployeeUsername.Contains("navg")).FirstOrDefault(); current.Add(root); current.Add(root2); var IsNextNull = false; while (!IsNextNull) { next = new List <RegisteredUsers>(); foreach (var item in current) { if (item.EmployeeUsername == username[0]) { IsNextNull = true; break; } foreach (var item2 in db.RegisteredUsers) { if (item2.ReportingManagerUsername == item.EmployeeUsername) { next.Add(item2); } } } if (next.Count == 0) { IsNextNull = true; } foreach (var item4 in current) { result.Add(item4); } current = new List <RegisteredUsers>(); foreach (var item3 in next) { current.Add(item3); } } result.Add(db.RegisteredUsers.Where(x => x.EmployeeUsername.Contains(username[0])).FirstOrDefault()); var mychildren = db.RegisteredUsers.Where(x => x.ReportingManagerUsername.Contains(username[0])).ToList(); foreach (var i in mychildren) { result.Add(i); } return(result); }
public IEnumerable <UserInformation> Getuser() { string profilepicPath = null; List <UserInformation> result = new List <UserInformation>(); foreach (var item in context.RegisteredUsers) { OrganizationHierarchyContext db = new OrganizationHierarchyContext(); string imreBase64Data = Convert.ToBase64String(item.Profilepic); profilepicPath = string.Format("data:image/png;base64,{0}", imreBase64Data); Console.WriteLine(item); UserInformation user = new UserInformation(); user.EmployeeId = item.EmployeeId; user.DisplayName = item.DisplayName; user.EmployeeUsername = item.EmployeeUsername; user.Email = item.Email; user.ProfilepicPath = profilepicPath; user.ReportingManagerUsername = item.ReportingManagerUsername; user.UserRegisteredOrNot = item.UserRegisteredOrNot; user.DepartmentName = db.DepartmentInformation.Where(x => x.DepartmentId.Equals(item.DepartmentId)).FirstOrDefault().DepartmentName; //item.Department.DepartmentName, user.Designation = db.DesignationInformation.Where(x => x.DesignationId.Equals(item.DesignationId)).FirstOrDefault().Designation; //item.Designation.Designation, user.Office = db.OfficeInformation.Where(x => x.OfficeId.Equals(item.OfficeId)).FirstOrDefault().OfficeName; //item.Office.OfficeName, result.Add(user); db.Dispose(); } return(result); }