Exemplo n.º 1
0
            public DuplicateVoteModel Create(IDataReader reader)
            {
                Guid   cookieId            = reader.GetGuid(reader.GetOrdinal("CookieId"));
                int    userIdField         = reader.GetOrdinal("UserId");
                int?   userId              = reader.IsDBNull(userIdField) ? (int?)null : reader.GetInt32(userIdField);
                int    emailAddressOrdinal = reader.GetOrdinal("EmailAddress");
                string emailAddress        = reader.IsDBNull(emailAddressOrdinal) ? null : reader.GetString(emailAddressOrdinal);

                int    sessionId    = reader.GetInt32(reader.GetOrdinal("SessionId"));
                string sessionTitle = reader.GetString(reader.GetOrdinal("SessionTitle"));

                int    speakerUserId = reader.GetInt32(reader.GetOrdinal("SpeakerUserId"));
                string speakerName   = reader.GetString(reader.GetOrdinal("SpeakerName"));

                int numberOfVotes = reader.GetInt32(reader.GetOrdinal("VoteCount"));

                bool   userIsUnknown = !userId.HasValue;
                string gravatar      = gravatarUrl.GetUrl(userIsUnknown ? cookieId.ToString() : emailAddress, useIdenticon: userIsUnknown);

                return(new DuplicateVoteModel
                {
                    CookieId = cookieId,
                    UserId = userId,
                    GravatarUrl = gravatar,
                    SessionId = sessionId,
                    SessionTitle = sessionTitle,
                    SpeakerUserId = speakerUserId,
                    SpeakerName = speakerName,
                    NumberOfVotes = numberOfVotes
                });
            }
Exemplo n.º 2
0
            public SessionVoterModel Create(IDataReader reader)
            {
                Guid   cookieId          = reader.GetGuid(reader.GetOrdinal("CookieId"));
                int    userNameField     = reader.GetOrdinal("Name");
                string userName          = reader.IsDBNull(userNameField) ? null : reader.GetString(userNameField);
                int    emailAddressField = reader.GetOrdinal("EmailAddress");
                string emailAddress      = reader.IsDBNull(emailAddressField) ? null : reader.GetString(emailAddressField);

                string userIdentifier = userName ?? cookieId.ToString();
                string gravatarUrl    = emailAddress == null
                                        ? gravatar.GetUrl(cookieId.ToString(), useIdenticon : true)
                                        : gravatar.GetUrl(emailAddress);

                return(new SessionVoterModel
                {
                    IsAnonymous = userName == null,
                    UserIdentifier = userIdentifier,
                    GravatarUrl = gravatarUrl
                });
            }
Exemplo n.º 3
0
            public AnonymousUserVoteCountModel Create(IDataReader reader)
            {
                Guid cookieId      = reader.GetGuid(reader.GetOrdinal("CookieId"));
                int  numberOfVotes = reader.GetInt32(reader.GetOrdinal("VoteCount"));

                return(new AnonymousUserVoteCountModel
                {
                    CookieId = cookieId,
                    GravatarUrl = gravatar.GetUrl(cookieId.ToString(), useIdenticon: true),
                    NumberOfVotes = numberOfVotes
                });
            }
Exemplo n.º 4
0
            public KnownUserVoteCountModel Create(IDataReader reader)
            {
                int    userId        = reader.GetInt32(reader.GetOrdinal("UserId"));
                string name          = reader.GetString(reader.GetOrdinal("Name"));
                string emailAddress  = reader.GetString(reader.GetOrdinal("EmailAddress"));
                string username      = reader.GetString(reader.GetOrdinal("UserName"));
                int    numberOfVotes = reader.GetInt32(reader.GetOrdinal("VoteCount"));

                return(new KnownUserVoteCountModel
                {
                    UserId = userId,
                    GravatarUrl = gravatar.GetUrl(emailAddress),
                    Name = string.IsNullOrWhiteSpace(name) ? username : name,
                    NumberOfVotes = numberOfVotes
                });
            }