@model Ninesky.Models.UserGroup
@{
ViewBag.Title = "修改用户组";
Layout = "~/Views/Layout/_Manage.cshtml";
}
div class="left">
div class="top">/div>
左侧列表
/div>
div class="split">/div>
div class="workspace">
div class="inside">
div class="notebar">
img alt="" src="~/Skins/Default/Manage/Images/UserGroup.gif" />修改用户组资料
/div>
@using (Html.BeginForm("Eidt","UserGroup"))
{
@Html.ValidationSummary(true)
fieldset>
legend>用户组资料/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="保存" />
/div>
/li>
/ul>
/fieldset>
}
/div>
/div>
div class="clear">/div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
[HttpPost]
[AdminAuthorize]
public ActionResult Eidt(UserGroup userGroup)
{
userGroupRsy = new UserGroupRepository();
var _userGroup = userGroupRsy.Find(userGroup.UserGroupId);
if (_userGroup == null)
{
Error _e = new Error { Title = "用户组不存在", Details = "修改用户时发生错误,修改的用户组不存在。", Cause = "该用户组已被其他管理员删除", Solution = Server.UrlEncode("li>返回a href='" + Url.Action("List", "UserGroup") + "'>用户组列表/a>/li>") };
return RedirectToAction("ManageError", "Prompt", _e);
}
_userGroup.Name = userGroup.Name;
_userGroup.Description = userGroup.Description;
if (userGroupRsy.Update(_userGroup))
{
Notice _n = new Notice { Title = "修改成功", Details = "成功修改了用户组信息", DwellTime = 3, NavigationName = "用户组列表", NavigationUrl = Url.Action("List", "UserGroup") };
return RedirectToAction("ManageNotice", "Prompt", _n);
}
else
{
Error _e = new Error { Title = "更新数据失败", Details = "修改用户组信息时修改的信息未能保存到数据库。", Cause = Server.UrlEncode("li>您并未更改用户组信息。/li>li>数据库未知错误。/li>"), Solution = Server.UrlEncode("li>返回a href='" + Url.Action("List", "UserGroup") + "'>用户组列表/a>/li>li>重新a href='" + Url.Action("Edit", "UserGroup", new { id = userGroup.UserGroupId }) + "'>修改用户组/a>/li>") };
return RedirectToAction("ManageError", "Prompt", _e);
}
}