Esempio n. 1
0
        public void WithViewModelRendersWithoutExceptions()
        {
            var view = new Register();

            var viewModel = new RegisterViewModel { ConfirmPassword = "******", Password = "******", Email = "incorrect" };

            var html = view.RenderAsHtml(viewModel);
        }
Esempio n. 2
0
        public ActionResult Register(RegisterViewModel model)
        {
            Contract.Requires<InvalidOperationException>(this.ClientService != null);
            Contract.Requires<InvalidOperationException>(this.SessionPersister != null);
            Contract.Requires<ArgumentNullException>(model != null, "model");

            if (this.SessionPersister.HasSession)
            {
                throw new InvalidOperationException("The user is already logged in.");
            }

            if (this.ModelState.IsValid)
            {
                this.ClientService.CreateUser(model.Email, model.Password, model.ParentUserId);
                this.SessionPersister.SessionId = this.ClientService.CreateSession(model.Email, model.Password);
                return this.RedirectToAction(string.Empty, "Account");
            }

            return this.View(model);
        }