ASP.net MVC4 -- History Log (UPDATE / DELETE)

I like
http://www.codeproject.com/Articles/34491/Implementing-Audit-Trail-using-Entity-Framework-Pa
but it is not for MVC4.

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

Steps
 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
-----------------------------------------------------------------
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(MAINT_WORK_REQ maint_work_req)
        {
            if (ModelState.IsValid)
            {
                db.Entry(maint_work_req).State = EntityState.Modified;
                try
                {
                    //OurTechSignature_Date
                    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;

                    db.SaveChanges();
                    .... something like "db.SaveAuditLog()" here
finance_teacherAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard LeeSoftware EnthusiastCommented:
I am not clear what is the question here?

There is not special solution for Audit logs in MVC. Solutions that work anywhere else will work with MVC and Entity Framework.

1. If you use a trigger then that gets executed at the database level and no need to worry about it in your c# code.

2. If you are manually saving to an audit table then simple insert into that table. Wrapping this in a transaction would be handy.

DaTribe
finance_teacherAuthor Commented:
Do you have some sample code for your #2 solution ?
Aaron JabamaniTechnical ArchitectCommented:
Use "Change Capture" feature in sql server 2008 to do audit.

Look into the link for more details...http://forums.asp.net/post/2693763.aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.