public void CurrentSessionDao_Read() { CurrentSessionDao dao = new CurrentSessionDao(); var result = dao.Read(); foreach (var item in result) { Debug.WriteLine(item.ToString()); } }
public bool SignInToApplication(string email, string password) { string userId = ""; CurrentSessionDto sessionToWorkWith = null; List <BankClientDto> allUsers = _bankClientDao.Read() .ToList(); List <CurrentSessionDto> allSessions = _currentSessionsDao.Read() .ToList(); foreach (var item in allUsers) { if (item.Email == email && PasswordHashGenerator.GetMd5Hash(password) == item.PasswordHash) { userId = item.Id; break; } } foreach (var item in allSessions) { if (item.UserId == userId) { sessionToWorkWith = item; break; } } if (sessionToWorkWith == null) { _currentSessionsDao.Create(new CurrentSessionDto() { LastOperationTime = DateTime.Now, UserId = userId, Id = Guid.NewGuid().ToString() }); return(true); } if ((DateTime.Now - sessionToWorkWith.LastOperationTime).TotalMinutes > 60D) { _currentSessionsDao.Remove(sessionToWorkWith.Id); _currentSessionsDao.Create(new CurrentSessionDto() { LastOperationTime = DateTime.Now, UserId = userId, Id = Guid.NewGuid().ToString() }); return(true); } return(false); }
public void CurrentSessionDao_Delete() { CurrentSessionDto dto = new CurrentSessionDto() { Id = Guid.NewGuid().ToString(), UserId = "1111", LastOperationTime = DateTime.Now, SignInTime = DateTime.Now, EntityStatus = EntityStatusType.IsActive, CreatedTime = DateTime.Now, }; CurrentSessionDao dao = new CurrentSessionDao(); dao.Create(dto); dao.Remove(dto.Id); Assert.IsNull(dao.Read(dto.Id)); }