Beispiel #1
0
 /// <summary>
 /// check if all info was correct and send mail to the email
 /// </summary>
 /// <param name="email"></param>
 /// <param name="favColor"></param>
 public void CheckUserinfo(string email, string favColor)
 {
     try
     {
         //if email and favcolor is correct
         if (Validdate(email, favColor))
         {
             string key = GenerateKey();
             //check email for existing;;
             var keymodel = KeyRepository.CheckKeyExistByEmail(email);
             if (keymodel != null)
             {
                 keymodel.Key = key;
                 keyService.UpdateKey(keymodel);
             }
             else
             {
                 keyService.SetKey(key, email);
             }
             //send mail to the given email
             EmailController emailController = new EmailController();
             emailController.SendMail("ResetKey", email, "Your reset key is: " + key);
             MessageBox.Show("Email send");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void InsertUser(UserModel user, bool sendEmail)
        {
            //Add user by service
            user.UserId = UserRepository.AutoIncredement();
            UserService.InsertUser(user);

            //Check checkbox
            if (sendEmail)
            {
                //Send mail
                EmailController email   = new EmailController();
                string          subject = "Your account has been added to NoDesk: TGG";
                string          toMail  = user.Email;
                string          body    = "Dear " + user.FirstName + ",\r\n\r\nYour username is: " + user.Username + "\r\nYour password: "******"\r\n\r\nYours sincerly,\r\n\r\nNoDesk";
                email.SendMail(subject, toMail, body);
            }
        }