MVC4制作网站教程第四章 更新栏目4.3(2)

/// <summary> /// 修改栏目信息 /// </summary> /// <param></param> /// <returns></returns> public ActionResult ManageUpdate(Category category) { switch (category.Type) { case 0: category.Navigation = ""; break; case 1: category.Model = ""; category.ContentView = ""; category.Navigation = ""; break; case 2: category.Model = ""; category.CategoryView = ""; category.ContentView = ""; break; } categoryRsy = new CategoryRepository(); if (categoryRsy.Update(category)) { Notice _n = new Notice { Title = "修改栏目成功", Details = "修改栏目成功!", DwellTime = 5, NavigationName = "栏目详细信息", NavigationUrl = Url.Action("ManageDetails", "Category", new { id = category.CategoryId }) }; return RedirectToAction("ManageNotice", "Prompt", _n); } else { Error _e = new Error { Title = "修改栏目失败", Details = "在修改栏目信息时,未能保存到数据库", Cause = "系统错误", Solution = Server.UrlEncode("<li>返回<a href='" + Url.Action("ManageDetails", "Category", new { id = category.CategoryId }) + "'>栏目详细资料</a>页面,修改信息后重新操作</li><li>联系网站管理员</li>") }; return RedirectToAction("ManageError", "Prompt", _e); } }

很简单,首先是判断栏目类型,根据栏目类型清除无关数据,然后将修改保存到数据库。
试一下将“测试栏目”改成“公司简介” 

MVC4制作网站教程第四章 更新栏目4.3

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyjzs.html