public object Get() { try { var identity = User.Identity as ClaimsIdentity; String conn = identity.Claims.Where(n => n.Type == "conn").FirstOrDefault().Value; String uName = identity.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value; PORT.UserProfile userProfile = BL.Web.SEC.SEC_UserProvider.GetUserProfile(conn, uName); return(userProfile); } catch (Exception e) { return(e.ToString()); } }
public static PORT.UserProfile GetUserProfile(string connectionString, string userName) { PORT.UserProfile userProfile = new PORT.UserProfile(); using (UnitOfWork uow = new UnitOfWork()) { uow.ConnectionString = connectionString; uow.Connect(); //XPQuery<DAL.XPO.Datamodel.SEC_User> users = uow.Query<DAL.XPO.Datamodel.SEC_User>(); //userProfile = users.Where(u => u.Username == uName).Select(n => new Models.UserProfile { DisplayName = n.DisplayName, Avatar = n.PersonId.HRS_Employees1.FirstOrDefault(e => e.PersonId == n.PersonId).Photo, Online = true }).FirstOrDefault(); //return userProfile; XPCollection <DAL.Datamodel.SEC_User> users = new XPCollection <DAL.Datamodel.SEC_User>(uow); userProfile = users.Where(u => u.Username == userName).Select(n => new PORT.UserProfile { displayName = n.DisplayName, avatar = n.PersonId.HRS_Employees1.FirstOrDefault(e => e.PersonId == n.PersonId).Photo, online = true }).FirstOrDefault(); } return(userProfile); }