public UserProfile GetUserProfile(string userEmail) { UserProfile userProfile = new UserProfile(); Users user = new Users(); if (!string.IsNullOrEmpty(userEmail)) { using (var ctx = new SRLManagementEntities()) { user = ctx.Users.Where(u => u.Email == userEmail).FirstOrDefault(); } if (!string.IsNullOrEmpty(user.Email)) { userProfile.FirstName = user.FirstName; userProfile.LastName = user.LastName; userProfile.EmailAddress = user.Email; using (var ctx = new SRLManagementEntities()) { userProfile.Roles = ctx.sp_GetUserRoles(userEmail).Select(r => r.RoleName).ToList(); } } } return(userProfile); }
public List <Role> GetUserRoles(string userEmail) { List <Role> roles = new List <Role>(); using (var ctx = new SRLManagementEntities()) { roles = ctx.sp_GetUserRoles(userEmail).ToList().ToEntityRoleList(); } return(roles); }