doerffler/accounting-control-center

Generation of test data does not refresh the data of loaded viewmodels

timo2o1o opened this issue · 8 comments

Describe the bug
The generator for testdata directcly writes to the database using the service. If you opened one of the windows before creating the test data, the newly generated data will not be displayed in this window as long as you restart the whole application.

To Reproduce
Steps to reproduce the behavior:

  1. With a clean database go to main window
  2. Open any window (e.g Kostenstellen bearbeiten)
  3. See an empty window
  4. Click on main menu button (doerffler-icon top left)
  5. Hover over "Testdaten"
  6. Click on "Vollständie Testdaten generieren"
  7. Open the window (e.g Kostenstellen bearbeiten) again
  8. See an empty window
  9. Restart the application
  10. Open the window (e.g Kostenstellen bearbeiten) again
  11. See that now the testdata will be shown.

Expected behavior
The testdata should be shown in all the windows right after you generated it. Even if you opened the window before test data creation.

@timo2o1o
I think I have found a way to keep the data "up to date" in the DataContext. I will test this tomorrow and create a pull request if necessary.

Here is my intention

https://stackoverflow.com/questions/38138100/addtransient-addscoped-and-addsingleton-services-differences#:~:text=Transient%20objects%20are,and%20every%20request.

We probably need to switch from singleton to transient for the view models.

Then Issue #44 is probably no longer necessary or?

@timo2o1o

I think I have found a way to keep the data "up to date" in the DataContext. I will test this tomorrow and create a pull request if necessary.

Here is my intention

https://stackoverflow.com/questions/38138100/addtransient-addscoped-and-addsingleton-services-differences#:~:text=Transient%20objects%20are,and%20every%20request.

We probably need to switch from singleton to transient for the view models.

Then Issue #44 is probably no longer necessary or?

Hi @Jusdon, I'm afraid this would cause some other issues. The biggest problem in my opinion is that we would be more dependent on the database connection, because that would be queried every time a transient viewmodel would be created. Another problem is, that you could not add data (e.g a new Kostenstelle) in one window and reference it in another window (e.g Mitarbeiter) without saving it to the database inbetween.

@timo2o1o

I think I have found a way to keep the data "up to date" in the DataContext. I will test this tomorrow and create a pull request if necessary.

Here is my intention

https://stackoverflow.com/questions/38138100/addtransient-addscoped-and-addsingleton-services-differences#:~:text=Transient%20objects%20are,and%20every%20request.

We probably need to switch from singleton to transient for the view models.

Then Issue #44 is probably no longer necessary or?

Hi @Jusdon, I'm afraid this would cause some other issues. The biggest problem in my opinion is that we would be more dependent on the database connection, because that would be queried every time a transient viewmodel would be created. Another problem is, that you could not add data (e.g a new Kostenstelle) in one window and reference it in another window (e.g Mitarbeiter) without saving it to the database inbetween.

@timo2o1o

Oh crap... I see what you mean :(

But then the scope would be the right one for our use case, right?

"Scoped objects are the same within a request, but different across different requests."

@timo2o1o

I think I have found a way to keep the data "up to date" in the DataContext. I will test this tomorrow and create a pull request if necessary.

Here is my intention

https://stackoverflow.com/questions/38138100/addtransient-addscoped-and-addsingleton-services-differences#:~:text=Transient%20objects%20are,and%20every%20request.

We probably need to switch from singleton to transient for the view models.

Then Issue #44 is probably no longer necessary or?

Hi @Jusdon, I'm afraid this would cause some other issues. The biggest problem in my opinion is that we would be more dependent on the database connection, because that would be queried every time a transient viewmodel would be created. Another problem is, that you could not add data (e.g a new Kostenstelle) in one window and reference it in another window (e.g Mitarbeiter) without saving it to the database inbetween.

@timo2o1o

Oh crap... I see what you mean :(

But then the scope would be the right one for our use case, right?

"Scoped objects are the same within a request, but different across different requests."

I'm not sure, but it's worth to give it a try!

How can I test the case you mentioned? How can I reproduce it to see if it works with Scopes?

How can I test the case you mentioned? How can I reproduce it to see if it works with Scopes?

  1. Open the Window to Manage Mitarbeiter
  2. (Choose a Mitarbeiter or create a new one from the list on the left)
  3. Click on the Button to add a new Kostenstelle to the combobox Mitarbeiterkostenstelle
  4. Enter a name into the dialog and click okay
  5. Minimize the Mitarbeiterwindow or close it. But do not Hit the save Button.
  6. Open the Window to manage Kostenstelle
  7. The Kostenstelle you just created should be part of the list on the left.

How can I test the case you mentioned? How can I reproduce it to see if it works with Scopes?

  1. Open the Window to Manage Mitarbeiter
  2. (Choose a Mitarbeiter or create a new one from the list on the left)
  3. Click on the Button to add a new Kostenstelle to the combobox Mitarbeiterkostenstelle
  4. Enter a name into the dialog and click okay
  5. Minimize the Mitarbeiterwindow or close it. But do not Hit the save Button.
  6. Open the Window to manage Kostenstelle
  7. The Kostenstelle you just created should be part of the list on the left.

Thanks :)

Please send a refresh message after creation of test data