0
大家好,你能告訴我還在學習,我不知道如何或什麼是爲了使用重用我的代碼的數據庫操作的最佳方法;例如下面MVC3我怎麼能重用我的ActionResult代碼
代碼// i reuse this code multiple times throughout my site but everytime I change it I must change
// all of the different Edit's each time I would like a central hub for all of it.
[Authorize]
public ActionResult Edit()
{
var ss = User.Identity.Name;
int myid = Convert.ToInt32(ss);
var buyer = (from s in db.buyers where myid == s.RegistrationID select s).FirstOrDefault();
ViewBag.RegistrationID = myid;
if (buyer != null && buyer.RegistrationID == myid)
{
return View(buyer);
}
else
{
RedirectToAction("buyerrequire");
}
return View("buyerrequire");
}
如何將這些代碼放入可重複使用的容器中?所以如果我改變了那裏的東西,它會改變整個網站使用那個容器,整理像一個_部分除了ActionResults ...感謝您的幫助..