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 ActionResult Edit(UserTable usertable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usertable).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(usertable);
 }
        public ActionResult Create(UserTable usertable)
        {
            if (ModelState.IsValid)
            {
                db.UserTables.Add(usertable);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(usertable);
        }