我需要获取(UserUniqueId)
在 Get 操作期间存储的属性的值。
public ActionResult Create(int uniqueId = -1)
{
w = new Work { UserUniqueId = uniqueId };
//todo: how to pass uniqueId while rendering view. such that must receive it back during post.
return View(w);
}
查看不会填充/更新此值。我需要访问UserUniqueId
数据库保存操作。
[HttpPost]
public ActionResult Create(Work work)
{
if (ModelState.IsValid)
{
//Set uniqueId, Set UserId
int userId = WebSecurity.HasUserId ? WebSecurity.CurrentUserId : -1;
work.UserId = WebSecurity.CurrentUserId;
//Need previously stored uniqueId here.
work.UserUniqueId = //How do I obtain this value here.
db.SaveChanges();
return RedirectToAction("Index");
}
return View(work);
}