Example #1
0
        public ActionResult Register(RegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipCreateStatus createStatus;
                WebSite.Infrastructure.MembershipProvider membershipProvider = Membership.Provider as WebSite.Infrastructure.MembershipProvider;

                int memberId = membershipProvider.CreateStockwinnersMember(model.Email, model.Password, model.FirstName, model.LastName, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    Authentication.SetCurrentUser(new LoggedInUserIdentity()
                    {
                        FirstName                = model.FirstName,
                        LastName                 = model.LastName,
                        EmailAddress             = model.Email,
                        IdentityProvider         = IdentityProvider.Stockwinners,
                        IdentityProviderIssuedId = memberId.ToString()
                    }, rememberUser: false);

                    return(this.RedirectToAction("RegistrationSuccess"));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #2
0
        public ActionResult Signup(string firstName, string lastName, string email)
        {
            // Do we have all the data we need?
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(email))
            {
                return(this.RedirectToAction("Index", "Home"));
            }

            MembershipCreateStatus createStatus;

            WebSite.Infrastructure.MembershipProvider membershipProvider = Membership.Provider as WebSite.Infrastructure.MembershipProvider;

            int memberId = membershipProvider.CreateStockwinnersMember(email, "stockwinners", firstName, lastName, out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                Authentication.SetCurrentUser(new LoggedInUserIdentity()
                {
                    FirstName                = firstName,
                    LastName                 = lastName,
                    EmailAddress             = email,
                    IdentityProvider         = IdentityProvider.Stockwinners,
                    IdentityProviderIssuedId = memberId.ToString()
                }, rememberUser: false);
            }

            ViewBag.ShowTemporaryPassword = true;

            return(View("RegistrationSuccess"));
        }