Beispiel #1
0
 public ActionResult Create()
 {
     var model = new UserCreateViewModel {
         Password = Membership.GeneratePassword(12, 1)
     };
     if (RuntimeOptions.Current.UseMailing) {
         ViewBag.HeaderText = "Na zadanou e-mailovou adresu bude automaticky zaslána zpráva s instrukcemi pro přihlášení.";
     }
     ViewBag.Title = "Nový uživatel";
     ViewBag.CancelAction = "Index";
     return View("~/Views/Shared/UniversalEditor.cshtml", model);
 }
Beispiel #2
0
 public ActionResult Create(UserCreateViewModel model)
 {
     if (this.TryUpdateModel(model)) {
         MembershipCreateStatus status;
         var newUser = Membership.CreateUser(model.UserName, model.Password, model.EmailAddress, null, null, true, out status);
         if (status == MembershipCreateStatus.Success) {
             var homeUri = new UriBuilder(this.Request.Url) { Path = "", Query = "", Fragment = "" };
             Mailer.SendMail(model.EmailAddress, Properties.Resources.UserCreateSubject, Properties.Resources.UserCreateBody,
                 RuntimeOptions.Current.ApplicationTitle,
                 homeUri,
                 model.UserName,
                 model.Password);
             return this.RedirectToAction("Index");
         }
         this.ModelState.AddModelError(null, string.Format("Nepodařilo se vytvořit uživatele: {0}", status));
     }
     ViewBag.Title = "Nový uživatel";
     ViewBag.CancelAction = "Index";
     return View("~/Views/Shared/UniversalEditor.cshtml", model);
 }