Exemplo n.º 1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    dbHelper.AddUser(model);
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return PartialView(model);
        }
Exemplo n.º 2
0
        public void AddUser(RegisterModel model)
        {
            var user = new UserModels { Name = model.UserName,
                                        Email = model.Email,
                                        Comments = new List<CommentModels>(),
                                        Deals = new List<DealModels>(),
                                        Validated = false,
                                        ValidationUrl = Utils.ToolUtils.CreateValidationEmail(model.Email, "http://localhost:61382/")
            };

            dbStore.User.Add(user);
            dbStore.SaveChanges();
        }