Exemplo n.º 1
0
 private static UserModel CreateUserModel(UserProfile profile)
 {
     return new UserModel
         {
             UserId = profile.UserId,
             UserName = profile.UserName,
             Name = profile.Name,
             EmailAddress = profile.EmailAddress,
             MobilePhone = profile.MobilePhone,
             WebsiteUrl = profile.WebsiteUrl,
             TwitterHandle = profile.TwitterHandle,
             Bio = profile.Bio,
             NewSpeaker = profile.NewSpeaker,
             GravatarUrl = profile.GravatarUrl()
         };
 }
        private SessionDisplayModel CreateDisplayModel(Session session, UserProfile profile)
        {
            var isUsersSession = Request.IsAuthenticated && session.SpeakerUserName == User.Identity.Name;
            var tweetLink = CreateTweetLink(isUsersSession, session.Title,
                                            Url.Action("Details", "Session", new { id = session.SessionId },
                                                       Request.Url.Scheme));

            var displayModel = new SessionDisplayModel
                {
                    SessionId = session.SessionId,
                    SessionTitle = session.Title,
                    SessionAbstract = session.Abstract,
                    SpeakerId = profile.UserId,
                    SpeakerName = profile.Name,
                    SpeakerUserName = session.SpeakerUserName,
                    SpeakerGravatarUrl = profile.GravatarUrl(),
                    TweetLink = tweetLink,
                    IsUsersSession = isUsersSession
                };
            return displayModel;
        }
        private SpeakerDisplayModel CreateDisplayModel(UserProfile userProfile, IEnumerable<Session> sessions)
        {
            var isCurrentUser = Request.IsAuthenticated && userProfile.UserName == User.Identity.Name;
            var userSessions = sessions.ToDictionary(s => s.SessionId, s => s.Title);

            return new SpeakerDisplayModel
                {
                    IsCurrentUser = isCurrentUser,
                    Name = userProfile.Name,
                    Bio = userProfile.Bio,
                    GravatarUrl = userProfile.GravatarUrl(),
                    TwitterHandle = userProfile.TwitterHandle,
                    WebsiteUrl = userProfile.WebsiteUrl,
                    Sessions = userSessions
                };
        }