當前位置: 首頁>>代碼示例>>C#>>正文


C# Models.User類代碼示例

本文整理匯總了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);
					}
				}
			}
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:32,代碼來源:UserSessionService.cs

示例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;
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:34,代碼來源:PrivateMessageService.cs

示例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));
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:7,代碼來源:LastReadServiceTests.cs

示例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);
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:7,代碼來源:UserService.cs

示例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());
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:7,代碼來源:SubscribedTopicsServiceTests.cs

示例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;
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:25,代碼來源:UserEdit.cs

示例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());
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:26,代碼來源:UserSessionServiceTests.cs

示例8: MarkAllForumsRead

		public void MarkAllForumsRead(User user)
		{
			if (user == null)
				throw new ArgumentNullException("user");
			_lastReadRepository.SetAllForumsRead(user.UserID, DateTime.UtcNow);
			_lastReadRepository.DeleteAllTopicReads(user.UserID);
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:7,代碼來源:LastReadService.cs

示例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);
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:26,代碼來源:PrivateMessageService.cs

示例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());
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:AwardCalculatorTests.cs

示例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());
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:SubscribedTopicsServiceTests.cs

示例12: GetForumReadStatus

		public DateTime? GetForumReadStatus(User user, Forum forum)
		{
			if (user != null)
			{
				return _lastReadRepository.GetLastReadTimesForForum(user.UserID, forum.ForumID);
			}
			return null;
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:LastReadService.cs

示例13: GetTopicReadStatus

		public DateTime? GetTopicReadStatus(User user, Topic topic)
		{
			if (user != null)
			{
				return _lastReadRepository.GetLastReadTimeForTopic(user.UserID, topic.TopicID);
			}
			return null;
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:LastReadService.cs

示例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);
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:LastReadService.cs

示例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());
		}
開發者ID:andyliyuze,項目名稱:POPForums,代碼行數:8,代碼來源:UserAwardServiceTests.cs


注:本文中的PopForums.Models.User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。