First, users
Second, the user group
2.1 Browse User Groups
2.2 Adding user groups
2.3 Modifying user groups
First Open "Usergroupcontroller" and modify the [Edit (int Id)] Action
<summary>
///Modify user group
///</summary>
///<param name= "Id" > User group id</param>
/ <returns></returns>
[adminauthorize] public
actionresult Edit (int Id)
{
Usergrouprsy = new Usergrouprepository ();
var _usergroup = Usergrouprsy.find (Id);
Return View (_usergroup);
}
Right-click to add the enhanced type view and modify the view code (similar to the Add user group)
@model Ninesky.Models.UserGroup @{viewbag.title = "Modify User group";
Layout = "~/views/layout/_manage.cshtml";
<div class= "Left" > <div class= "Top" ></div> left-hand list </div> <div class= "Split" ></div> <div class= "Workspace" > <div class= "Inside" > <div class= "Notebar" > Modify user Group Data </div> @using (Html.BeginForm (" Eidt "," UserGroup ")) {@ Html.validationsummary (True) <fieldset> <legend> user group information </legend> @Html. HIDDENFOR (model => model. Usergroupid) <ul> <li> <div class= "Editor-label" > @Html. Labelfor (model => model. Type) </div> <div class= "Editor-field" > @Html. Displaytextfor (model => model. Type) </div> </li> <li> <div class= "Editor-label" > @Html. Labelfor (model => model. Name) </div> <div class= "Editor-field" > @Html. Editorfor (model => model. Name) @Html.validationmessagefor (model => model. Name) </div> </li> <li> <div class= "Editor-label" > @Html. Labelfor (model => model. Description) </div> <div class= "Editor-field" > @Html. Editorfor (model => model. Description) @Html. Validationmessagefor (model => model. Description) </div> </li> <li> <div class= "Editor-label" > </div> <div class= "
Editor-field "> <input type=" Submit "value=" save "/> </div> </li> </ul> </fieldset> } </div> </div> <div class= "clear" ></div> @section Scripts {@Scripts. Render ("~/bundles/jquery
Val ")}
Modify processing Action[eidt (UserGroup usergroup)]
[HttpPost]
[Adminauthorize] public actionresult Eidt (UserGroup usergroup) {usergrouprsy = new usergrouprepository ();
var _usergroup = Usergrouprsy.find (usergroup.usergroupid); if (_usergroup = = null) {Error _e = new Error {Title = "user group does not exist", Details = "errors occurred while modifying the user, the modified user group does not exist." ", cause =" The user group has been deleted by another administrator ", Solution = Server.URLEncode (" <li> return <a href= ' "+ url.action (" List "," usergroup ") +" ' &
gt; user group List </a></li> ")};
Return redirecttoaction ("Manageerror", "Prompt", _e);
} _usergroup.name = Usergroup.name;
_usergroup.description = usergroup.description; if (Usergrouprsy.update (_usergroup)) {Notice _n = new Notice {Title = "modified successfully", details = "Successfully modified user group information", Dwelltime = 3, n
Avigationname = "user group list", Navigationurl = url.action ("list", "UserGroup")};
Return redirecttoaction ("Managenotice", "Prompt", _n); else {Error _e = new Error {Title = ' update data failed ', details = ' modified information when modifying user group information failed to be saved to the database. ", cause = Server.URLEncode (" <li> you did not change the user group information. </li><li> database is notKnow the wrong. </li> "), Solution = Server.URLEncode (" <li> return <a href= ' "+ url.action (" list "," usergroup ") +" ' > User group list </a></li><li> re-<a href= ' "+ url.action (" Edit "," UserGroup ", new {id = usergroup.usergroupid}) +" ' &
gt; Modify user group </a></li> ")};
Return redirecttoaction ("Manageerror", "Prompt", _e);
}
}
Browser Open Look
Point Save
Code Packaging Address: Http://xiazai.jb51.net/201608/yuanma/Ninesky (jb51.net). rar
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.