Asp.net core mvc update after approval

Viewed 221

I have two tables one has all the employee information the second one like log or history for the changes

what I want to do is

the employee can update his information but it will not update the main table unless the manger approve the changes when the manger approve the changes it will update the main table which has all the employee information

how I can do this and please note that I am beginner in asp.net core MVC & Entity framework core

Thanks.

2 Answers

The easiest is to:

  1. Make a 2nd classes in your code, you can inherit from the employee, let's call it EmployeeAproval
  2. When changes are needed to be made then find the latest change request that is not approved and load it, or, copy the employee data in a new EmployeeAproval instance, show that instance in your screen.
  3. Save the changes made to the EmployeeAproval class, EF will save it in the table for you. 4, Notify the manager that he has changes pending (do not bombard managers they do not like to work) if he has no pending approvals.
  4. Manager approves the change then cast the EmployeeAproval to an Employee instance and save it or find the approved version, copy the changes and save it.
  5. Notify the Employee instance that the changes where approved.

That's the easy way.

The hard way is to set am approved DateTime and duplicate the records make sure you join on latest approved entries etc... becomes a maintenance mess as soon as you hand over the code in 3 years ;-)

Maybe you can share more details about what you keep in history, might help with information about the status of employees (if they have unsaved data that needs approval and so on)

You can use some intermediate table where to keep unsaved employee data. Then maybe add a flag on the employee, that has unsaved changes (that way also the manager knows which rows are looking for approvals) and once is approved update entry with data from intermediate table.

Would be other options as well, but you need to think what happens if the manager denies the changes. (in the case above, data will not be affected)

Related