Пример #1
0
        public ActionResult Register(RegisterModel model)
        {
            model.TimeZones = TimeZoneInfo.GetSystemTimeZones();

            if (ModelState.IsValid)
            {
                MembershipCreateStatus createStatus;
                var user = Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, createPersistentCookie: false);

                    _userSettingsService.Add(new UserSettings() { UserId = user.ProviderUserKey.ToString(), TimeZoneId = model.TimeZoneId });

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, ErrorCodeToString(createStatus));
                }
            }

            return View(model);
        }
Пример #2
0
        public ActionResult Register()
        {
            var registerViewModel = new RegisterModel()
            {
                TimeZones = TimeZoneInfo.GetSystemTimeZones()
            };

            ViewData.Model = registerViewModel;

            return View();
        }