//[HttpPost]
        //[Route("Register")]
        public ActionResult Register(Customer model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //the password is checked using the [Compare] tag. (checked before this post method is invoked). See Customer

            /*else if (model.Password != model.ConfirmPassword){
             *  ModelState.AddModelError("PasswordsDoNotMatch", "Passwords do not match!");
             *  return View(model);
             * }*/
            else
            {
                using (var context = new SiteContext()) {
                    //model.RoleId = context.Roles.Where(r => r.Name.ToLower().Equals("user")).FirstOrDefault().Id;
                    //model.RoleType = RoleType.Administrator;
                    model.RoleId = 3; // Role ID 3 =  Normal

                    Customer match = context.Customers.Where(u => u.UserName == model.UserName || u.Email == model.Email).FirstOrDefault();
                    //this is now being checked by the modelstate checker. see customer entity class

                    /*
                     * if (match != null){
                     *  ModelState.AddModelError("ExistingUser", "Please choose a different username");
                     *  return View(model);
                     * }
                     * else{*/
                    model.CreatedDate   = DateTime.Today;
                    model.LastLoginDate = DateTime.Today;

                    HttpPostedFileBase file = Request.Files["ImageData"];
                    if (file != null)
                    {
                        byte[] arr = _image.ConvertToBytes(file);
                        if (arr.Length <= 2000000)
                        {
                            model.File = arr;
                        }
                        else
                        {
                            //display a warning and do not let the user register
                            ModelState.AddModelError("File", "File too large. Upload limit: 2MB");
                            return(View(model));
                        }
                    }
                    else
                    {
                        model.File = new byte[] { };
                    }

                    //model.Password = Encryption(model.Password);
                    //model.ConfirmPassword = Encryption(model.ConfirmPassword);
                    model.Password        = _encrypt.Encryption(model.Password);
                    model.ConfirmPassword = _encrypt.Encryption(model.ConfirmPassword);

                    context.Customers.Add(model);
                    try{
                        context.SaveChanges();
                    }
                    catch {
                        ModelState.AddModelError("File too large", "Please choose a different file");
                        return(View(model));
                    }
                    return(Redirect("Login"));
                }
            }
        }