0

Can't seem to find information on this anywhere. I'm looking for something similar to this audit trails feature but I also want the user to be able to add a reason as to why they are making the change.

Basically I just want to add a partial view / Editor Template(not sure which to use) onto the edit/create.cshtml pages.

This would then show the strongly types Audit Model or partial view containing just this note allowing an input to be saved at the same time as the main model.

Would I have to add a property to this Audit class on every other class definition?

public partial class Job
{
 public Audit audit { get; set; }
}

controller

 public async Task<ActionResult> Edit(int? id)
    {
 Job job = await db.Jobs.FindAsync(id);
 job.audit = new Audit();

        return View(job);
    }

cshtml

 @Html.EditorFor(model => model.audit, new { htmlAttributes = new { @class = "form-control" } })

I want to add this to every controller so having to add the above code to each section seems like the wrong approach, however I don't know the correct way to tackle this

2
  • Please see How do I ask a good question?. Be sure to also include code if it helps clarify the question.
    – Igor
    Feb 23, 2016 at 15:25
  • Edited the question to give more insight, the above does seem to work, but I'm unsure if there is a better way?
    – Chris
    Feb 24, 2016 at 9:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.