public ActionResult RegisterUser(registerItem item)
        {
            System.Threading.Thread.Sleep(1500);

            var enCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            var trCulture = System.Globalization.CultureInfo.CreateSpecificCulture("tr-TR");

            // lower Emal
            item.email = item.email.ToLower(enCulture);

            // Upper case Name And Surname
            var currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            item.name = currentCulture.TextInfo.ToTitleCase(item.name);
            item.surname = currentCulture.TextInfo.ToTitleCase(item.surname);

            string redirectPage = "";
            pageShared ps = new pageShared(db);
            userShared us = new userShared(db);
            string html = "";

            var aggrementModule = ps.getModuleByType(moduleType.registerAgreement, langId);
            if (aggrementModule != null)
            {
                item.agreementContent = aggrementModule.htmlContent;
            }

            // Input Validate
            #region Validate

            if (item.gender == 0)
            {
                ModelState.AddModelError("gender", App_GlobalResources.lang.formGenderRequired);
            }

            if (item.day == 0)
            {
                ModelState.AddModelError("day", App_GlobalResources.lang.formDayRequired);
            }
            if (item.month == 0)
            {
                ModelState.AddModelError("month", App_GlobalResources.lang.formMonthRequired);
            }

            if (item.year == 0)
            {
                ModelState.AddModelError("year", App_GlobalResources.lang.formYearRequired);
            }

            if (!item.isAggrementCheck)
            {
                ModelState.AddModelError("isAggrementCheck", App_GlobalResources.lang.formUserDocumentRequired);
            }

            DateTime birthday = DateTime.Now;

            try
            {
                birthday = new DateTime(item.year, item.month, item.day);
            }
            catch
            {
                ModelState.AddModelError("validDate", App_GlobalResources.lang.formValidDate);
            }

            try
            {
                System.Net.Mail.MailAddress mailItem = new System.Net.Mail.MailAddress(item.email);
            }
            catch
            {
                ModelState.AddModelError("email", App_GlobalResources.lang.formValidEmail);
            }

            if (item.password != item.passwordRep)
            {
                ModelState.AddModelError("passwordRep", App_GlobalResources.lang.formPassworRepSame);
            }

            #endregion

            // Register Statu Validate
            #region RegisterControl

            if (ModelState.IsValid)
            {
                var registerStatuItem = us.getUserRegisterStatuByEmail(item.email);

                string errorMessage = "";
                bool isRegisterStatuValid = false;

                switch (registerStatuItem)
                {
                    case registerStatu.registered:

                        var forgetPassword = ps.getPageByType(pageType.forgetPassword, langId);
                        errorMessage = App_GlobalResources.lang.activationHasRegisteredUser;
                        errorMessage = errorMessage.Replace("[email]", item.email);

                        if (forgetPassword != null)
                        {
                            errorMessage = errorMessage.Replace("[forgetPasswordUrl]", (Url.Content("~/") + langCode + "/" + forgetPassword.url + ".html"));
                        }

                        break;
                    case registerStatu.waitingActivation:

                        var pageMailResent = ps.getPageByType(pageType.activationResent, langId);

                        // Send Error Message
                        // Replace [email],[activationResent] errorMessage
                        errorMessage = App_GlobalResources.lang.activationNoApprove;
                        errorMessage = errorMessage.Replace("[email]", item.email);
                        if (pageMailResent != null)
                        {
                            errorMessage = errorMessage.Replace("[activationResent]", (Url.Content("~/") + langCode + "/" + pageMailResent.url + ".html"));
                        }

                        break;
                    case registerStatu.ban:

                        errorMessage = App_GlobalResources.lang.unexpectedErrorMsg;

                        break;
                    case registerStatu.unregistered:

                        isRegisterStatuValid = true;
                        break;

                }

                if (!isRegisterStatuValid)
                {
                    item.isMessageExist = true;
                    item.message = getErrorMessage(errorMessage);
                    html = RenderRazorViewToString("Register", item);
                    return Json(new { htmlText = html });
                }

            }

            #endregion

            if (ModelState.IsValid)
            {
                bool isProoceessError = false;

                #region Shared

                var settingItem = db.tbl_settings.Where(a => a.langId == langId).FirstOrDefault();
                var userItem = new tbl_user();
                mailShared ms = new mailShared(db, langId);

                userItem.birthday = birthday;
                userItem.email = item.email;
                userItem.gender = item.gender;
                userItem.guid = Guid.NewGuid().ToString();
                userItem.isPasswordUpdate = false;
                userItem.name = item.name;
                userItem.password = MD5(item.password);
                userItem.registerStatuId = (int)registerStatu.waitingActivation;
                userItem.surname = item.surname;
                userItem.userTypeId = (int)userType.normalMember;
                userItem.createDate = DateTime.Now;
                #endregion

                // Has Activation
                if (settingItem.registerIsActivationExist)
                {
                    #region Add User

                    try
                    {
                        db.tbl_user.Add(userItem);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        errorSend(ex, "User Aktivasyonlu Ekleme");
                        isProoceessError = true;
                    }

                    #endregion

                    #region Activation Add

                    tbl_activation activationItem = new tbl_activation();

                    try
                    {
                        activationItem = us.addActivationWithItem(userItem.guid, userItem.userId);
                    }
                    catch (Exception ex)
                    {
                        errorSend(ex, "User Aktivation Ekleme");
                        isProoceessError = true;

                    }

                    #endregion

                    #region Action

                    if (!isProoceessError)
                    {
                        var mailItem = ms.getActivationMailContent(userItem.name, userItem.surname, activationItem.code, getSiteName(Request), langCode);
                        string mailSubject = mailItem.Item1;
                        string mailBody = mailItem.Item2;

                        try
                        {
                            mailSend(userItem.email, mailSubject, mailBody);

                            ModelState.Clear();
                            item.isMessageExist = true;
                            item.message = getSuccesMessage(App_GlobalResources.lang.activationMailSend.Replace("[email]", userItem.email));

                            // Add Resent Mail Link
                            var pageMailResent = ps.getPageByType(pageType.activationResent, langId);
                            string resentMailMsg = "";

                            if (pageMailResent != null)
                            {
                                resentMailMsg = App_GlobalResources.lang.activationMailResend;
                                resentMailMsg = resentMailMsg.Replace("[resentMailLink]", Url.Content("~/" + langCode + "/" + pageMailResent.url + ".html"));
                            }

                            item.message = item.message + resentMailMsg;
                        }
                        catch (Exception ex)
                        {
                            errorSend(ex, "Send Activation Mail");
                            isProoceessError = true;
                        }
                    }

                    #endregion
                }

                else   // No Activation
                {
                    userItem.registerStatuId = (int)registerStatu.registered;

                    #region Add User

                    try
                    {
                        db.tbl_user.Add(userItem);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        errorSend(ex, "User Aktivasyonsuz Ekleme");
                        isProoceessError = true;
                    }

                    #endregion

                    #region Thank Message

                    if (!isProoceessError && settingItem.registerIsThankMessageSend)
                    {
                        var mailItem = ms.getRegisterThankMailContent(userItem.name, userItem.surname);
                        string mailSubject = mailItem.Item1;
                        string mailBody = mailItem.Item2;

                        try
                        {
                            mailSend(userItem.email, mailSubject, mailBody);
                        }
                        catch (Exception ex)
                        {
                            errorSend(ex, "Send Thank Mail");
                        }

                    }

                    #endregion

                    #region Action

                    item.isMessageExist = true;
                    item.message = getSuccesMessage("Üyeliğiniz başarıyla oluşturuldu.Kaldığınız sayfaya yönlendiriliyorsunuz...");

                    // Set UserId, User Role , CheckoutProcess
                    setLoginSession(userItem);

                    // Switch Guest to Basket && Redirect
                    redirectPage = basketSwitchAndRedirect(userItem);

                    #endregion
                }

                // Process Has Error
                if (isProoceessError)
                {
                    item.isMessageExist = true;
                    item.message = getErrorMessage(App_GlobalResources.lang.unexpectedErrorMsg, "");
                    errorSend(new Exception("Kayıt Sırasında Hata"), "Kayıt Sırasında Hata", true);
                }
            }

            html = RenderRazorViewToString("Register", item);
            return Json(new { htmlText = html, redirectPage = redirectPage });
        }
        public ActionResult Index(int pageId)
        {
            pageShared ps = new pageShared(db);

            var helperItem = new ViewModel.LoginRegister.helperLoginRegister();

            // Registered User Redirect
            if (ViewData["topCart"] != null)
            {
                var cartItem = (topCart)ViewData["topCart"];
                if (cartItem.isRegisteredUser)
                {
                    return Redirect("~/");
                }
            }

            helperItem.register = new ViewModel.LoginRegister.registerItem();
            var aggrementModule = ps.getModuleByType(moduleType.registerAgreement, langId);
            if (aggrementModule != null)
            {
                helperItem.register.agreementContent = aggrementModule.htmlContent;
            }

            helperItem.login = new ViewModel.LoginRegister.loginItem();

            var pageItem = ps.getPageById(pageId);
            if (pageItem == null)
            {
                return null;
            }

            ps.pageTitleBind(pageItem, helperItem, langId);
            var pageName = pageItem.name;
            if (!string.IsNullOrWhiteSpace(pageItem.title))
            {
                pageName = pageItem.title;
            }

            // forget Password Link
            var forgetPasswordPage = ps.getPageByType(pageType.forgetPassword, langId);
            if (forgetPasswordPage != null)
            {
                helperItem.login.forgetPasswordUrl = langCode + "/" + forgetPasswordPage.url + ".html";
            }

            // Facebook Register & login Error
            if (Request.QueryString["facebookError"] != null && Request.QueryString["facebookError"].ToString() == "yes")
            {
                helperItem.isFacebookError = true;
                helperItem.facebookErrorMessage = getErrorMessage(App_GlobalResources.lang.unexpectedErrorMsg);
            }

            if (Request.QueryString["needLogin"] != null && Request.QueryString["needLogin"].ToString() == "yes")
            {
                helperItem.isLoginRequeredShown = true;
                helperItem.isLoginRequeredMessage = getErrorMessage(App_GlobalResources.lang.needLogin, "mTop10 mBottom0 autoHide");
            }

            helperItem.breadCrumbItem = getBreadCrumbStaticPage(pageName);

            return View(helperItem);
        }