예제 #1
0
 private void  SaveCodeToDB(string email, int kod, DateTime kodGenerateDate)
 {
     try
     {
         EmailChacingDal e = new EmailChacingDal();
         EmailChecking   k = new EmailChecking();
         k.Email           = email;
         k.Kod             = kod;
         k.KodGenerateDate = kodGenerateDate;
         e.Insert(k);
     }
     catch (Exception exp)
     {
         logger.Error(exp, "Insert Department");
         throw;
     }
 }
예제 #2
0
        public int Insert(EmailChecking emailChaching)
        {
            try
            {
                var parameters = new List <SqlParameter>();
                parameters.Add(sqlHelper.CreateParameter("@Email", 150, emailChaching.Email, DbType.String));

                parameters.Add(sqlHelper.CreateParameter("@Kod", emailChaching.Kod, DbType.Int32));

                parameters.Add(sqlHelper.CreateParameter("@KodGenerateDate", emailChaching.KodGenerateDate, DbType.DateTime));
                int lastId = 0;

                sqlHelper.Insert("INSERT INTO EmailChacking(Email,Kod,KodGenerateDate) VALUES (@Email,@Kod,@KodGenerateDate)",
                                 CommandType.Text, parameters.ToArray(), out lastId);

                return(lastId);
            }
            catch (Exception exp)
            {
                logger.Error(exp, "EmailChacking");
                throw;
            }
        }
예제 #3
0
        public bool GetByCode(int Code, string Email)
        {
            bool netice     = false;
            var  parameters = new List <SqlParameter>();

            parameters.Add(sqlHelper.CreateParameter("@Code", Code, DbType.Int32));
            parameters.Add(sqlHelper.CreateParameter("@Email", Email, DbType.String));

            var dataReader = sqlHelper.GetDataReader("SELECT Id,Email,Kod,KodGenerateDate FROM EmailChacking WHERE Kod=@Code AND Email=@Email",
                                                     CommandType.Text, parameters.ToArray(), out connection);

            try
            {
                var codes = new EmailChecking();
                while (dataReader.Read())
                {
                    codes.KodGenerateDate = dataReader["KodGenerateDate"] == System.DBNull.Value ? default(DateTime) : (DateTime)dataReader["KodGenerateDate"];
                }
                DateTime t       = codes.KodGenerateDate ?? (DateTime.Now.AddDays(-10));
                double   minutes = (DateTime.Now - t).TotalMinutes;
                if (minutes < 5)
                {
                    netice = true;
                }
            }
            catch (Exception exp)
            {
                logger.Error(exp, "EmailChacking");
                throw;
            }
            finally
            {
                dataReader.Close();
                CloseConnection();
            }
            return(netice);
        }