예제 #1
0
        public async Task <Boolean> RegisterCustomer(Customer customer)
        {
            var email = customer.Email;

            customer.Pass_word = HashAndSalt.HashSalt(customer.Pass_word);
            using (IDbConnection dbConnection = Connection)
            {
                string sQuery0 = "SELECT FirstName FROM Customer WHERE Email = @email";
                dbConnection.Open();
                String result = dbConnection.QueryFirstOrDefault <String>(sQuery0, new { @Email = email });
                dbConnection.Close();

                if (string.IsNullOrEmpty(result))
                {
                    customer.VerifiCode = VerifiCodeGenarator.CreateRandomPassword();
                    customer.Validated  = false;
                    string sQuery = "INSERT INTO Customer(FirstName,LastName,Pass_word,Email,MobileNo,VerifiCode,Validated)" +
                                    "VALUES(@FirstName,@LastName,@Pass_word,@Email,@MobileNo,@VerifiCode,@Validated)";

                    dbConnection.Open();
                    //dbConnection.Execute(sQuery, new { customer.FirstName = FirstName , VerifiCode = vCode });
                    dbConnection.Execute(sQuery, customer);
                    Senders emailsender = new Senders();
                    await emailsender.SendEmailAsync("*****@*****.**", customer.VerifiCode);

                    return(true);
                }
            }
            return(false);
        }