public static string GetLastLoggedInText(Member member, DateTime?ifLaterThan) { if (member == null) { throw new ArgumentNullException("member"); } DateTime?lastLogin; try { lastLogin = _userSessionsQuery.GetLastLoginTime(member.Id); } catch (Exception ex) { // This is slow and could time out - don't fail completely. ExceptionManager.HandleException(ex, new StandardErrorHandler()); return(""); } if (lastLogin == null || (ifLaterThan != null && lastLogin.Value.Date <= ifLaterThan.Value.Date)) { return(""); } return("Last visited LinkMe on " + lastLogin.Value.ToString(Constants.DATE_FORMAT)); }
public void TestLastLogin() { var userId = Guid.NewGuid(); Assert.IsNull(_userSessionsQuery.GetLastLoginTime(userId)); // Admin login is not a real login. _userSessionsCommand.CreateUserLogin(new UserLogin { UserId = userId, AuthenticationStatus = AuthenticationStatus.AuthenticatedWithOverridePassword }); Assert.IsNull(_userSessionsQuery.GetLastLoginTime(userId)); _userSessionsCommand.CreateUserLogin(new UserLogin { UserId = userId, AuthenticationStatus = AuthenticationStatus.Authenticated }); Assert.IsNotNull(_userSessionsQuery.GetLastLoginTime(userId)); }
private ViewCandidateModel GetCurrentCandidate(Guid?currentCandidateId, EmployerMemberView view) { var currentCandidate = new ViewCandidateModel { View = view, LastLoginTime = currentCandidateId == null ? null : _userSessionsQuery.GetLastLoginTime(currentCandidateId.Value), CurrentSearch = EmployerContext.CurrentSearch, }; if (currentCandidateId.HasValue && EmployerContext.CurrentCandidates is ManageCandidatesNavigation) { var jobAdId = ((ManageCandidatesNavigation)EmployerContext.CurrentCandidates).JobAdId; currentCandidate.CurrentApplication = _jobAdApplicantsQuery.GetApplication(currentCandidateId.Value, jobAdId); currentCandidate.ApplicantStatus = currentCandidate.CurrentApplication == null ? (ApplicantStatus?)null : _jobAdApplicantsQuery.GetApplicantStatus(currentCandidate.CurrentApplication.Id); } return(currentCandidate); }