private static Member CreateNewMember(RegisterModel model)
        {
            var user = new User(0);

            var mt = MemberType.GetByAlias(model.MemberTypeAlias) ?? MemberType.MakeNew(user, model.MemberTypeAlias);

            var member = Member.MakeNew(model.Username, mt, user);

            if (model.Name != null)
            {
                member.Text = model.Name;
            }

            member.Email = model.Email;
            member.Password = model.Password;

            if (model.MemberProperties != null)
            {
                foreach (var property in model.MemberProperties.Where(p => p.Value != null))
                {
                    member.getProperty(property.Alias).Value = property.Value;
                }
            }

            member.Save();
            return member;
        }
        public ActionResult Register(RegisterModel reg_model)
        {
            reg_model.Name = reg_model.Username;
              reg_model.UsernameIsEmail = false;
              MembershipCreateStatus status = MembershipCreateStatus.UserRejected;
              MembershipUser user = Membership.CreateUser(reg_model.Username, reg_model.Password, reg_model.Email,
            null, null, false, null, out status);

              switch (status)
              {
            case MembershipCreateStatus.DuplicateUserName:
              TempData["register_error"] = "Указанное имя пользователя уже зарегистрировано, попробуйте другое имя";
              break;
            case MembershipCreateStatus.DuplicateEmail:
              TempData["register_error"] = "Указанный email уже зарегистрирован, воспользуйтесь процедурой восстановления пароля";
              break;
            case MembershipCreateStatus.Success:
              string confirmUrl = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + "/register/verify/" + user.ProviderUserKey.ToString();
              EmailHelper.SendConfirmationMail(user.UserName, user.Email, confirmUrl);
              return Redirect(reg_model.RedirectUrl);
              }

              return RedirectToAction("Register");
        }