private static RegisterModel PopulateRegisterModel(Guid id)
        {
            MemberDisplayBasic member = RDN.Library.Classes.Account.User.GetMemberDisplay(id);
            RegisterModel register = new RegisterModel();
            register.DerbyName = member.DerbyName;
            register.GenderName = member.Gender;
            register.MemberId = member.MemberId;

            if (member.Email != null)
                register.EmailVerify = member.Email.Split('@').LastOrDefault();
            return register;
        }
[RequireHttps] //apply to all actions in controller
#endif
        public ActionResult SignUp()
        {
            RegisterModel model = new RegisterModel();
            NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.Url.Query);
            string updated = nameValueCollection["u"];
            List<DefaultPositionEnum> positions = Enum.GetValues(typeof(DefaultPositionEnum))
                                                           .Cast<DefaultPositionEnum>().ToList();

            //need to remove the first position from the list.
            positions.RemoveAt(0);
            var list = (from a in positions
                        select new SelectListItem
                        {
                            Text = RDN.Utilities.Enums.EnumExt.ToFreindlyName(a),
                            Value = ((int)a).ToString()
                        });

            ViewBag.Positions = new SelectList(list, "Value", "Text");

            List<GenderEnum> genders = Enum.GetValues(typeof(GenderEnum))
                                                           .Cast<GenderEnum>().ToList();
            genders.RemoveAt(0);
            var listGenders = (from a in genders
                               select new SelectListItem
                               {
                                   Text = RDN.Utilities.Enums.EnumExt.ToFreindlyName(a),
                                   Value = ((int)a).ToString()
                               });
            ViewBag.Genders = new SelectList(listGenders, "Value", "Text");

            if (!String.IsNullOrEmpty(updated) && updated == "f")
                model.IsConnectedToRollerDerby = false;
            else
                model.IsConnectedToRollerDerby = true;
            return View(model);
        }
[RequireHttps] //apply to all actions in controller
#endif
        public ActionResult SignUp(RegisterModel model)
        {
            try
            {

                if (!String.IsNullOrEmpty(model.Email) && (model.Email.Contains("@163.com") || model.Email.Contains("@tom.com") || model.Email.Contains("@126.com")))
                {
                    ModelState.AddModelError("", "That Domain name has been banned from RDNation, if you think this is in Error, please contact us.");
                    return View(model);
                }
                var id = StoreGateway.GetShoppingCartId(HttpContext);

                List<DefaultPositionEnum> positions = Enum.GetValues(typeof(DefaultPositionEnum))
                                                          .Cast<DefaultPositionEnum>().ToList();
                //need to remove the first position from the list.
                positions.RemoveAt(0);
                var list = (from a in positions
                            select new SelectListItem
                            {
                                Text = RDN.Utilities.Enums.EnumExt.ToFreindlyName(a),
                                Value = ((int)a).ToString()
                            });

                ViewBag.Positions = new SelectList(list, "Value", "Text");

                List<GenderEnum> genders = Enum.GetValues(typeof(GenderEnum))
                                                           .Cast<GenderEnum>().ToList();
                genders.RemoveAt(0);
                var listGenders = (from a in genders
                                   select new SelectListItem
                                   {
                                       Text = RDN.Utilities.Enums.EnumExt.ToFreindlyName(a),
                                       Value = ((int)a).ToString()
                                   });
                ViewBag.Genders = new SelectList(listGenders, "Value", "Text");


                List<NewUserEnum> result = new List<NewUserEnum>();
                //p=f&returnSite=store&ReturnUrl
                if (model.IsConnectedToRollerDerby)
                    result = Library.Classes.Account.User.CreateMember(model.Email, model.ConfirmEmail, model.Password, model.Firstname, model.DerbyName, model.Gender, model.PositionType, Request.UserHostAddress);
                else
                {
                    result = Library.Classes.Account.User.CreateUserNotConnectedToDerby(model.Email, model.ConfirmEmail, model.Password);
                }
                if (result.Count > 0)
                {
                    model.Errors = Register.RegisterErrors(result);
                    return View(model);
                }
                setCookie(model.Email, true);

                if (id != null)
                    StoreGateway.SetShoppingCartSession(id.Value, HttpContext);

                if (Request.UrlReferrer != null)
                {
                    NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.UrlReferrer.Query);
                    string site = nameValueCollection["returnSite"];
                    string url = nameValueCollection["ReturnUrl"];

                    if (site == "store")
                    {
                        if (!String.IsNullOrEmpty(site) && !String.IsNullOrEmpty(url))
                            return Redirect(ServerConfig.WEBSITE_STORE_DEFAULT_LOCATION + url);
                        else if (!String.IsNullOrEmpty(site))
                            return Redirect(ServerConfig.WEBSITE_STORE_DEFAULT_LOCATION);
                    }
                    else if (site == "rollinNews")
                    {
                        if (!String.IsNullOrEmpty(site) && !String.IsNullOrEmpty(url))
                            return Redirect(RollinNewsConfig.WEBSITE_DEFAULT_LOCATION + url);
                        else if (!String.IsNullOrEmpty(site))
                            return Redirect(RollinNewsConfig.WEBSITE_DEFAULT_LOCATION);

                    }

                }
                return Redirect(ServerConfig.WEBSITE_INTERNAL_DEFAULT_LOCATION);
            }
            catch (Exception e)
            {
                ErrorDatabaseManager.AddException(e, GetType());
                return View();
            }
        }
[RequireHttps] //apply to all actions in controller
#endif
        public ActionResult VerifyDerbyName(RegisterModel model)
        {
            try
            {

                var result = Library.Classes.Account.User.VerifyDerbyNameAndCreateAccount(model.MemberId, model.Email, model.ConfirmEmail, model.Password, Request.UserHostAddress);

                if (result.Count > 0)
                {
                    RegisterModel register = PopulateRegisterModel(model.MemberId);
                    register.Errors = Register.RegisterErrors(result);
                    return View(register);
                }

                setCookie(model.Email, true);


                return Redirect("http://league.rdnation.com");



            }
            catch (Exception e)
            {
                ErrorDatabaseManager.AddException(e, GetType());
                return View();
            }
        }