本文整理汇总了C#中PopForums.Models.User类的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于PopForums.Models命名空间,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessUserRequest
public void ProcessUserRequest(User user, HttpContextBase context)
{
if (context.Response.IsRequestBeingRedirected)
return;
int? userID = null;
if (user != null)
userID = user.UserID;
if (context.Request.Cookies[_sessionIDCookieName] == null)
{
StartNewSession(context, userID);
if (user != null)
_userRepository.UpdateLastActivityDate(user, DateTime.UtcNow);
}
else
{
var sessionID = Convert.ToInt32(context.Request.Cookies[_sessionIDCookieName].Value);
if (user != null)
_userRepository.UpdateLastActivityDate(user, DateTime.UtcNow);
var updateSuccess = _userSessionRepository.UpdateSession(sessionID, DateTime.UtcNow);
if (!updateSuccess)
StartNewSession(context, userID);
else
{
var isAnon = _userSessionRepository.IsSessionAnonymous(sessionID);
if (userID.HasValue && isAnon || !userID.HasValue && !isAnon)
{
EndAndDeleteSession(new ExpiredUserSession { UserID = null, SessionID = sessionID, LastTime = DateTime.UtcNow });
StartNewSession(context, userID);
}
}
}
}
示例2: Create
public PrivateMessage Create(string subject, string fullText, User user, List<User> toUsers)
{
if (String.IsNullOrWhiteSpace(subject))
throw new ArgumentNullException("subject");
if (String.IsNullOrWhiteSpace(fullText))
throw new ArgumentNullException("fullText");
if (user == null)
throw new ArgumentNullException("user");
if (toUsers == null || toUsers.Count == 0)
throw new ArgumentException("toUsers must include at least one user.", "toUsers");
var names = user.Name;
foreach (var toUser in toUsers)
names += ", " + toUser.Name;
var now = DateTime.UtcNow;
var pm = new PrivateMessage
{
Subject = TextParsingService.EscapeHtmlAndCensor(subject),
UserNames = names,
LastPostTime = now
};
pm.PMID = PrivateMessageRepository.CreatePrivateMessage(pm);
PrivateMessageRepository.AddUsers(pm.PMID, new List<int> {user.UserID}, now, true);
PrivateMessageRepository.AddUsers(pm.PMID, toUsers.Select(u => u.UserID).ToList(), now.AddSeconds(-1), false);
var post = new PrivateMessagePost
{
FullText = TextParsingService.ForumCodeToHtml(fullText),
Name = user.Name,
PMID = pm.PMID,
PostTime = now,
UserID = user.UserID
};
PrivateMessageRepository.AddPost(post);
return pm;
}
示例3: MarkAllForumReadSetsReadTimes
public void MarkAllForumReadSetsReadTimes()
{
var service = GetService();
var user = new User(456, DateTime.MinValue);
service.MarkAllForumsRead(user);
_lastReadRepo.Verify(l => l.SetAllForumsRead(user.UserID, It.IsAny<DateTime>()), Times.Exactly(1));
}
示例4: SetPassword
public void SetPassword(User targetUser, string password, string ip, User user)
{
var salt = Guid.NewGuid();
var hashedPassword = password.GetMD5Hash(salt);
_userRepository.SetHashedPassword(targetUser, hashedPassword, salt);
_securityLogService.CreateLogEntry(user, targetUser, ip, String.Empty, SecurityLogType.PasswordChange);
}
示例5: TryRemoveSubTopicNullTopic
public void TryRemoveSubTopicNullTopic()
{
var service = GetService();
var user = new User(123, DateTime.MaxValue);
service.TryRemoveSubscribedTopic(user, null);
_mockSubRepo.Verify(s => s.RemoveSubscribedTopic(It.IsAny<int>(), It.IsAny<int>()), Times.Never());
}
示例6: UserEdit
public UserEdit(User user, Profile profile)
{
UserID = user.UserID;
Name = user.Name;
Email = user.Email;
IsApproved = user.IsApproved;
IsSubscribed = profile.IsSubscribed;
Signature = profile.Signature;
ShowDetails = profile.ShowDetails;
Location = profile.Location;
IsPlainText = profile.IsPlainText;
Dob = profile.Dob;
Web = profile.Web;
Aim = profile.Aim;
Icq = profile.Icq;
YahooMessenger = profile.YahooMessenger;
Facebook = profile.Facebook;
Twitter = profile.Twitter;
TimeZone = profile.TimeZone;
IsDaylightSaving = profile.IsDaylightSaving;
HideVanity = profile.HideVanity;
Roles = user.Roles.ToArray();
AvatarID = profile.AvatarID;
ImageID = profile.ImageID;
}
示例7: UserWithAnonCookieStartsLoggedInSession
public void UserWithAnonCookieStartsLoggedInSession()
{
var user = new User(123, DateTime.MinValue);
var service = GetService();
const int sessionID = 5467;
var requestCookies = new HttpCookieCollection { new HttpCookie("pf_sessionID", sessionID.ToString()) };
_contextHelper.MockRequest.Setup(r => r.Cookies).Returns(requestCookies);
_mockUserSessionRepo.Setup(u => u.UpdateSession(sessionID, It.IsAny<DateTime>())).Returns(true);
_mockUserSessionRepo.Setup(u => u.IsSessionAnonymous(sessionID)).Returns(true);
var responseCookies = new HttpCookieCollection();
_contextHelper.MockResponse.Setup(r => r.Cookies).Returns(responseCookies);
service.ProcessUserRequest(user, _contextHelper.MockContext.Object);
_mockUserSessionRepo.Verify(u => u.UpdateSession(sessionID, It.IsAny<DateTime>()), Times.Once());
_mockUserRepo.Verify(u => u.UpdateLastActivityDate(user, It.IsAny<DateTime>()), Times.Once());
_mockUserSessionRepo.Verify(u => u.DeleteSessions(null, sessionID), Times.Once());
_mockSecurityLogService.Verify(s => s.CreateLogEntry(null, null, String.Empty, sessionID.ToString(), SecurityLogType.UserSessionEnd, It.IsAny<DateTime>()), Times.Once());
Assert.AreEqual(1, responseCookies.Count);
var cookie = responseCookies[0];
int newSessionID;
Assert.True(int.TryParse(cookie.Value, out newSessionID));
Assert.AreEqual("pf_sessionID", cookie.Name);
_mockUserSessionRepo.Verify(u => u.CreateSession(It.IsAny<int>(), user.UserID, It.IsAny<DateTime>()), Times.Once());
_mockSecurityLogService.Verify(s => s.CreateLogEntry(null, user.UserID, It.IsAny<string>(), It.IsAny<string>(), SecurityLogType.UserSessionStart), Times.Once());
}
示例8: MarkAllForumsRead
public void MarkAllForumsRead(User user)
{
if (user == null)
throw new ArgumentNullException("user");
_lastReadRepository.SetAllForumsRead(user.UserID, DateTime.UtcNow);
_lastReadRepository.DeleteAllTopicReads(user.UserID);
}
示例9: Reply
public void Reply(PrivateMessage pm, string fullText, User user)
{
if (pm == null || pm.PMID == 0)
throw new ArgumentException("Can't reply to a PM that hasn't been persisted.", "pm");
if (String.IsNullOrWhiteSpace(fullText))
throw new ArgumentNullException("fullText");
if (user == null)
throw new ArgumentNullException("user");
if (!IsUserInPM(user, pm))
throw new Exception("Can't add a PM reply for a user not part of the PM.");
var post = new PrivateMessagePost
{
FullText = TextParsingService.ForumCodeToHtml(fullText),
Name = user.Name,
PMID = pm.PMID,
PostTime = DateTime.UtcNow,
UserID = user.UserID
};
PrivateMessageRepository.AddPost(post);
var users = PrivateMessageRepository.GetUsers(pm.PMID);
foreach (var u in users)
PrivateMessageRepository.SetArchive(pm.PMID, u.UserID, false);
var now = DateTime.UtcNow;
PrivateMessageRepository.UpdateLastPostTime(pm.PMID, now);
PrivateMessageRepository.SetLastViewTime(pm.PMID, user.UserID, now);
}
示例10: EnqueueDoesWhatItSaysItShould
public void EnqueueDoesWhatItSaysItShould()
{
var calc = GetCalc();
var user = new User(1, DateTime.MinValue);
var eventDef = new EventDefinition {EventDefinitionID = "blah"};
calc.QueueCalculation(user, eventDef);
_awardCalcRepo.Verify(x => x.Enqueue(eventDef.EventDefinitionID, user.UserID), Times.Once());
}
示例11: TryRemoveSubTopic
public void TryRemoveSubTopic()
{
var service = GetService();
var user = new User(123, DateTime.MaxValue);
var topic = new Topic(456);
service.TryRemoveSubscribedTopic(user, topic);
_mockSubRepo.Verify(s => s.RemoveSubscribedTopic(user.UserID, topic.TopicID), Times.Once());
}
示例12: GetForumReadStatus
public DateTime? GetForumReadStatus(User user, Forum forum)
{
if (user != null)
{
return _lastReadRepository.GetLastReadTimesForForum(user.UserID, forum.ForumID);
}
return null;
}
示例13: GetTopicReadStatus
public DateTime? GetTopicReadStatus(User user, Topic topic)
{
if (user != null)
{
return _lastReadRepository.GetLastReadTimeForTopic(user.UserID, topic.TopicID);
}
return null;
}
示例14: MarkTopicRead
public void MarkTopicRead(User user, Topic topic)
{
if (user == null)
throw new ArgumentNullException("user");
if (topic == null)
throw new ArgumentNullException("topic");
_lastReadRepository.SetTopicRead(user.UserID, topic.TopicID, DateTime.UtcNow);
}
示例15: IssueMapsFieldsToRepoCall
public void IssueMapsFieldsToRepoCall()
{
var user = new User(123, DateTime.MinValue);
var awardDef = new AwardDefinition {AwardDefinitionID = "blah", Description = "desc", Title = "title", IsSingleTimeAward = true};
var service = GetService();
service.IssueAward(user, awardDef);
_userAwardRepo.Verify(x => x.IssueAward(user.UserID, awardDef.AwardDefinitionID, awardDef.Title, awardDef.Description, It.IsAny<DateTime>()), Times.Once());
}