Ejemplo n.º 1
0
        public ActionResult Create(RegisterModel model)
        {
            while (!String.IsNullOrEmpty(model.Username) && model.Username.Last() == ' ')
            {
                model.Username = model.Username.Substring(0, model.Username.Length - 1);
            }

            if (ModelState.IsValid)
            {
                if (MembershipService.CreateUser(model.Username, model.Password, model.Name, model.Surname, model.Email))
                {
                    TempData["CreateSuccess"] = true;
                    return RedirectToAction("Index", "Account");
                }
                else
                {
                    ModelState.AddModelError("Username", Resources.Home_Register_AccountAlreadyExists);
                }
            }

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Register(RegisterModel model)
        {
            while (!String.IsNullOrEmpty(model.Username) && model.Username.Last() == ' ')
            {
                model.Username = model.Username.Substring(0, model.Username.Length - 1);
            }

            if (ModelState.IsValid)
            {
                if (MembershipService.CreateUser(model.Username, model.Password, model.Name, model.Surname, model.Email))
                {
                    FormsAuthenticationService.SignIn(model.Username, false);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("Username", Resources.Home_Register_AccountAlreadyExists);
                }
            }

            return View(model);
        }