public ActionResult Register(RegisterModel model, bool captchaValid, string captchaErrorMessage)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    UserTable usertable = new UserTable();
                    usertable.UserId = GetNextUserId();
                    usertable.Nom = model.UserLName;
                    usertable.Prenom = model.UserFName;
                    usertable.Pseudo = model.UserName;
                    usertable.Courriel = model.EmailAddress;
                    usertable.MotDePasse = model.Password;
                    if (model.TermAndConditions)
                        usertable.SiteCondAccept = true;
                    else
                        usertable.SiteCondAccept = false;

                    if (!captchaValid)
                    {
                        ModelState.AddModelError("recaptcha", captchaErrorMessage);
                        return View(model);
                    }
                    else
                    {
                        if (!DoesUserNameExist(model.UserName))
                        {
                            //Generate key to validate registration
                            String keyRegistration = usertable.Prenom + "-" + usertable.Nom + "-"+usertable.UserId;

                            MD5 md5Hash = MD5.Create();
                            usertable.ValidationToken = GetMd5Hash(md5Hash, keyRegistration);

                            // Send email to user to confirm account registration.
                            if (SendAccountConfimration(model, usertable.ValidationToken))
                            {
                                db.UserTables.Add(usertable);
                                db.SaveChanges();

                                return RedirectToAction("AfterRegister", "Account");
                            }
                            else
                                ModelState.AddModelError("", "An error has occurred attempting to send an email.");
                        }
                        else
                        {
                            ModelState.AddModelError("", "Username already exist.  Please select another username.");
                        }
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Registration Error");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
       public Boolean SendAccountConfimration(RegisterModel model, String tokenBody)
        {
            Boolean bRetCode = true;
            //Send confirmation email.
            try
            {
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                String prefix = "http://notetaloc.azurewebsites.net/Account/Activation?activationKey=";
                String validationLink = prefix + tokenBody;

                message.To.Add(model.EmailAddress); //recipient 
                message.Subject = "RateYourRent - confirmation email";
                message.From = new System.Net.Mail.MailAddress("*****@*****.**"); //from email 
                message.Body = "Please click on the link to confirm your registration: "+validationLink;
                
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mail.cia.ca");
                smtp.Send(message); 
            }
            catch
            {
                bRetCode = false;
            }
            return bRetCode;
        }