示例#1
0
        public void DeleteBankClient()
        {
            BankClientDao bankManagerDAO = new BankClientDao();

            BankClientDto bankManagerDto = new BankClientDto()

            {
                FirstName = "Serik",

                LastName = "Shulembekov",

                Email = "*****@*****.**",

                CreatedTime = DateTime.Now,

                ApplicationClientType = ApplicationClientType.BankClient,

                EntityStatus = EntityStatusType.IsActive,

                PasswordHash = "123",
            };

            bankManagerDto.Id = ApplicationUserIdGenerator.GenerateUniqueId(

                bankManagerDto.FirstName, bankManagerDto.LastName,

                bankManagerDto.ApplicationClientType);

            bankManagerDAO.Create(bankManagerDto);

            bankManagerDAO.Remove(bankManagerDto.Id);

            Assert.IsNull(bankManagerDAO.Read(bankManagerDto.Id));
        }
        public void BankClientDao_Read()
        {
            BankClientDao dao    = new BankClientDao();
            var           result = dao.Read();

            foreach (var item in result)
            {
                Debug.WriteLine(item.ToString());
            }
        }
示例#3
0
        public void ReadBankClient()

        {
            BankClientDao bankManagerDAO = new BankClientDao();

            var res = bankManagerDAO.Read();

            foreach (var item in res)
            {
                Debug.WriteLine(item.ToString());
            }
        }
示例#4
0
        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);
        }