public UserInfoViewModel GetUserInfo() { var user = UserManager.FindById(User.Identity.GetUserId <int>()); if (user == null) { return(null); } var rolemanager = new EformRoleManager(new EformRoleStore(BaseDbContext.Create())); var roleId = user.Roles.FirstOrDefault()?.RoleId; string role = null; if (roleId != null) { role = rolemanager.FindById((int)roleId)?.Name; } return(new UserInfoViewModel { Email = user.Email, Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Role = role }); }