我试图添加"历史"当我的编辑页面提交对"记录的更改时,在另一个表中。表。我想保存记录ID,日期,用户ID以及已更改的旧值的列表(列名,更改内容以及更改内容)。
到目前为止,基本控制器是:
// GET: Record/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
TM_Records tM_Records = db.TM_Records.Find(id);
if (tM_Records == null)
{
return HttpNotFound();
}
ViewBag.Consult_Type = new SelectList(db.TM_Consult_Types, "TM_Consult_Type_ID", "TM_Consult_Type_Name", tM_Records.Consult_Type);
ViewBag.Department = new SelectList(db.TM_Departments, "Dept_ID", "Dept_Name", tM_Records.Department);
ViewBag.FSC = new SelectList(db.TM_FSCs_dim, "TM_FSC_ID", "TM_FSC_NAME", tM_Records.FSC);
ViewBag.Gender = new SelectList(db.TM_Genders_dim, "TM_Gender_ID", "TM_Gender_Name", tM_Records.Gender);
return View(tM_Records);
}
// POST: Record/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "Index_key,Hospital,NMXS_Consult_ID,DateTime_Requested,DateTime_Answered,DateTime_Completed,Patient_Name,DOB,MRN,Requesting_Provider,Consulting_Provider,Duration_Minutes,Ready_to_Review,DateTime_Reviewed,Bill_To,Bill_Amount,Consulting_Provider_ID,Requester_NPI,DateTime_Billed,DateTime_Payment_received,Amt_Received,Reconcile_Exception_Amt,File_Location,Initial_Diagnosis,Final_Diagnosis,Date_Loaded,Date_Updated,Gender,FSC,Consult_Type,Rec_Notes,Department,Valid_Record,DateTime_Billed_Rpt_Run")] TM_Records tM_Records)
{
if (ModelState.IsValid)
{
db.Entry(tM_Records).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.Consult_Type = new SelectList(db.TM_Consult_Types, "TM_Consult_Type_ID", "TM_Consult_Type_Name", tM_Records.Consult_Type);
ViewBag.Department = new SelectList(db.TM_Departments, "Dept_ID", "Dept_Name", tM_Records.Department);
ViewBag.FSC = new SelectList(db.TM_FSCs_dim, "TM_FSC_ID", "TM_FSC_NAME", tM_Records.FSC);
ViewBag.Gender = new SelectList(db.TM_Genders_dim, "TM_Gender_ID", "TM_Gender_Name", tM_Records.Gender);
return View(tM_Records);
}
我尝试使用以下详细信息向TM_History表添加新记录:
Columns:
TM_Hist_ID, (primary key)
TM_Hist_Record_ID, (the record that was modified)
TM_Hist_Date, (populate with now())
TM_Hist_Values, (changes e.g. Price: $320 >> $220 | Note: "" >> $100 coupon)
TM_Hist_Ident_ID (User.Identity.Name)
我搜索过stackoverflow并且找不到任何适合此问题的答案。
感谢您的考虑。
罗伯特