troubleshooting Question MVC4 -- History Log (UPDATE / DELETE)

Avatar of finance_teacher
finance_teacher asked on
.NET ProgrammingC#ASP.NET
3 Comments1 Solution1038 ViewsLast Modified:
I like
but it is not for MVC4.

What easy " MVC4 History Log"
solution do you have so the below works ?

 1. user clicks SAVE on Edit.cshtml as normal
 2. below code runs as normal
 3. somehow (via code or MSSQL database trigger) it writes
    only changed values to my "AUDIT_LOG" database table
        public ActionResult Edit(MAINT_WORK_REQ maint_work_req)
            if (ModelState.IsValid)
                db.Entry(maint_work_req).State = EntityState.Modified;
                    if (maint_work_req.OurTechSignature_Date == null)
                        if (Request["Signature_Tech_Checked"].Contains("true"))
                            var context = new UsersContext();
                            UserProfile myProfile = context.UserProfiles.SingleOrDefault(u => u.UserName == User.Identity.Name);
                            maint_work_req.OurTechSignature_Date = myProfile.FirstName + " " + myProfile.LastName + " " + DateTime.Now.ToShortDateString();

                    var context2 = new UsersContext();
                    UserProfile myProfile2 = context2.UserProfiles.SingleOrDefault(u => u.UserName == User.Identity.Name);
                    maint_work_req.LastModifiedDate = DateTime.Now;
                    maint_work_req.LastModifiedBy = myProfile2.FirstName + " " + myProfile2.LastName;

                    .... something like "db.SaveAuditLog()" here
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros