Example #1
0
 void IUserSessionsRepository.CreateUserSessionEnd(UserSessionEnd sessionEnd)
 {
     using (var dc = CreateContext())
     {
         dc.UserLoginEntities.InsertOnSubmit(sessionEnd.Map());
         dc.SubmitChanges();
     }
 }
Example #2
0
        public void TestSession()
        {
            var userId = Guid.NewGuid();

            AssertActivities(_userSessionsQuery.GetUserActivity(userId));

            // Login.

            var          now       = DateTime.Now;
            var          sessionId = Guid.NewGuid().ToString();
            const string ipAddress = "123.456.123.456";
            var          login     = new UserLogin
            {
                UserId               = userId,
                SessionId            = sessionId,
                Time                 = now,
                IpAddress            = ipAddress,
                AuthenticationStatus = AuthenticationStatus.Authenticated
            };

            _userSessionsCommand.CreateUserLogin(login);

            AssertActivities(_userSessionsQuery.GetUserActivity(userId), login);

            // Logout.

            var logout = new UserLogout
            {
                UserId    = userId,
                SessionId = sessionId,
                Time      = now.AddMinutes(1),
                IpAddress = ipAddress,
            };

            _userSessionsCommand.CreateUserLogout(logout);

            AssertActivities(_userSessionsQuery.GetUserActivity(userId), login, logout);

            // End session.

            var sessionEnd = new UserSessionEnd
            {
                UserId    = userId,
                SessionId = sessionId,
                Time      = now.AddMinutes(2),
                IpAddress = ipAddress,
            };

            _userSessionsCommand.CreateUserSessionEnd(sessionEnd);

            AssertActivities(_userSessionsQuery.GetUserActivity(userId), login, logout, sessionEnd);
        }
Example #3
0
 public static UserLoginEntity Map(this UserSessionEnd sessionEnd)
 {
     return(sessionEnd.Map(ActivityType.SessionEnd));
 }
Example #4
0
 void IUserSessionsCommand.CreateUserSessionEnd(UserSessionEnd sessionEnd)
 {
     sessionEnd.Prepare();
     sessionEnd.Validate();
     _repository.CreateUserSessionEnd(sessionEnd);
 }