コード例 #1
0
		public new ActionResult User(UserEditModel um) {
			if (um.User.IsNew)
				ViewBag.Title = Piranha.Resources.Settings.EditTitleNewUser ;
			else ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;

			if (ModelState.IsValid) {
				try {
					if (um.SaveAll()) {
						ModelState.Clear() ;
						ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;
						SuccessMessage(Piranha.Resources.Settings.MessageUserSaved) ;
					} else ErrorMessage(Piranha.Resources.Settings.MessageUserNotSaved) ;
				} catch (Exception e) {
					ErrorMessage(e.ToString()) ;
				}
			}
			return View(@"~/Areas/Manager/Views/Settings/User.cshtml", um) ;
		}
コード例 #2
0
ファイル: SettingsController.cs プロジェクト: d-popov/Piranha
		public new ActionResult User(UserEditModel um) {
			if (um.User.IsNew)
				ViewBag.Title = Piranha.Resources.Settings.EditTitleNewUser ;
			else ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;

			// Check so that users are not saved without a group
			if (um.User.GroupId == Guid.Empty)
				ModelState.AddModelError("User.GroupId", Resources.Settings.UserGroupIdRequired) ;

			if (ModelState.IsValid) {
				try {
                    if (um.SaveAll()) {
						ModelState.Clear() ;
						ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;
						SuccessMessage(Piranha.Resources.Settings.MessageUserSaved) ;
					} else ErrorMessage(Piranha.Resources.Settings.MessageUserNotSaved) ;
				} catch (Exception e) {
					ErrorMessage(e.ToString()) ;
				}
			}
			return View(@"~/Areas/Manager/Views/Settings/User.cshtml", um) ;
		}
コード例 #3
0
		public new ActionResult User(UserEditModel um) {
			if (um.User.IsNew)
				ViewBag.Title = Piranha.Resources.Settings.EditTitleNewUser ;
			else ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;

			// Check so that users are not saved without a group
			if (um.User.GroupId == Guid.Empty)
				ModelState.AddModelError("User.GroupId", Resources.Settings.UserGroupIdRequired) ;

			if (ModelState.IsValid) {
				try {
			        // Executes the user edit before save hook, if registered
			        if (WebPages.Hooks.Manager.UserEditModelBeforeSave != null)
				        WebPages.Hooks.Manager.UserEditModelBeforeSave(this, WebPages.Manager.GetActiveMenuItem(), um) ;

                    if (um.SaveAll()) {
                        // Executes the user edit after save hook, if registered
			            if (WebPages.Hooks.Manager.UserEditModelAfterSave != null)
				            WebPages.Hooks.Manager.UserEditModelAfterSave(this, WebPages.Manager.GetActiveMenuItem(), um) ;

						ModelState.Clear() ;
						ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingUser ;
						SuccessMessage(Piranha.Resources.Settings.MessageUserSaved) ;
					} else ErrorMessage(Piranha.Resources.Settings.MessageUserNotSaved) ;
				} catch (Exception e) {
					ErrorMessage(e.ToString()) ;
				}
			}
			return View(@"~/Areas/Manager/Views/Settings/User.cshtml", um) ;
		}