0

I have such a question. Is it possible to Undo the CRUD Operation (MVC-EF6, asp.net).

  1. The UNDO Of ADD will be Delete The UNDO of DELETE will be ADD The
  2. UNDO of EDIT have to get the previous changes made.
  3. How can we implement this behavior ?

I could not find how we can implement that undoing operations, so I wanna try to ask here.

Thanks :)

Romo Daneghyan
  • 2,099
  • 3
  • 18
  • 23
  • There are many different ways you could do this, what have you tried, how far have you got? What problems have you encountered? – Ben Robinson Aug 27 '14 at 11:51
  • @Raghu no, that is preventing changes to be saved. OP: do you want that, or to revert changes already committed to the database? – CodeCaster Aug 27 '14 at 11:52
  • Yeah @CodeCaster I do, I have not done anything yet, because I am not familiar to UNDO operations here, so I have to know where and how to start implementation. – Romo Daneghyan Aug 27 '14 at 11:53
  • context.Refresh() will reload from the entity and remove all changes. Revert from a commit you would have to track outside. – juanvan Aug 27 '14 at 11:54
  • I don't need to revert everything @juanvan, I just need to Undo changes one step back. – Romo Daneghyan Aug 27 '14 at 12:02
  • @juanvan, where should I use the context.Refresh() ? In my Controller class ? ( I am not master in MVC ) – Romo Daneghyan Aug 27 '14 at 12:06
  • use a status field for the tables that you want apply the undo for example the table status might be ( pending approval, approved , deleted, cancelled,...etc), once you add new row on the table, the status will be pending approval, then you make an action to commit the data by making the status as approved, and later for special authority, some power users can return the status to be pending approval or deleted or cancelled, hope this will help you – Monah Aug 27 '14 at 12:21

0 Answers0